2017-09-19 00:32:03 +02:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
readonly THISSCRIPT=$0
|
2018-07-01 00:59:14 +02:00
|
|
|
|
readonly PACKAGE=$1
|
|
|
|
|
readonly BRANCH=$2
|
2021-02-05 02:18:01 +01:00
|
|
|
|
readonly DISTRIB="bullseye"
|
|
|
|
|
#readonly DISTRIB="buster"
|
|
|
|
|
readonly DISTRIB_N="11"
|
2017-09-19 00:32:03 +02:00
|
|
|
|
|
|
|
|
|
source /home/vinaigrette/config/config
|
2018-07-01 00:59:14 +02:00
|
|
|
|
source /home/vinaigrette/scripts/common.sh
|
2017-09-19 00:32:03 +02:00
|
|
|
|
|
2018-07-01 00:59:14 +02:00
|
|
|
|
# ##### #
|
|
|
|
|
# Usage #
|
|
|
|
|
# ##### #
|
2017-09-19 00:32:03 +02:00
|
|
|
|
|
2018-07-01 00:59:14 +02:00
|
|
|
|
function usage()
|
2017-09-19 00:32:03 +02:00
|
|
|
|
{
|
2018-07-01 00:59:14 +02:00
|
|
|
|
cat << EOF
|
2018-05-03 02:03:29 +02:00
|
|
|
|
|
2018-07-01 00:59:14 +02:00
|
|
|
|
Usage:
|
2021-01-27 23:03:13 +01:00
|
|
|
|
$THISSCRIPT <project> <branch>
|
2018-05-03 02:03:29 +02:00
|
|
|
|
|
2018-07-01 00:59:14 +02:00
|
|
|
|
Arguments:
|
2020-02-08 03:08:22 +01:00
|
|
|
|
<project> metronome or other project name to be built
|
2018-07-01 00:59:14 +02:00
|
|
|
|
<branch> stable, testing or unstable
|
2017-09-19 00:32:03 +02:00
|
|
|
|
|
2018-07-01 00:59:14 +02:00
|
|
|
|
EOF
|
2017-09-19 00:32:03 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-01 00:59:14 +02:00
|
|
|
|
function main()
|
2018-05-03 02:03:29 +02:00
|
|
|
|
{
|
2018-07-01 00:59:14 +02:00
|
|
|
|
validate_arguments
|
|
|
|
|
cd $GIT_REPOS/$PACKAGE
|
|
|
|
|
tweak_$PACKAGE
|
|
|
|
|
build
|
|
|
|
|
}
|
2018-05-03 02:03:29 +02:00
|
|
|
|
|
2018-07-01 00:59:14 +02:00
|
|
|
|
# ################# #
|
|
|
|
|
# Check user inputs #
|
|
|
|
|
# ################# #
|
2018-05-03 02:03:29 +02:00
|
|
|
|
|
2018-07-01 00:59:14 +02:00
|
|
|
|
function validate_arguments()
|
|
|
|
|
{
|
2022-01-05 18:17:20 +01:00
|
|
|
|
[[ $PACKAGE =~ ^metronome|miniupnpc|gevent-websocket|python-zeroconf|lexicon$ ]] || critical "Invalid package $PACKAGE"
|
2018-07-01 00:59:14 +02:00
|
|
|
|
[[ $BRANCH =~ ^testing|stable|unstable$ ]] || critical "Invalid branch $BRANCH"
|
|
|
|
|
[[ "$(tty)" != "not a tty" ]] || critical "You aint in a tty (are you in a 'lxc exec' ?) The script can't run because pbuilder won't be happy :|"
|
|
|
|
|
}
|
2018-05-03 02:03:29 +02:00
|
|
|
|
|
2018-07-01 00:59:14 +02:00
|
|
|
|
# ##################### #
|
|
|
|
|
# Build recipe / tweaks #
|
|
|
|
|
# ##################### #
|
2018-05-03 02:03:29 +02:00
|
|
|
|
|
2021-08-19 19:48:03 +02:00
|
|
|
|
function tweak_python-zeroconf()
|
|
|
|
|
{
|
|
|
|
|
readonly VERSION="$(dpkg-parsechangelog -S Version 2>/dev/null)+ynh$DISTRIB_N"
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-05 18:17:20 +01:00
|
|
|
|
function tweak_lexicon()
|
|
|
|
|
{
|
|
|
|
|
readonly VERSION="$(dpkg-parsechangelog -S Version 2>/dev/null)+ynh$DISTRIB_N-1"
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-12 18:57:37 +01:00
|
|
|
|
function tweak_miniupnpc()
|
|
|
|
|
{
|
2021-01-27 23:03:13 +01:00
|
|
|
|
readonly VERSION="$(dpkg-parsechangelog -S Version 2>/dev/null)+ynh$DISTRIB_N"
|
2020-02-12 18:57:37 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-01-27 23:03:13 +01:00
|
|
|
|
function tweak_gevent-websocket()
|
|
|
|
|
{
|
|
|
|
|
readonly VERSION="$(dpkg-parsechangelog -S Version 2>/dev/null)+ynh$DISTRIB_N"
|
|
|
|
|
}
|
2020-02-12 18:57:37 +01:00
|
|
|
|
|
2018-07-01 00:59:14 +02:00
|
|
|
|
function tweak_metronome()
|
|
|
|
|
{
|
2022-01-05 18:17:20 +01:00
|
|
|
|
readonly VERSION="$(dpkg-parsechangelog -S Version 2>/dev/null)+ynh$DISTRIB_N-1"
|
2018-05-03 02:03:29 +02:00
|
|
|
|
}
|
2017-09-19 00:32:03 +02:00
|
|
|
|
|
|
|
|
|
function build()
|
|
|
|
|
{
|
|
|
|
|
# SVERSION is VERSION without the -1 at the end ...
|
|
|
|
|
local SVERSION=$(echo $VERSION | tr '-' ' ' | awk '{print $1}')
|
2018-05-03 02:03:29 +02:00
|
|
|
|
|
2017-09-19 00:32:03 +02:00
|
|
|
|
cd $GIT_REPOS/$PACKAGE
|
|
|
|
|
|
|
|
|
|
# Tweak the changelog temporarily
|
2018-07-01 00:59:14 +02:00
|
|
|
|
info "Setting version in changelog to ${VERSION}"
|
2017-09-19 00:32:03 +02:00
|
|
|
|
rm -f debian/changelog.dch
|
|
|
|
|
cp debian/changelog debian/changelog.old
|
|
|
|
|
dch --package "${PACKAGE}" \
|
|
|
|
|
--force-bad-version \
|
|
|
|
|
-v "${VERSION}" \
|
2018-07-01 00:59:14 +02:00
|
|
|
|
-D "${BRANCH}" \
|
2017-09-19 00:32:03 +02:00
|
|
|
|
--force-distribution \
|
2018-07-01 00:59:14 +02:00
|
|
|
|
"YunoHost custom build." \
|
2017-09-19 00:32:03 +02:00
|
|
|
|
> /dev/null 2>&1
|
|
|
|
|
|
|
|
|
|
# Create temporary folder
|
|
|
|
|
TMP_FOLDER=$(mktemp -d)
|
|
|
|
|
|
|
|
|
|
# Extract git archive a desired tag
|
2018-07-01 00:59:14 +02:00
|
|
|
|
info "Exporting in $TMP_FOLDER ... "
|
2018-05-03 02:03:29 +02:00
|
|
|
|
git ls-files | xargs tar -czf archive.tar.gz
|
2017-09-19 00:32:03 +02:00
|
|
|
|
cat archive.tar.gz | tar -xz -C $TMP_FOLDER
|
2018-05-03 02:03:29 +02:00
|
|
|
|
# For some reason, these wants archive named
|
2017-09-19 00:32:03 +02:00
|
|
|
|
# e.g. metronome_x.y.z+stuff.orig.tar.gz
|
|
|
|
|
# in the parent folder...
|
|
|
|
|
mv archive.tar.gz $TMP_FOLDER/../${PACKAGE}_${SVERSION}.orig.tar.gz
|
|
|
|
|
|
|
|
|
|
# Build Debian package
|
|
|
|
|
cd $TMP_FOLDER
|
2018-05-03 02:33:47 +02:00
|
|
|
|
$BUILD_DEB $DISTRIB $BRANCH .
|
2017-09-19 00:32:03 +02:00
|
|
|
|
|
2018-05-03 02:33:47 +02:00
|
|
|
|
# Restore changelog
|
2018-07-01 00:59:14 +02:00
|
|
|
|
info "Restoring previous changelog"
|
2017-09-19 00:32:03 +02:00
|
|
|
|
cd $GIT_REPOS/$PACKAGE
|
|
|
|
|
cp debian/changelog.old debian/changelog
|
|
|
|
|
rm debian/changelog.old
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-01 00:59:14 +02:00
|
|
|
|
[[ "$1" =~ ^-h|--help$ ]] && (usage; exit 0) || main
|