mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-21 10:09:07 +00:00
Add container for MirageOS compiler
Signed-off-by: Thomas Gazagnaire <thomas@gazagnaire.org>
This commit is contained in:
parent
f2c64f4482
commit
1715e0b464
3
tools/mirage-compile/.gitignore
vendored
Normal file
3
tools/mirage-compile/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
*.hash
|
||||
functoria
|
||||
mirage
|
18
tools/mirage-compile/Dockerfile
Normal file
18
tools/mirage-compile/Dockerfile
Normal file
@ -0,0 +1,18 @@
|
||||
FROM ocaml/opam:alpine-3.5_ocaml-4.04.0
|
||||
RUN git -C /home/opam/opam-repository pull origin master && opam update -u
|
||||
|
||||
RUN opam pin add -n functoria https://github.com/samoht/functoria.git#output
|
||||
RUN opam pin add -n mirage https://github.com/samoht/mirage.git#static
|
||||
RUN opam pin add -n mirage-net-fd https://github.com/mirage/mirage-net-fd.git
|
||||
RUN opam pin add -n charrua-client https://github.com/yomimono/charrua-client.git#state-halfway
|
||||
RUN opam depext -uiy ocamlfind topkg-care ocamlbuild lwt mirage-types-lwt mirage
|
||||
RUN opam depext -uiy charrua-client cohttp conduit mirage-unix
|
||||
RUN opam depext -uiy mirage-net-fd ptime mirage-logs
|
||||
|
||||
RUN sudo mkdir -p /src
|
||||
RUN sudo chown -R opam /src
|
||||
WORKDIR /src
|
||||
|
||||
COPY compile.sh /usr/bin/
|
||||
|
||||
ENTRYPOINT ["/usr/bin/compile.sh"]
|
33
tools/mirage-compile/Makefile
Normal file
33
tools/mirage-compile/Makefile
Normal file
@ -0,0 +1,33 @@
|
||||
.PHONY: tag push
|
||||
|
||||
BASE=ocaml/opam:alpine-3.5_ocaml-4.04.0
|
||||
IMAGE=mirage-compile
|
||||
|
||||
default: push
|
||||
|
||||
hash: Dockerfile compile.sh
|
||||
docker pull $(BASE)
|
||||
tar cf - $^ | docker build -t $(IMAGE):build -
|
||||
docker run --rm --entrypoint=/bin/sh $(IMAGE):build -c \
|
||||
'{ dpkg-query -W; \
|
||||
opam list; \
|
||||
cat /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 $(HASHES)
|
||||
|
||||
.DELETE_ON_ERROR:
|
48
tools/mirage-compile/compile.sh
Executable file
48
tools/mirage-compile/compile.sh
Executable file
@ -0,0 +1,48 @@
|
||||
#!/bin/sh
|
||||
|
||||
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
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option $1"
|
||||
exit 1
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
[ -z "$out" ] && usage
|
||||
|
||||
package=$(basename "$out")
|
||||
|
||||
dir="/src"
|
||||
|
||||
# untar input
|
||||
tar xf - -C $dir
|
||||
|
||||
(
|
||||
cd $dir
|
||||
opam config exec -- mirage configure -o $out -t unix
|
||||
opam config exec -- make depend
|
||||
opam config exec -- make
|
||||
mv $(readlink $out) $out
|
||||
) > /src/logs 2>&1
|
||||
|
||||
cd $dir && tar -cf - $out
|
||||
|
||||
exit 0
|
Loading…
Reference in New Issue
Block a user