85 lines
2.3 KiB
Bash
Executable file
85 lines
2.3 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
QUIET_ARG=""
|
|
[ "$1" == "--quiet" ] && QUIET_ARG="--quiet"
|
|
|
|
# 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
|
|
VENV=$(mktemp -d)
|
|
echo "Create a temporary virtualenv in $VENV to install build dependencies..."
|
|
TEMP_VENV=1
|
|
python3 -m venv $VENV
|
|
fi
|
|
|
|
echo "Install dependencies in virtualenv using pip..."
|
|
$VENV/bin/python3 -m pip install stdeb GitPython wheel $QUIET_ARG
|
|
|
|
echo "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 $QUIET_ARG https://gitea.zionetrix.net/bn8/gitdch.git $TMP_GITDCH/gitdch
|
|
GITDCH=$TMP_GITDCH/gitdch/gitdch
|
|
else
|
|
TMP_GITDCH=""
|
|
fi
|
|
|
|
echo "Build debian source package using stdeb sdist_dsc command..."
|
|
$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"
|
|
|
|
echo "Keep only debian package directory and orig.tar.gz archive..."
|
|
find deb_dist/ -maxdepth 1 -type f ! -name '*.orig.tar.gz' -delete
|
|
|
|
echo "Enter in debian package directory..."
|
|
cd deb_dist/mylib-$VERSION
|
|
|
|
echo "Generate EE debian codename..."
|
|
DEBIAN_CODENAME=$( lsb_release -c -s )
|
|
[ $( lsb_release -r -s ) -ge 9 ] && DEBIAN_CODENAME="${DEBIAN_CODENAME}-ee"
|
|
|
|
echo "Generate debian changelog using gitdch..."
|
|
GITDCH_LOG_ARG='--verbose'
|
|
[ -n "$QUIET_ARG" ] && GITDCH_LOG_ARG='--warning'
|
|
$VENV/bin/python3 $GITDCH \
|
|
--package-name mylib \
|
|
--version "${VERSION}" \
|
|
--code-name $DEBIAN_CODENAME \
|
|
--output debian/changelog \
|
|
--path ../../ \
|
|
$GITDCH_LOG_ARG
|
|
|
|
echo "Add custom package name for dependencies..."
|
|
cat << EOF > debian/py3dist-overrides
|
|
cx_oracle python3-cx-oracle
|
|
EOF
|
|
|
|
[ $TEMP_VENV -eq 1 ] && echo "Clean temporary virtualenv..." && rm -fr $VENV
|
|
|
|
[ -n "$TMP_GITDCH" ] && echo "Clean temporary gitdch installation..." && rm -fr $TMP_GITDCH
|
|
|
|
echo "Build debian package..."
|
|
dpkg-buildpackage --no-sign
|