#!/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=python$(echo ${version} | cut -d'.' -f1-2) 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/local 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 datetime=$(/bin/date "+%Y-%m-%d-%H%M") for del in $(aptly repo search bashclub | grep $package_name | grep ${dpkg_arch}); do aptly repo remove bashclub $package_name done aptly repo add bashclub $build_dir/$deb_package.deb aptly snapshot create $datetime-bashclub from repo bashclub if [ $(aptly publish list -raw |wc -l) -gt 0 ]; then sudo -u root aptly publish drop $(lsb_release -cs) debian fi sudo -u root aptly publish snapshot -distribution="$(lsb_release -cs)" $datetime-bashclub debian /bin/systemctl restart aptly.service echo "Build succeeded! You can find the .deb package at: /root/$deb_package.deb" exit 0