80 lines
2 KiB
Bash
Executable file
80 lines
2 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# Enter source directory
|
|
cd $( dirname $0 )
|
|
|
|
# Clean previous build
|
|
rm -fr dist deb_dist
|
|
|
|
# Set version in pyproject.toml
|
|
VERSION="$( git describe --tags )"
|
|
sed -i "s/^version *=.*$/version = '$VERSION'/" setup.py
|
|
|
|
if [ -d venv ]
|
|
then
|
|
VENV=$( realpath venv )
|
|
TEMP_VENV=0
|
|
else
|
|
# Install stdeb in temporary venv
|
|
VENV=$(mktemp -d)
|
|
echo "Create a temporary virtualenv in $VENV to install build dependencies..."
|
|
TEMP_VENV=1
|
|
python3 -m venv $VENV
|
|
$VENV/bin/python3 -m pip install stdeb GitPython wheel
|
|
fi
|
|
|
|
# Build wheel package
|
|
$VENV/bin/python3 setup.py bdist_wheel
|
|
|
|
# Check gitdch is installed
|
|
GITDCH=$(which gitdch)
|
|
set -e
|
|
if [ -z "$GITDCH" ]
|
|
then
|
|
TMP_GITDCH=$(mktemp -d)
|
|
echo "Temporary install gitdch in $TMP_GITDCH"
|
|
git clone https://gitea.zionetrix.net/bn8/gitdch.git $TMP_GITDCH/gitdch
|
|
GITDCH=$TMP_GITDCH/gitdch/gitdch
|
|
else
|
|
TMP_GITDCH=""
|
|
fi
|
|
|
|
# Build debian source package
|
|
$VENV/bin/python3 setup.py --command-packages=stdeb.command sdist_dsc \
|
|
--package3 "python3-mylib" \
|
|
--maintainer "Benjamin Renard <brenard@zionetrix.net>" \
|
|
--compat 10 \
|
|
--section net \
|
|
--forced-upstream-version "$VERSION"
|
|
|
|
# Keep only debian package directory and orig.tar.gz archive
|
|
find deb_dist/ -maxdepth 1 -type f ! -name '*.orig.tar.gz' -delete
|
|
|
|
# Enter in debian package directory
|
|
cd deb_dist/mylib-$VERSION
|
|
|
|
# Generate EE debian codename
|
|
DEBIAN_CODENAME=$( lsb_release -c -s )
|
|
[ $( lsb_release -r -s ) -ge 9 ] && DEBIAN_CODENAME="${DEBIAN_CODENAME}-ee"
|
|
|
|
# Generate debian changelog using generate_debian_changelog.py
|
|
$VENV/bin/python3 $GITDCH \
|
|
--package-name mylib \
|
|
--version "${VERSION}" \
|
|
--code-name $DEBIAN_CODENAME \
|
|
--output debian/changelog \
|
|
--path ../../ \
|
|
--verbose
|
|
|
|
# Add custom package name for dependencies
|
|
cat << EOF > debian/py3dist-overrides
|
|
cx_oracle python3-cx-oracle
|
|
EOF
|
|
|
|
[ $TEMP_VENV -eq 1 ] && rm -fr $VENV
|
|
|
|
# Clean temporary gitdch installation
|
|
[ -n "$TMP_GITDCH" ] && rm -fr $TMP_GITDCH
|
|
|
|
# Build debian package
|
|
dpkg-buildpackage --no-sign
|