2017-09-18 22:41:39 +02:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
readonly THISSCRIPT=$0
|
2021-02-05 02:18:01 +01:00
|
|
|
|
readonly DISTRIBS="buster bullseye"
|
2017-09-18 22:41:39 +02:00
|
|
|
|
readonly TIMETAG="$(date +%Y%m%d%H%M)"
|
|
|
|
|
readonly PACKAGES="moulinette SSOwat yunohost yunohost-admin"
|
2020-06-04 21:35:28 +02:00
|
|
|
|
readonly FORCE="false"
|
2020-05-14 19:14:25 +02:00
|
|
|
|
readonly LAST_BUILDS_CACHE="/var/cache/vinaigrette/last_builds/"
|
2017-09-18 22:41:39 +02:00
|
|
|
|
|
|
|
|
|
source /home/vinaigrette/config/config
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function main()
|
|
|
|
|
{
|
2020-05-14 19:14:25 +02:00
|
|
|
|
|
|
|
|
|
mkdir -p $LAST_BUILDS_CACHE
|
|
|
|
|
|
2019-01-30 19:50:30 +01:00
|
|
|
|
#if [[ "$(tty)" == "not a tty" ]]
|
|
|
|
|
#then
|
|
|
|
|
# echo "You aint in a tty (are you in a 'lxc exec' ?)"
|
|
|
|
|
# echo "The script can't run because pbuilder won't be happy :|"
|
|
|
|
|
# exit
|
|
|
|
|
#fi
|
2018-04-26 18:35:52 +02:00
|
|
|
|
|
2017-09-18 22:41:39 +02:00
|
|
|
|
for PACKAGE in $PACKAGES;
|
|
|
|
|
do
|
2020-02-07 23:24:00 +01:00
|
|
|
|
for DISTRIB in $DISTRIBS;
|
|
|
|
|
do
|
|
|
|
|
echo "-------------------------------------"
|
|
|
|
|
echo "Looking for update in ${PACKAGE} for ${DISTRIB}... "
|
2017-09-18 22:41:39 +02:00
|
|
|
|
|
2020-02-07 23:24:00 +01:00
|
|
|
|
build_if_needed $PACKAGE $DISTRIB
|
|
|
|
|
done
|
2017-09-18 22:41:39 +02:00
|
|
|
|
|
|
|
|
|
done
|
|
|
|
|
echo "-------------------------------------"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function build_if_needed()
|
|
|
|
|
{
|
|
|
|
|
local PACKAGE=$1
|
2020-02-07 23:24:00 +01:00
|
|
|
|
local DISTRIB=$2
|
2020-08-31 16:24:26 +02:00
|
|
|
|
local LAST_BUILD_FOR_THIS_PACKAGE=$LAST_BUILDS_CACHE/${DISTRIB}_${PACKAGE}
|
2017-09-18 22:41:39 +02:00
|
|
|
|
|
2022-01-19 23:22:30 +01:00
|
|
|
|
[[ $DISTRIB == "buster" ]] && BRANCH_NIGHTLY="buster"
|
|
|
|
|
[[ $DISTRIB == "bullseye" ]] && BRANCH_NIGHTLY="dev"
|
2021-02-05 02:18:01 +01:00
|
|
|
|
|
2017-09-18 22:41:39 +02:00
|
|
|
|
cd $GIT_REPOS/$PACKAGE
|
|
|
|
|
|
2020-05-14 19:14:25 +02:00
|
|
|
|
git fetch origin >/dev/null 2>/dev/null
|
2017-09-22 19:37:31 +02:00
|
|
|
|
|
2020-08-31 16:24:26 +02:00
|
|
|
|
git checkout $BRANCH_NIGHTLY >/dev/null 2>/dev/null
|
|
|
|
|
git pull origin $BRANCH_NIGHTLY >/dev/null 2>/dev/null
|
|
|
|
|
git reset --hard origin/$BRANCH_NIGHTLY
|
2020-05-14 19:14:25 +02:00
|
|
|
|
|
|
|
|
|
# Check if build is needed
|
|
|
|
|
|
|
|
|
|
if [ -e $LAST_BUILD_FOR_THIS_PACKAGE ]
|
|
|
|
|
then
|
|
|
|
|
TIMESTAMP_LASTBUILD=$(stat -c %Y $LAST_BUILD_FOR_THIS_PACKAGE)
|
|
|
|
|
else
|
|
|
|
|
TIMESTAMP_LASTBUILD=0
|
|
|
|
|
fi
|
|
|
|
|
TIMESTAMP_HEAD=$(git show -s --format=%ct HEAD)
|
|
|
|
|
|
|
|
|
|
if [ $TIMESTAMP_HEAD -lt $TIMESTAMP_LASTBUILD ]
|
|
|
|
|
then
|
2018-05-08 04:40:28 +02:00
|
|
|
|
if ! "$FORCE";
|
|
|
|
|
then
|
|
|
|
|
echo "Sources up-to-date, nothing to build."
|
|
|
|
|
return
|
|
|
|
|
else
|
|
|
|
|
echo "Sources up-to-date but forcing build anyway."
|
|
|
|
|
fi
|
2017-09-18 22:41:39 +02:00
|
|
|
|
fi
|
2017-09-22 19:37:31 +02:00
|
|
|
|
|
2017-09-18 22:41:39 +02:00
|
|
|
|
VERSION=$(dpkg-parsechangelog -S Version 2>/dev/null)
|
2018-04-28 22:10:51 +02:00
|
|
|
|
VERSION_NIGHTLY="${VERSION}+${TIMETAG}"
|
2017-09-18 22:41:39 +02:00
|
|
|
|
|
|
|
|
|
# Tweak the changelog temporarily
|
|
|
|
|
echo "> Setting version in changelog to ${VERSION_NIGHTLY}"
|
|
|
|
|
rm -f debian/changelog.dch
|
|
|
|
|
cp debian/changelog debian/changelog.old
|
|
|
|
|
dch --package "${PACKAGE}" \
|
|
|
|
|
--force-bad-version \
|
|
|
|
|
-v "${VERSION_NIGHTLY}" \
|
2020-08-31 16:24:26 +02:00
|
|
|
|
-D "unstable" \
|
2017-09-18 22:41:39 +02:00
|
|
|
|
--force-distribution \
|
2017-09-22 19:37:31 +02:00
|
|
|
|
"Daily build." \
|
2017-09-18 22:41:39 +02:00
|
|
|
|
> /dev/null 2>&1
|
|
|
|
|
|
2020-05-11 04:24:44 +02:00
|
|
|
|
head -n 5 debian/changelog
|
2017-09-18 22:41:39 +02:00
|
|
|
|
|
|
|
|
|
# Launch the build using build_deb script
|
|
|
|
|
build
|
|
|
|
|
|
2020-05-14 19:14:25 +02:00
|
|
|
|
touch $LAST_BUILD_FOR_THIS_PACKAGE
|
|
|
|
|
|
2017-09-18 22:41:39 +02:00
|
|
|
|
# Restore changelog
|
|
|
|
|
echo "> Restoring previous changelog"
|
|
|
|
|
cd $GIT_REPOS/$PACKAGE
|
|
|
|
|
cp debian/changelog.old debian/changelog
|
|
|
|
|
rm debian/changelog.old
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function build()
|
|
|
|
|
{
|
|
|
|
|
# Create temporary folder
|
|
|
|
|
TMP_FOLDER=$(mktemp -d)
|
|
|
|
|
|
|
|
|
|
# Move files to a tmp folder
|
|
|
|
|
echo "> Exporting in $TMP_FOLDER ... "
|
2017-09-22 19:37:31 +02:00
|
|
|
|
git ls-files | xargs tar -czf archive.tar.gz
|
2017-09-18 22:41:39 +02:00
|
|
|
|
cat archive.tar.gz | tar -xz -C $TMP_FOLDER
|
|
|
|
|
rm archive.tar.gz
|
|
|
|
|
|
|
|
|
|
# Build Debian package
|
|
|
|
|
echo "> Starting build ..."
|
|
|
|
|
cd $TMP_FOLDER
|
2020-08-31 16:24:26 +02:00
|
|
|
|
$BUILD_DEB $DISTRIB "unstable" .
|
2017-09-18 22:41:39 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
main
|