2022-12-03 15:48:42 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
QUIET_ARG=""
|
|
|
|
[ "$1" == "--quiet" ] && QUIET_ARG="--quiet"
|
|
|
|
|
|
|
|
# Enter source directory
|
|
|
|
cd $( dirname $0 )
|
|
|
|
|
|
|
|
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..."
|
|
|
|
BDIR=dist/check-esphome-devices-$VERSION
|
|
|
|
mkdir -p $BDIR
|
|
|
|
[ -z "$QUIET_ARG" ] && RSYNC_ARG="-v" || RSYNC_ARG=""
|
|
|
|
rsync -a $RSYNC_ARG debian/ $BDIR/debian/
|
|
|
|
cp check_esphome_devices $BDIR/
|
|
|
|
|
|
|
|
echo "Set VERSION=$VERSION in gitdch using sed..."
|
|
|
|
sed -i "s/^VERSION *=.*$/VERSION = '$VERSION'/" $BDIR/check_esphome_devices
|
|
|
|
|
|
|
|
if [ -z "$DEBIAN_CODENAME" ]
|
|
|
|
then
|
2024-03-13 18:36:27 +01:00
|
|
|
echo "Retrieve debian codename using lsb_release..."
|
2022-12-03 15:48:42 +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')
|
|
|
|
[ -n "$QUIET_ARG" ] && GITDCH_ARGS=('--warning')
|
|
|
|
if [ -n "$MAINTAINER_NAME" ]
|
|
|
|
then
|
|
|
|
echo "Use maintainer name from environment ($MAINTAINER_NAME)"
|
|
|
|
GITDCH_ARGS+=("--maintainer-name" "${MAINTAINER_NAME}")
|
|
|
|
fi
|
|
|
|
if [ -n "$MAINTAINER_EMAIL" ]
|
|
|
|
then
|
|
|
|
echo "Use maintainer email from environment ($MAINTAINER_EMAIL)"
|
|
|
|
GITDCH_ARGS+=("--maintainer-email" "$MAINTAINER_EMAIL")
|
|
|
|
fi
|
|
|
|
gitdch \
|
|
|
|
--package-name check-esphome-devices \
|
|
|
|
--version "${VERSION}" \
|
|
|
|
--code-name $DEBIAN_CODENAME \
|
|
|
|
--output $BDIR/debian/changelog \
|
|
|
|
--release-notes dist/release_notes.md \
|
|
|
|
"${GITDCH_ARGS[@]}"
|
|
|
|
|
|
|
|
if [ -n "$MAINTAINER_NAME" -a -n "$MAINTAINER_EMAIL" ]
|
|
|
|
then
|
|
|
|
echo "Set Maintainer field in debian control file ($MAINTAINER_NAME <$MAINTAINER_EMAIL>)..."
|
|
|
|
sed -i "s/^Maintainer: .*$/Maintainer: $MAINTAINER_NAME <$MAINTAINER_EMAIL>/" $BDIR/debian/control
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Build debian package..."
|
|
|
|
cd $BDIR
|
|
|
|
dpkg-buildpackage
|