commit 01e8ace8ff244a716557be58c354fa33ac130bf7 Author: Thorsten Spille Date: Sat Jun 11 17:16:32 2022 +0200 First commit, full project diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a5b7ae4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +src/* +build/* \ No newline at end of file diff --git a/builder b/builder new file mode 100755 index 0000000..d8f23bf --- /dev/null +++ b/builder @@ -0,0 +1,82 @@ +#!/bin/bash +set -euo pipefail + +PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin" + +prog='$(basename "$0")' + +source environment + +version=$1 +package=python3 +package_name=package + +echo "$(date) setting global vars..." +libc6_version=$( dpkg -s libc6 | grep Version | cut -d':' -f2 | cut -d' ' -f2 | cut -d'-' -f1) +dpkg_arch=$(dpkg --print-architecture) +deb_package=${package}_${version}_${dpkg_arch} +src_dir=$PWD/src +build_dir=$PWD/build +prefix=usr +my_dir=$PWD + +echo "$(date) installing dependencies..." +sudo DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt -y -qq install build-essential dpkg-dev $dpkg_depends +sudo ldconfig + +echo "$(date) seting download url" +download=$dl_prefix/$version/$dl_name-$version.$dl_suffix +echo "download_url=$download" + +echo "$(date) creating build directories..." +mkdir -p $src_dir +mkdir -p $build_dir +mkdir -p $build_dir/$deb_package/DEBIAN + +echo "$(date) downloading and extracting source code..." +cd $src_dir +wget $download +tar -xvf $dl_name-$version.$dl_suffix +rm $dl_name-$version.$dl_suffix +cd $dl_name-$version + +echo "$(date) configuring project..." +./$configure_sript --prefix=/$prefix $configure_extra_params + +echo "$(date) compiling project..." +make -j$(nproc) + +echo "$(date) testing build if activated..." +if [ $make_test -gt 0 ]; then + make test +fi + +echo "$(date) installing build to target directory..." +make DESTDIR=$build_dir/$deb_package $install_param + +cd $my_dir + +$build_dir/$deb_package/$prefix/bin/python3 -m pip install --prefix /$prefix --root $build_dir/$deb_package --upgrade pip +$build_dir/$deb_package/$prefix/bin/python3 -m pip install --prefix /$prefix --root $build_dir/$deb_package six toml + +cd $build_dir + +echo "$(date) creating DEBIBAN/control..." +cat << EOF > $deb_package/DEBIAN/control +Package: $package_name +Version: $version +Architecture: $dpkg_arch +Essential: no +Priority: optional +Depends: libc6 (>= $libc6_version) +Maintainer: bashclub +Description: The deb package for $package_name $version maintained from bashclub.org. +EOF + +echo "$(date) building deb package..." +dpkg-deb --build $deb_package +rm -r $src_dir/$dl_name-$version +rm -r $build_dir/$deb_package + +echo "Build succeeded! You can find the .deb package at: $build_dir/$deb_package.deb" +exit 0 diff --git a/environment b/environment new file mode 100644 index 0000000..b39c278 --- /dev/null +++ b/environment @@ -0,0 +1,9 @@ +package_name=Python3 +configure_sript=configure +dl_prefix=https://www.python.org/ftp/python +dl_name=Python +dl_suffix=tgz +dpkg_depends="zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget" +configure_extra_params="--enable-optimizations" +make_test=1 +install_param="install" diff --git a/run b/run new file mode 100755 index 0000000..501355c --- /dev/null +++ b/run @@ -0,0 +1,11 @@ +#!/bin/bash +set -euo pipefail + +PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin" + +source environment +source version +for ver in ${versions[@]}; do + VERSION=$(wget -q -O - $dl_prefix/ | grep -o "$ver.[0-9]" | tail -1) + ./builder $VERSION +done \ No newline at end of file diff --git a/version b/version new file mode 100644 index 0000000..59e533c --- /dev/null +++ b/version @@ -0,0 +1 @@ +versions=(3.8 3.9 3.10) \ No newline at end of file