2023-01-19 12:51:32 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
QUIET_ARG=""
|
2024-07-15 17:00:45 +02:00
|
|
|
[[ "$1" == "--quiet" ]] && QUIET_ARG="--quiet"
|
2023-01-19 12:51:32 +01:00
|
|
|
|
|
|
|
# Enter source directory
|
2024-07-15 17:00:45 +02:00
|
|
|
cd "$( dirname "$0" )" || exit
|
|
|
|
|
|
|
|
CHECK_FILE="$( find "." -name 'check_*' ! -name '*~' -type f -executable | head -n 1 )"
|
|
|
|
PACKAGE_NAME="$( basename "$CHECK_FILE" | tr '_' '-' )"
|
2023-01-19 12:51:32 +01:00
|
|
|
|
|
|
|
echo "Clean previous build..."
|
|
|
|
rm -fr dist
|
|
|
|
|
|
|
|
echo "Detect version using git describe..."
|
|
|
|
VERSION="$( git describe --tags|sed 's/^[^0-9]*//' )"
|
|
|
|
|
|
|
|
echo "Create building environemt..."
|
2024-07-15 17:00:45 +02:00
|
|
|
BDIR="dist/$PACKAGE_NAME-$VERSION"
|
|
|
|
mkdir -p "$BDIR"
|
|
|
|
RSYNC_ARG=""
|
|
|
|
[[ -z "$QUIET_ARG" ]] && RSYNC_ARG="-v"
|
|
|
|
rsync -a "$RSYNC_ARG" debian/ "$BDIR/debian/"
|
|
|
|
cp "$CHECK_FILE" "$BDIR/"
|
2023-01-19 12:51:32 +01:00
|
|
|
|
|
|
|
echo "Set VERSION=$VERSION in gitdch using sed..."
|
2024-07-15 17:00:45 +02:00
|
|
|
sed -i "s/^VERSION *=.*$/VERSION = '$VERSION'/" "$BDIR/$( basename "$CHECK_FILE" )"
|
2023-01-19 12:51:32 +01:00
|
|
|
|
2024-07-15 17:00:45 +02:00
|
|
|
if [[ -z "$DEBIAN_CODENAME" ]]; then
|
2024-01-22 01:49:05 +01:00
|
|
|
echo "Retrieve debian codename using lsb_release..."
|
2023-01-19 12:51:32 +01:00
|
|
|
DEBIAN_CODENAME=$( lsb_release -c -s )
|
|
|
|
else
|
|
|
|
echo "Use debian codename from environment ($DEBIAN_CODENAME)"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Generate debian changelog using gitdch..."
|
|
|
|
GITDCH_ARGS=('--verbose')
|
2024-07-15 17:00:45 +02:00
|
|
|
[[ -n "$QUIET_ARG" ]] && GITDCH_ARGS=('--warning')
|
|
|
|
if [[ -n "$MAINTAINER_NAME" ]]; then
|
2023-01-19 12:51:32 +01:00
|
|
|
echo "Use maintainer name from environment ($MAINTAINER_NAME)"
|
|
|
|
GITDCH_ARGS+=("--maintainer-name" "${MAINTAINER_NAME}")
|
|
|
|
fi
|
2024-07-15 17:00:45 +02:00
|
|
|
if [[ -n "$MAINTAINER_EMAIL" ]]; then
|
2023-01-19 12:51:32 +01:00
|
|
|
echo "Use maintainer email from environment ($MAINTAINER_EMAIL)"
|
|
|
|
GITDCH_ARGS+=("--maintainer-email" "$MAINTAINER_EMAIL")
|
|
|
|
fi
|
|
|
|
gitdch \
|
2024-07-15 17:00:45 +02:00
|
|
|
--package-name "$PACKAGE_NAME" \
|
2023-01-19 12:51:32 +01:00
|
|
|
--version "${VERSION}" \
|
2024-07-15 17:00:45 +02:00
|
|
|
--code-name "$DEBIAN_CODENAME" \
|
|
|
|
--output "$BDIR"/debian/changelog \
|
2023-01-19 12:51:32 +01:00
|
|
|
--release-notes dist/release_notes.md \
|
|
|
|
"${GITDCH_ARGS[@]}"
|
|
|
|
|
2024-07-15 17:00:45 +02:00
|
|
|
if [[ -n "$MAINTAINER_NAME" ]] && [[ -n "$MAINTAINER_EMAIL" ]]; then
|
2023-01-19 12:51:32 +01:00
|
|
|
echo "Set Maintainer field in debian control file ($MAINTAINER_NAME <$MAINTAINER_EMAIL>)..."
|
2024-07-15 17:00:45 +02:00
|
|
|
sed -i "s/^Maintainer: .*$/Maintainer: $MAINTAINER_NAME <$MAINTAINER_EMAIL>/" \
|
|
|
|
"$BDIR"/debian/control
|
2023-01-19 12:51:32 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Build debian package..."
|
2024-07-15 17:00:45 +02:00
|
|
|
cd "$BDIR" || exit
|
2023-01-19 12:51:32 +01:00
|
|
|
dpkg-buildpackage
|