-
Notifications
You must be signed in to change notification settings - Fork 353
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3034 from OCamlPro/release-building
Add rules for automatised release builds
- Loading branch information
Showing
9 changed files
with
172 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
FROM multiarch/debian-debootstrap:%TARGET_TAG% | ||
# May need configuration on the host: | ||
# docker run --rm --privileged multiarch/qemu-user-static:register --reset | ||
LABEL Description="opam release builds" Vendor="OCamlPro" Version="1.0" | ||
|
||
RUN apt-get update && apt-get install bzip2 g++ make patch wget libglpk-dev libltdl-dev --yes && apt-get clean --yes | ||
RUN useradd -U --create-home opam | ||
|
||
ADD https://caml.inria.fr/pub/distrib/ocaml-4.04/ocaml-4.04.2.tar.gz /root/ | ||
|
||
WORKDIR /root | ||
RUN tar xzf ocaml-4.04.2.tar.gz | ||
WORKDIR ocaml-4.04.2 | ||
RUN ./configure %CONF% -prefix /usr/local | ||
RUN make world opt.opt | ||
RUN make install | ||
RUN rm -rf /root/ocaml-4.04.2 /root/ocaml-4.04.2.tar.gz | ||
|
||
ENV PATH /usr/local/bin:/usr/bin:/bin | ||
USER opam | ||
VOLUME /src | ||
WORKDIR /home/opam/ | ||
CMD tar xzf /src/opam-full-${VERSION}.tar.gz && \ | ||
cd opam-full-${VERSION} && \ | ||
echo "(${LINKING})" > src/client/linking.sexp && \ | ||
./configure --with-mccs && \ | ||
make lib-ext opam && \ | ||
strip opam && \ | ||
cp opam /src/opam-${VERSION}-${TARGET} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
TAG = master | ||
VERSION = $(shell git describe $(TAG) | sed 's/-/~/') | ||
GIT_URL = .. | ||
|
||
FULL_ARCHIVE_URL = https://github.com/ocaml/opam/releases/download/$(VERSION)/opam-full-$(VERSION).tar.gz | ||
|
||
TARGETS = x86_64-linux i686-linux armhf-linux arm64-linux | ||
# todo: x86_64-darwin | ||
|
||
OCAMLV = 4.04.2 | ||
# currently hardcoded in Dockerfile.in | ||
OCAML_URL = https://caml.inria.fr/pub/distrib/ocaml-$(basename $(OCAMLV))/ocaml-$(OCAMLV).tar.gz | ||
|
||
HOST_OS = $(shell uname -s | tr A-Z a-z) | ||
HOST = $(shell uname -m)-$(HOST_OS) | ||
|
||
all: $(patsubst %,out/opam-$(VERSION)-%,$(TARGETS)) | ||
|
||
out/opam-full-$(VERSION).tar.gz: | ||
mkdir -p out | ||
cd out && curl -OL $(FULL_ARCHIVE_URL) || { \ | ||
git clone $(GIT_URL) -b $(TAG) --depth 1 opam-full-$(VERSION); \ | ||
sed -i 's/^AC_INIT(opam,.*)/AC_INIT(opam,$(VERSION))/' \ | ||
opam-full-$(VERSION)/configure.ac; \ | ||
cd opam-full-$(VERSION) && $(MAKE) configure download-ext; \ | ||
tar cz --exclude-vcs opam-full-$(VERSION) -f $@; \ | ||
rm -rf opam-full-$(VERSION); \ | ||
} | ||
|
||
build/Dockerfile.x86_64-linux: Dockerfile.in | ||
mkdir -p build && sed 's/%TARGET_TAG%/amd64-jessie/g' $^ | sed 's/%CONF%//g' >$@ | ||
build/Dockerfile.i686-linux: Dockerfile.in | ||
mkdir -p build && sed 's/%TARGET_TAG%/i386-jessie/g' $^ | sed 's/%CONF%/-host i686-linux/g' >$@ | ||
build/Dockerfile.armhf-linux: Dockerfile.in | ||
mkdir -p build && sed 's/%TARGET_TAG%/armhf-jessie/g' $^ | sed 's/%CONF%//g' >$@ | ||
build/Dockerfile.arm64-linux: Dockerfile.in | ||
mkdir -p build && sed 's/%TARGET_TAG%/arm64-jessie/g' $^ | sed 's/%CONF%//g' >$@ | ||
|
||
|
||
build/%.image: build/Dockerfile.% | ||
docker build -t opam-build-$* -f $^ build | ||
touch $@ | ||
|
||
# Actually, this is for debian 8 jessie, and varies wildly | ||
CLINKING_linux = \ | ||
-Wl,-Bstatic \ | ||
-lunix -lbigarray -lmccs_stubs \ | ||
-lglpk -lstdc++ -lz -lamd -lcolamd -lltdl \ | ||
-Wl,-Bdynamic \ | ||
-static-libgcc | ||
|
||
CLINKING_darwin = \ | ||
-lunix -lbigarray -lmccs_stubs \ | ||
/usr/local/lib/libglpk.a -lz -lstdc++ | ||
|
||
CLINKING_openbsd = $(CLINKING_darwin) | ||
|
||
EXPORTS_openbsd = \ | ||
CPATH=/usr/local/include: \ | ||
LIBRARY_PATH=/usr/local/lib: \ | ||
|
||
|
||
%: opam-$(VERSION)-% | ||
|
||
opam-$(VERSION)-%: out/opam-$(VERSION)-% | ||
ln -sf $^ $@ | ||
|
||
host: opam-$(VERSION)-$(HOST) | ||
|
||
# Build for the local host. Containerised builds, below, are preferred, but not always available | ||
build/$(HOST).env: | ||
mkdir -p build/$(HOST) | ||
cd build/$(HOST) && curl -OL $(OCAML_URL) | ||
cd build/$(HOST) && tar xzf ocaml-$(OCAMLV).tar.gz | ||
cd build/$(HOST)/ocaml-$(OCAMLV) && \ | ||
./configure -prefix $(shell pwd)/build/$(HOST) && \ | ||
$(MAKE) world opt.opt && \ | ||
$(MAKE) install | ||
rm -rf build/$(HOST)/ocaml-$(OCAMLV) build/$(HOST)/ocaml-$(OCAMLV).tar.gz | ||
touch $@ | ||
|
||
out/opam-$(VERSION)-$(HOST): out/opam-full-$(VERSION).tar.gz build/$(HOST).env | ||
cd build && tar xzf ../$< | ||
( export \ | ||
PATH=$(shell pwd)/build/$(HOST)/bin:$$PATH \ | ||
MAKE=$(MAKE) \ | ||
$(EXPORTS_$(HOST_OS)); \ | ||
cd build/opam-full-$(VERSION) && \ | ||
./configure --with-glpk && \ | ||
echo "(-noautolink $(patsubst %,-cclib %,$(CLINKING_$(HOST_OS))))" \ | ||
>src/client/linking.sexp && \ | ||
$(MAKE) lib-ext opam JBUILDER_ARGS="--root=`pwd`"; \ | ||
) | ||
strip build/opam-full-$(VERSION)/opam | ||
cp build/opam-full-$(VERSION)/opam out/opam-$(VERSION)-$(HOST) | ||
rm -rf build/opam-full-$(VERSION) | ||
|
||
# Containerised builds | ||
out/opam-$(VERSION)-%-linux: build/%-linux.image out/opam-full-$(VERSION).tar.gz | ||
docker run --rm -v `pwd`/out:/src \ | ||
-e "VERSION=$(VERSION)" \ | ||
-e "TARGET=$*-linux" \ | ||
-e "LINKING=$(LINKING_jessie)" \ | ||
opam-build-$*-linux | ||
|
||
clean: | ||
rm -rf build | ||
|
||
distclean: clean | ||
rm -rf out | ||
|
||
REMOTE_DIR = /tmp/opam-release | ||
REMOTE_MAKE = gmake | ||
remote: out/opam-full-$(VERSION).tar.gz | ||
ssh "$(REMOTE)" "mkdir -p $(REMOTE_DIR)/out" | ||
scp Makefile "$(REMOTE):$(REMOTE_DIR)/" | ||
scp "$^" "$(REMOTE):$(REMOTE_DIR)/$^" | ||
ssh "$(REMOTE)" 'sh -c "cd $(REMOTE_DIR) && $(REMOTE_MAKE) host TAG=$(TAG) VERSION=$(VERSION) OCAMLV=$(OCAMLV)"' | ||
scp "$(REMOTE):$(REMOTE_DIR)/out/opam-$(VERSION)*" out/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters