From: Adam Dickmeiss Date: Tue, 3 Jan 2017 10:50:15 +0000 (+0100) Subject: Make image with build tools X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=19646e2cd7432de9eaa255b0543755c31f2d661e;p=git-tools-moved-to-github.git Make image with build tools This reduces total time for building packages a lot as soon as the image is created once. --- diff --git a/id-deb-build/docker-build.sh b/id-deb-build/docker-build.sh index 780bcfc..8ae0d73 100755 --- a/id-deb-build/docker-build.sh +++ b/id-deb-build/docker-build.sh @@ -204,7 +204,6 @@ fi if test "${CENTOS_DIST}"; then for dist in ${CENTOS_DIST}; do - echo -n "$dist " case $dist in centos6) D=6;; @@ -215,7 +214,15 @@ if test "${CENTOS_DIST}"; then exit 1 esac cd build/centos/$dist - docker run --rm -v "$PWD:/build" -w /build/rpmbuild centos:$D ../in-docker-rpm.sh centos $D >log 2>&1 + + echo "FROM centos:$D" >Dockerfile + echo "RUN yum install -y wget yum-utils rpm-build gcc gcc-c++ make" >>Dockerfile + echo "RUN rpm --import http://ftp.indexdata.com/pub/yum/centos/$D/RPM-GPG-KEY-indexdata" >>Dockerfile + echo "RUN wget http://ftp.indexdata.com/pub/yum/centos/$D/indexdata.repo -P /etc/yum.repos.d/" >>Dockerfile + echo 'ENTRYPOINT ["/bin/sh", "-c"]' >>Dockerfile + docker build -t indexdata-build-centos-$D . + echo -n "$dist " + docker run --rm -v "$PWD:/build" -w /build/rpmbuild indexdata-build-centos-$D ../in-docker-rpm.sh >log 2>&1 if test $? -eq 0; then echo Done else @@ -226,9 +233,14 @@ if test "${CENTOS_DIST}"; then fi if test "${DEBIAN_DIST}"; then for dist in ${DEBIAN_DIST}; do - echo -n "Debian $dist " cd build/debian/$dist - docker run --rm -v "$PWD:/build" -w /build/$PRODUCT-$VERSION debian:$dist ../in-docker.sh debian $dist >log 2>&1 + echo "FROM debian:$dist" >Dockerfile + echo 'RUN apt-get update && apt-get -q install -y wget devscripts equivs' >>Dockerfile + echo 'RUN wget -q -O - http://ftp.indexdata.dk/debian/indexdata.asc|apt-key add -' >>Dockerfile + echo "RUN echo \"deb http://ftp.indexdata.dk/debian $dist main\" >/etc/apt/sources.list.d/indexdata.list" >>Dockerfile + docker build -t indexdata-build-debian-$dist . + echo -n "Debian $dist " + docker run --rm -v "$PWD:/build" -w /build/$PRODUCT-$VERSION indexdata-build-debian-$dist ../in-docker.sh >log 2>&1 if test $? -eq 0; then echo Done else @@ -239,9 +251,14 @@ if test "${DEBIAN_DIST}"; then fi if test "${UBUNTU_DIST}"; then for dist in ${UBUNTU_DIST}; do - echo -n "Ubuntu $dist" cd build/ubuntu/$dist - docker run --rm -v "$PWD:/build" -w /build/$PRODUCT-$VERSION ubuntu:$dist ../in-docker.sh ubuntu $dist >log 2>&1 + echo "FROM ubuntu:$dist" >Dockerfile + echo 'RUN apt-get update && apt-get -q install -y wget devscripts equivs' >>Dockerfile + echo 'RUN wget -q -O - http://ftp.indexdata.dk/debian/indexdata.asc|apt-key add -' >>Dockerfile + echo "RUN echo \"deb http://ftp.indexdata.dk/ubuntu $dist main\" >/etc/apt/sources.list.d/indexdata.list" >>Dockerfile + docker build -t indexdata-build-ubuntu-$dist . + echo -n "Ubuntu $dist " + docker run --rm -v "$PWD:/build" -w /build/$PRODUCT-$VERSION indexdata-build-ubuntu-$dist ../in-docker.sh >log 2>&1 if test $? -eq 0; then echo Done else diff --git a/id-deb-build/in-docker-rpm.sh b/id-deb-build/in-docker-rpm.sh index fe68b2f..fa41656 100755 --- a/id-deb-build/in-docker-rpm.sh +++ b/id-deb-build/in-docker-rpm.sh @@ -2,14 +2,6 @@ # in-docker-rpm.sh set -x -DIST=$1 -STEP=$2 - -yum install -y wget yum-utils rpm-build gcc gcc-c++ make - -rpm --import http://ftp.indexdata.com/pub/yum/centos/$STEP/RPM-GPG-KEY-indexdata - -wget http://ftp.indexdata.com/pub/yum/centos/$STEP/indexdata.repo -P /etc/yum.repos.d/ echo "%_topdir /build/rpmbuild" >$HOME/.rpmmacros echo "%_source_filedigest_algorithm 0" >>$HOME/.rpmmacros diff --git a/id-deb-build/in-docker.sh b/id-deb-build/in-docker.sh index 96fa8ef..c48a9eb 100755 --- a/id-deb-build/in-docker.sh +++ b/id-deb-build/in-docker.sh @@ -1,26 +1,15 @@ #!/bin/sh # in-docker.sh -# Build Debian package in Docker. Use steps like this: -# make dist -# ../git-tools/id-deb-build/id-mk-deb-src.sh - -# docker run -it --rm -v "$PWD:/build" -w /build/product-version debian:jessie ./in-docker.sh -# set -x -OS=$1 -DIST=$2 DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND -apt-get -q update && apt-get -q install -y wget devscripts equivs -wget -q -O - http://ftp.indexdata.dk/debian/indexdata.asc|apt-key add - -echo "deb http://ftp.indexdata.dk/${OS} ${DIST} main" >/etc/apt/sources.list.d/indexdata.list -apt-get -q update - +# we want the newest Index Data packages +apt-get update mk-build-deps dpkg -i *-build-deps_*_all.deb || apt-get -q install -f -y -rm *-build-deps_*_all.deb +rm *-build-deps_*_all.deb dpkg-buildpackage -rfakeroot RET=$?