diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2018-08-12 17:46:34 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2018-08-12 17:46:34 -0400 |
commit | c1d553388d7ef1ba387bc01747e7da23f6b7ccc6 (patch) | |
tree | 35545e296c27778ad0a84705146e0ddd431fb351 | |
download | docker-buildsys-vanilla-c1d553388d7ef1ba387bc01747e7da23f6b7ccc6.tar.gz |
Initial commit
-rw-r--r-- | Dockerfile | 41 | ||||
-rwxr-xr-x | build_mpdec.sh | 34 | ||||
-rwxr-xr-x | build_openssl.sh | 68 | ||||
-rwxr-xr-x | build_python.sh | 139 |
4 files changed, 282 insertions, 0 deletions
diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a2a2075 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,41 @@ +FROM centos:6 + +RUN yum install -y epel-release \ + && yum clean all + +RUN yum install -y \ + gcc \ + gcc-c++ \ + gfortran \ + glibc \ + perl \ + pkgconfig \ + expat-devel \ + bzip2-devel \ + gdbm-devel \ + libffi-devel \ + ncurses-devel \ + openssl-devel \ + readline-devel \ + sqlite-devel \ + tcl-devel \ + tk-devel \ + xz-devel \ + zlib-devel \ + && yum clean all + +COPY build_*.sh /usr/local/bin/ +ENV PATH="/opt/openssl/bin:${PATH}" +ENV MANPATH="/opt/openssl/share/man:${MANPATH}" +ENV PKG_CONFIG_PATH="/opt/openssl/lib/pkgconfig:${PKG_CONFIG_PATH}" + +WORKDIR /builder +RUN build_openssl.sh && rm -rf /builder/* +RUN build_mpdec.sh && rm -rf /builder/* +RUN build_python.sh 3.5.5 && rm -rf /builder/* +RUN build_python.sh 3.6.6 && rm -rf /builder/* +RUN build_python.sh 3.7.0 && rm -rf /builder/* +RUN rm -rf /builder && rm -rf /root/.cache/pip + +WORKDIR / + diff --git a/build_mpdec.sh b/build_mpdec.sh new file mode 100755 index 0000000..5bae0c2 --- /dev/null +++ b/build_mpdec.sh @@ -0,0 +1,34 @@ +#!/bin/bash +set -e +set -x + +tarball="mpdecimal-2.4.2.tar.gz" +dest="${tarball%%.tar.gz}" +url="http://www.bytereef.org/software/mpdecimal/releases/${tarball}" +prefix="/usr" + +function pre() +{ + curl -LO "${url}" + tar xf "${tarball}" +} + +function build() +{ + pre + pushd "${dest}" + export LDFLAGS="-Wl,-rpath=$prefix/lib" + ./configure --prefix=$prefix + make + make install + popd + post +} + +function post() +{ + echo "All done." +} + +# Main +build diff --git a/build_openssl.sh b/build_openssl.sh new file mode 100755 index 0000000..ab951f2 --- /dev/null +++ b/build_openssl.sh @@ -0,0 +1,68 @@ +#!/bin/bash +set -e +set -x +tarball="openssl-1.1.0h.tar.gz" +dest="${tarball%%.tar.gz}" +url="https://www.openssl.org/source/${tarball}" +prefix="/opt/openssl" + + +function pre() +{ + curl -LO "${url}" + tar xf "${tarball}" + export KERNEL_BITS=64 +} + + +function get_system_cacert() { + local paths=( + /etc/ssl/cert.pem + /etc/ssl/cacert.pem + /etc/ssl/certs/cacert.pem + /etc/ssl/certs/ca-bundle.crt + ) + for bundle in "${paths[@]}" + do + if [[ -f $bundle ]]; then + echo "$bundle" + break + fi + done +} + + +function build() +{ + pre + pushd "${dest}" + target="linux-x86_64" + export PATH="$prefix/bin:$PATH" + export LDFLAGS="-Wl,-rpath=$prefix/lib" + + ./Configure \ + --prefix="$prefix" \ + --openssldir="ssl" \ + --libdir="lib" \ + ${LDFLAGS} \ + ${target} \ + enable-ec_nistp_64_gcc_128 \ + zlib-dynamic \ + shared \ + no-ssl3-method + make + make install MANDIR="$prefix/share/man" MANSUFFIX=ssl + popd + post +} + +function post() +{ + bundle=$(get_system_cacert) + install -D -m644 "$bundle" "$prefix/ssl/cert.pem" + find $prefix + echo "All done." +} + +# Main +build diff --git a/build_python.sh b/build_python.sh new file mode 100755 index 0000000..4f302bf --- /dev/null +++ b/build_python.sh @@ -0,0 +1,139 @@ +#!/bin/bash +#https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.gz + +set -e +set -x + +python_version="$1" +python_basever="${python_version%.*}" + +if [[ ! ${python_version} || ! ${python_basever} ]]; then + echo "Need a python version..." + exit 1 +fi + +python_base_url="https://www.python.org/ftp/python" +python_tarball="Python-${python_version}.tgz" +python_source="${python_tarball%%.tgz}" +python_url="${python_base_url}/${python_version}/${python_tarball}" +prefix="/opt/${python_basever}" +openssl_root="/opt/openssl" + +dep_table=( + "bzlib.h libbz2.so" + "expat.h libexpat.so" + "ffi.h libffi.so" + "gdbm.h libgdbm.so" + "lzma.h liblzma.so" + "mpdecimal.h libmpdec.so" + "ncurses.h libncurses.so" + "nislib.h libnsl.so" + "readline.h libreadline.so" + "ssl.h libssl.so" + "sqlite3.h libsqlite3.so" + "tcl.h libtcl.so" + "tk.h libtk.so" + "zlib.h libz.so" +) + + +function depcheck() +{ + dep_count=0 + dep_total="${#dep_table[@]}" + + set +x + for _record in "${dep_table[@]}" + do + unset record + read -ra record <<< $_record + + header=$(find /usr/include $openssl_root /usr/lib{,64} -regex ".*\/${record[0]}" 2>/dev/null | head -n 1 || true) + if [[ -n $header ]]; then + dep_count=$((dep_count+1)) + else + echo "Missing header: ${record[0]}" + fi + lib=$(find $openssl_root /usr/lib{,64} -regex ".*\/${record[1]}" 2>/dev/null | head -n 1 || true) + if [[ -n "$lib" ]]; then + dep_count=$((dep_count+1)) + else + echo "Missing library: ${record[1]}" + fi + done + set -x + + if [[ ${dep_count} != $(( (dep_total * 2) )) ]]; then + echo 'Missing dependencies...' + exit 1 + fi +} + + +function pre() +{ + export PATH=$openssl_root/bin:$PATH + export PKG_CONFIG_PATH=$openssl_root/lib/pkgconfig:$PKG_CONFIG_PATH + export CFLAGS="-I$openssl_root/include" + export LDFLAGS="-L$openssl_root/lib -Wl,-rpath=$prefix/lib:$openssl_root/lib" + + depcheck + + if [[ ! -f ${python_tarball} ]]; then + curl -LO "${python_url}" + fi + + if [[ -d ${python_source} ]]; then + rm -rf "${python_source}" + fi + + tar xf "${python_tarball}" +} + + +function build() +{ + pre + pushd "${python_source}" + ./configure \ + --prefix="$prefix" \ + --enable-ipv6 \ + --enable-loadable-sqlite-extensions \ + --enable-profiling \ + --enable-shared \ + --with-dbmliborder=gdbm:ndbm \ + --with-openssl="$openssl_root" \ + --with-pymalloc \ + --with-system-expat \ + --with-system-ffi \ + --with-threads + make -j4 + make install + popd + post +} + + +function post() +{ + export PATH=$prefix/bin:$PATH + ln -sf python3 "${prefix}"/bin/python + ln -sf python3-config "${prefix}"/bin/python-config + ln -sf idle3 "${prefix}"/bin/idle + ln -sf pydoc3 "${prefix}"/bin/pydoc + ln -sf pip3 "${prefix}"/bin/pip + ln -sf python${python_basever}.1 "${prefix}"/share/man/man1/python.1 + + $prefix/bin/pip install --upgrade pip + $prefix/bin/pip install --upgrade setuptools + $prefix/bin/pip install wheel + + echo '---' + python --version + python -c "import sys; from pprint import pprint; pprint(sys.path)" + echo "All done." +} + + +# Main +build |