2022-06-11 17:16:32 +02:00
|
|
|
#!/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
|
2022-06-12 09:47:16 +02:00
|
|
|
package=python$(echo ${version} | cut -d'.' -f1-2)
|
2022-06-12 00:31:11 +02:00
|
|
|
package_name=$package
|
2022-06-11 17:16:32 +02:00
|
|
|
|
|
|
|
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
|
2022-06-12 09:28:06 +02:00
|
|
|
prefix=usr/local
|
2022-06-11 17:16:32 +02:00
|
|
|
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
|
|
|
|
|
2022-06-12 09:44:13 +02:00
|
|
|
$build_dir/$deb_package/$prefix/bin/python${version:0:3} -m pip install --prefix /$prefix --root $build_dir/$deb_package --upgrade pip
|
|
|
|
$build_dir/$deb_package/$prefix/bin/python${version:0:3} -m pip install --prefix /$prefix --root $build_dir/$deb_package six toml
|
2022-06-11 17:16:32 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2022-06-12 00:31:11 +02:00
|
|
|
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
|
|
|
|
|
2022-06-12 01:25:48 +02:00
|
|
|
if [ $(aptly publish list -raw |wc -l) -gt 0 ]; then
|
2022-06-12 01:42:16 +02:00
|
|
|
sudo -u root aptly publish drop $(lsb_release -cs) debian
|
2022-06-12 01:25:48 +02:00
|
|
|
fi
|
2022-06-12 00:31:11 +02:00
|
|
|
|
2022-06-12 01:42:16 +02:00
|
|
|
sudo -u root aptly publish snapshot -distribution="$(lsb_release -cs)" $datetime-bashclub debian
|
2022-06-12 00:31:11 +02:00
|
|
|
|
|
|
|
/bin/systemctl restart aptly.service
|
2022-06-11 23:00:31 +02:00
|
|
|
|
|
|
|
echo "Build succeeded! You can find the .deb package at: /root/$deb_package.deb"
|
2022-06-11 17:16:32 +02:00
|
|
|
exit 0
|