diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 5e86928..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "cpython"] - path = cpython - url = https://github.com/python/cpython.git diff --git a/Dockerfile b/Dockerfile index 01a285a..e442f50 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,14 @@ FROM ubuntu:bionic 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 + 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 apt-get update && \ - apt-get install -y dpkg-dev debhelper && \ - useradd builder && \ - install -d /target -o builder -g builder +RUN useradd builder && \ + install -d /build -o builder -g builder -RUN DEBIAN_FRONTEND=noninteractive apt-get install -y 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 +ADD scripts/bootstrap.sh /bootstrap.sh +ADD scripts/build.sh /build.sh + +ENTRYPOINT ["/bootstrap.sh"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..6f29d30 --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +Deb builder for extpython + +Build process: + +- ./build.sh to kick off the process, runs a docker image - docker run -it --rm -v $PWD:/src ubuntu:bionic bash + - ./build-inner.sh called in the container, prepares the environment + - ./build-inner.sh switches to an underpriv'd user and calls... + - ./build-deb.sh - does the actual build + +TODO: +- parameterize the build: + - vars.sh needs to pass PYTHON_RELEASE down into the makefile + - debian metadata files need to obey this too: + - changelog: package name and version + - control: package name + - Makefile: a component of the --prefix path + +TODO later: +- upload resulting deb to artifact +- support other than Bionic +- separate process into creating the builder image & building the deb itself +- parameter for pre-loaded pip modules diff --git a/build-inner.sh b/build-inner.sh deleted file mode 100755 index aa08e59..0000000 --- a/build-inner.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -# export PATH=$PATH:/usr/bin - -time dpkg-buildpackage -us -uc -b - -ls -la ../ - -mkdir -p ./out - -mv ../*.buildinfo ../*.changes ../*.deb diff --git a/build.sh b/build.sh deleted file mode 100755 index a44e3cb..0000000 --- a/build.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -sudo docker run -it --rm --workdir=/target/src -v $PWD:/target/src extbuilder ./build-inner.sh diff --git a/cpython b/cpython deleted file mode 160000 index 1bf9cc5..0000000 --- a/cpython +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1bf9cc509326bc42cd8cb1650eb9bf64550d817e diff --git a/debian/changelog b/debian/changelog deleted file mode 100644 index 80df145..0000000 --- a/debian/changelog +++ /dev/null @@ -1,5 +0,0 @@ -extpython-python3.7 (3.7.0) unstable; urgency=low - - * Initial release - - -- Dave Pedu Wed, 17 OPct 2018 22:08:15 -0800 diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh new file mode 100755 index 0000000..306d107 --- /dev/null +++ b/scripts/bootstrap.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# get metadata +cd /src +. vars.sh + +# install deps +apt-get update +DEBIAN_FRONTEND=noninteractive apt-get install -y $CPYTHON_DEPS + +# run the build +sudo -Hu builder /build.sh + +# export the debs +OUTDIR="/src/out/$PYTHON_RELEASE/" +mkdir -p $OUTDIR +cp /build/out/* $OUTDIR diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 0000000..7f284f0 --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +. /src/vars.sh + +# create build dir +cd /build +mkdir work +cd work + +# get cpython source +mkdir cpython +wget -qO- cpython.tar.gz $PYTHON_TARBALL | tar zxf - -C cpython/ --strip-components=1 + +# get debian metadata +# todo generate the metadata here +cp -r /src/debian /src/Makefile ./ + +# build the deb +time dpkg-buildpackage -us -uc -b + +cd .. +mkdir out +mv *.buildinfo *.changes *.deb out/ +cd out +sha256sum * diff --git a/Makefile b/src/Makefile similarity index 67% rename from Makefile rename to src/Makefile index 3aedacd..6dd46cd 100644 --- a/Makefile +++ b/src/Makefile @@ -1,7 +1,7 @@ #!/usr/bin/make -f PY3_SRC=./cpython/ -PY3_CONFFLAGS=--prefix=$(DESTDIR)/opt/extpython/3.7.0 --with-ensurepip=install +PY3_CONFFLAGS=--prefix=$(DESTDIR)/opt/extpython/3.7 --with-ensurepip=install all: cd $(PY3_SRC) && \ @@ -11,7 +11,7 @@ all: install: cd $(PY3_SRC) && \ make install - # $(DESTDIR)/opt/extpython/3.7.0/bin/python3 $(DESTDIR)/opt/extpython/3.7.0/bin/pip3 install -r requirements.txt + # $(DESTDIR)/opt/extpython/3.7.0/bin/python3 $(DESTDIR)/opt/extpython/3.7/bin/pip3 install -r requirements.txt clean: cd $(PY3_SRC) && \ diff --git a/src/debian/changelog b/src/debian/changelog new file mode 100644 index 0000000..5465bf4 --- /dev/null +++ b/src/debian/changelog @@ -0,0 +1,5 @@ +extpython-python3.7 (3.7.3) unstable; urgency=low + + * Initial release + + -- Dave Pedu Thu, 30 May 2019 08:47:19 -0800 diff --git a/debian/compat b/src/debian/compat similarity index 100% rename from debian/compat rename to src/debian/compat diff --git a/debian/control b/src/debian/control similarity index 100% rename from debian/control rename to src/debian/control diff --git a/debian/rules b/src/debian/rules similarity index 100% rename from debian/rules rename to src/debian/rules diff --git a/src/vars.sh b/src/vars.sh new file mode 100644 index 0000000..7fe0696 --- /dev/null +++ b/src/vars.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +export PYTHON_RELEASE=3.7.3 +# export PYTHON_TARBALL="https://github.com/python/cpython/archive/v${PYTHON_RELEASE}.tar.gz" +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"