From f9ad705a532a95702e8a1fea8b200fe6e47568a5 Mon Sep 17 00:00:00 2001 From: dave Date: Fri, 31 May 2019 14:26:56 -0700 Subject: [PATCH] multiple dist support --- .dockerignore | 3 ++- Dockerfile => Dockerfile.bionic | 0 Dockerfile.disco | 14 ++++++++++++++ Dockerfile.trusty | 14 ++++++++++++++ Dockerfile.xenial | 14 ++++++++++++++ README.md | 12 +++++++++++- build.sh | 4 ++-- images.sh | 7 +++++++ scripts/bootstrap.sh | 3 ++- src/Makefile | 3 ++- src/bionic-2.7.16.sh | 1 + src/bionic-3.7.3.sh | 2 ++ src/bionic-3.8.0a4.sh | 1 + src/disco-3.7.3.sh | 8 ++++++++ src/trusty-3.7.3.sh | 12 ++++++++++++ 15 files changed, 92 insertions(+), 6 deletions(-) rename Dockerfile => Dockerfile.bionic (100%) create mode 100644 Dockerfile.disco create mode 100644 Dockerfile.trusty create mode 100644 Dockerfile.xenial create mode 100755 images.sh create mode 100644 src/disco-3.7.3.sh create mode 100644 src/trusty-3.7.3.sh diff --git a/.dockerignore b/.dockerignore index 8f2aca6..a3d0f33 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,4 @@ cpython .git -temp \ No newline at end of file +temp +/src/out \ No newline at end of file diff --git a/Dockerfile b/Dockerfile.bionic similarity index 100% rename from Dockerfile rename to Dockerfile.bionic diff --git a/Dockerfile.disco b/Dockerfile.disco new file mode 100644 index 0000000..b969964 --- /dev/null +++ b/Dockerfile.disco @@ -0,0 +1,14 @@ +FROM ubuntu:disco + +RUN sed -i -E 's/(archive|security).ubuntu.com/192.168.1.142/' /etc/apt/sources.list && \ + sed -i -E 's/^deb-src/# deb-src/' /etc/apt/sources.list && \ + apt-get update && \ + apt-get install -y dpkg-dev debhelper build-essential sudo wget curl + +RUN useradd builder && \ + install -d /build -o builder -g builder + +ADD scripts/bootstrap.sh /bootstrap.sh +ADD scripts/build.sh /build.sh + +ENTRYPOINT ["/bootstrap.sh"] diff --git a/Dockerfile.trusty b/Dockerfile.trusty new file mode 100644 index 0000000..d103ec6 --- /dev/null +++ b/Dockerfile.trusty @@ -0,0 +1,14 @@ +FROM ubuntu:trusty + +RUN sed -i -E 's/(archive|security).ubuntu.com/192.168.1.142/' /etc/apt/sources.list && \ + sed -i -E 's/^deb-src/# deb-src/' /etc/apt/sources.list && \ + apt-get update && \ + apt-get install -y dpkg-dev debhelper build-essential sudo wget curl + +RUN useradd builder && \ + install -d /build -o builder -g builder + +ADD scripts/bootstrap.sh /bootstrap.sh +ADD scripts/build.sh /build.sh + +ENTRYPOINT ["/bootstrap.sh"] diff --git a/Dockerfile.xenial b/Dockerfile.xenial new file mode 100644 index 0000000..7d7e938 --- /dev/null +++ b/Dockerfile.xenial @@ -0,0 +1,14 @@ +FROM ubuntu:xenial + +RUN sed -i -E 's/(archive|security).ubuntu.com/192.168.1.142/' /etc/apt/sources.list && \ + sed -i -E 's/^deb-src/# deb-src/' /etc/apt/sources.list && \ + apt-get update && \ + apt-get install -y dpkg-dev debhelper build-essential sudo wget curl + +RUN useradd builder && \ + install -d /build -o builder -g builder + +ADD scripts/bootstrap.sh /bootstrap.sh +ADD scripts/build.sh /build.sh + +ENTRYPOINT ["/bootstrap.sh"] diff --git a/README.md b/README.md index a202644..6d9ab9b 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,17 @@ Extpython is a collection of tools for building installable packages containing installations are isolated from the operating system's python such that modules may be added, removed, or upgraded without risk of breaking. The builds are executed in Docker. +Example invocation: + +``` +./images.sh +./build.sh trusty-3.7.3.sh +``` + +The vars file - `trusty-3.7.3.sh` above - contains information about what python version will be built. See +`src/bionic-3.7.3.sh` for an annotated example. + + TODO: -- Support other than Bionic - Parameter for pre-loaded pip modules diff --git a/build.sh b/build.sh index 3b6eec6..a356b67 100755 --- a/build.sh +++ b/build.sh @@ -2,6 +2,6 @@ VARSFILE=$1 -ls -la src/$VARSFILE +. src/$VARSFILE -time docker run -it --rm -e "VARSFILE=$VARSFILE" -v $PWD/src:/src extpythonbuilder +time docker run -it --rm -e "VARSFILE=$VARSFILE" -v $PWD/src:/src extbuilder-$EXTPYTHON_DIST diff --git a/images.sh b/images.sh new file mode 100755 index 0000000..8c9b68c --- /dev/null +++ b/images.sh @@ -0,0 +1,7 @@ +#!/bin/bash -ex + +RELEASES="trusty xenial bionic disco" + +for release in $RELEASES ; do + docker build -t extbuilder-${release} -f Dockerfile.${release} . +done diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index 78abfec..e9e2d3a 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -3,6 +3,7 @@ # get metadata ln -s /src/$VARSFILE /tmp/vars.sh . /tmp/vars.sh +. /etc/lsb-release #for DISTRIB_CODENAME # install deps apt-get update @@ -12,6 +13,6 @@ DEBIAN_FRONTEND=noninteractive apt-get install -y -o Dpkg::Options::="--force-co sudo -Hu builder /build.sh # export the debs -OUTDIR="/src/out/$PYTHON_RELEASE/" +OUTDIR="/src/out/${PYTHON_RELEASE}/${DISTRIB_CODENAME}" mkdir -p $OUTDIR cp /build/out/* $OUTDIR diff --git a/src/Makefile b/src/Makefile index f2bb616..172dfe0 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,7 +1,8 @@ #!/usr/bin/make -f PY3_SRC=./cpython/ -PY3_CONFFLAGS=--prefix=$(DESTDIR)/opt/extpython/_OPT_DIR_ --with-ensurepip=install --enable-optimizations +PY3_CONFFLAGS=--prefix=$(DESTDIR)/opt/extpython/_OPT_DIR_ --with-ensurepip=install +#--enable-optimizations all: cd $(PY3_SRC) && \ diff --git a/src/bionic-2.7.16.sh b/src/bionic-2.7.16.sh index 6d8e0a5..d87634b 100644 --- a/src/bionic-2.7.16.sh +++ b/src/bionic-2.7.16.sh @@ -1,5 +1,6 @@ #!/bin/bash -eux +export EXTPYTHON_DIST=bionic export PYTHON_RELEASE=2.7.16 export PYTHON_MAJOR=2.7 export PYTHON_TARBALL="http://artifact.scc.net.davepedu.com/repo/tar/cpython/cpython/cpython-${PYTHON_RELEASE}.tar.gz" diff --git a/src/bionic-3.7.3.sh b/src/bionic-3.7.3.sh index ec5aa7e..cf75c4f 100644 --- a/src/bionic-3.7.3.sh +++ b/src/bionic-3.7.3.sh @@ -1,5 +1,7 @@ #!/bin/bash -eux +# Which dist to build on +export EXTPYTHON_DIST=bionic # Release is used to select which tarball to download export PYTHON_RELEASE=3.7.3 # Major version no is used in paths and labels (extpython-python${}, /opt/extpython/${}/...) diff --git a/src/bionic-3.8.0a4.sh b/src/bionic-3.8.0a4.sh index 8bf1d3a..8f8c232 100644 --- a/src/bionic-3.8.0a4.sh +++ b/src/bionic-3.8.0a4.sh @@ -1,5 +1,6 @@ #!/bin/bash -eux +export EXTPYTHON_DIST=bionic export PYTHON_RELEASE=3.8.0a4 export PYTHON_MAJOR=3.8 export PYTHON_TARBALL="http://artifact.scc.net.davepedu.com/repo/tar/cpython/cpython/cpython-${PYTHON_RELEASE}.tar.gz" diff --git a/src/disco-3.7.3.sh b/src/disco-3.7.3.sh new file mode 100644 index 0000000..811f3a6 --- /dev/null +++ b/src/disco-3.7.3.sh @@ -0,0 +1,8 @@ +#!/bin/bash -eux + +export EXTPYTHON_DIST=disco +export PYTHON_RELEASE=3.7.3 +export PYTHON_MAJOR=3.7 +export PYTHON_TARBALL="http://artifact.scc.net.davepedu.com/repo/tar/cpython/cpython/cpython-${PYTHON_RELEASE}.tar.gz" +export CPYTHON_DEPS="libssl-dev zlib1g-dev libncurses5-dev libncursesw5-dev \ + libreadline-dev libsqlite3-dev libgdbm-dev libdb5.3-dev libbz2-dev libexpat1-dev liblzma-dev tk-dev libffi-dev" diff --git a/src/trusty-3.7.3.sh b/src/trusty-3.7.3.sh new file mode 100644 index 0000000..4f27fef --- /dev/null +++ b/src/trusty-3.7.3.sh @@ -0,0 +1,12 @@ +#!/bin/bash -eux + +export EXTPYTHON_DIST=trusty +# Release is used to select which tarball to download +export PYTHON_RELEASE=3.7.3 +# Major version no is used in paths and labels (extpython-python${}, /opt/extpython/${}/...) +export PYTHON_MAJOR=3.7 +# Tarball download URL +export PYTHON_TARBALL="http://artifact.scc.net.davepedu.com/repo/tar/cpython/cpython/cpython-${PYTHON_RELEASE}.tar.gz" +# Deps needed to build this package +export CPYTHON_DEPS="libssl-dev zlib1g-dev libncurses5-dev libncursesw5-dev \ + libreadline-dev libsqlite3-dev libgdbm-dev libdb5.3-dev libbz2-dev libexpat1-dev liblzma-dev tk-dev libffi-dev"