mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-09-29 08:13:40 +00:00
Split base/ into base/ and tools/
Signed-off-by: Riyaz Faizullabhoy <riyaz.faizullabhoy@docker.com>
This commit is contained in:
15
tools/c-compile/Dockerfile
Normal file
15
tools/c-compile/Dockerfile
Normal file
@@ -0,0 +1,15 @@
|
||||
FROM alpine:3.5
|
||||
RUN \
|
||||
apk update && apk upgrade && \
|
||||
apk add \
|
||||
curl \
|
||||
gcc \
|
||||
git \
|
||||
libc-dev \
|
||||
linux-headers \
|
||||
util-linux-dev \
|
||||
&& true
|
||||
|
||||
COPY compile.sh /usr/bin/
|
||||
|
||||
ENTRYPOINT ["/usr/bin/compile.sh"]
|
29
tools/c-compile/Makefile
Normal file
29
tools/c-compile/Makefile
Normal file
@@ -0,0 +1,29 @@
|
||||
.PHONY: tag push
|
||||
|
||||
BASE=alpine:3.5
|
||||
IMAGE=c-compile
|
||||
|
||||
default: push
|
||||
|
||||
hash: Dockerfile compile.sh
|
||||
DOCKER_CONTENT_TRUST=1 docker pull $(BASE)
|
||||
tar cf - $^ | docker build --no-cache -t $(IMAGE):build -
|
||||
docker run --rm --entrypoint=/bin/sh $(IMAGE):build -c 'cat /lib/apk/db/installed /usr/bin/compile.sh | sha1sum' | sed 's/ .*//' > hash
|
||||
|
||||
push: hash
|
||||
docker pull mobylinux/$(IMAGE):$(shell cat hash) || \
|
||||
(docker tag $(IMAGE):build mobylinux/$(IMAGE):$(shell cat hash) && \
|
||||
docker push mobylinux/$(IMAGE):$(shell cat hash))
|
||||
docker rmi $(IMAGE):build
|
||||
rm -f hash
|
||||
|
||||
tag: hash
|
||||
docker pull mobylinux/$(IMAGE):$(shell cat hash) || \
|
||||
docker tag $(IMAGE):build mobylinux/$(IMAGE):$(shell cat hash)
|
||||
docker rmi $(IMAGE):build
|
||||
rm -f hash
|
||||
|
||||
clean:
|
||||
rm -f hash
|
||||
|
||||
.DELETE_ON_ERROR:
|
56
tools/c-compile/compile.sh
Executable file
56
tools/c-compile/compile.sh
Executable file
@@ -0,0 +1,56 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This is designed to compile a single package to a single binary
|
||||
# so it makes some assumptions about things to simplify config
|
||||
# to output a single binary (in a tarball) just use -o file
|
||||
# use --docker to output a tarball for input to docker build -
|
||||
|
||||
set -e
|
||||
|
||||
usage() {
|
||||
echo "Usage: -o file"
|
||||
exit 1
|
||||
}
|
||||
|
||||
[ $# = 0 ] && usage
|
||||
|
||||
while [ $# -gt 0 ]
|
||||
do
|
||||
flag="$1"
|
||||
case "$flag" in
|
||||
-o)
|
||||
[ $# -eq 1 ] && usage
|
||||
out="$2"
|
||||
mkdir -p "$(dirname $2)"
|
||||
shift
|
||||
;;
|
||||
-l*)
|
||||
LIBS="$LIBS $1"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option $1"
|
||||
exit 1
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
[ -z "$out" ] && usage
|
||||
|
||||
package=$(basename "$out")
|
||||
|
||||
dir="/src/$package"
|
||||
|
||||
mkdir -p $dir
|
||||
|
||||
# untar input
|
||||
tar xf - -C $dir
|
||||
|
||||
(
|
||||
cd $dir
|
||||
CFILES=$(find . -name '*.c')
|
||||
cc -static -O2 -Wall -Werror -o ../../$out $CFILES $LIBS
|
||||
)
|
||||
|
||||
tar cf - $out
|
||||
exit 0
|
Reference in New Issue
Block a user