mirror of
https://github.com/YunoHost/vinaigrette.git
synced 2024-09-03 20:06:11 +02:00
121 lines
2.9 KiB
Bash
Executable file
121 lines
2.9 KiB
Bash
Executable file
#!/bin/bash
|
||
|
||
readonly THISSCRIPT=$0
|
||
readonly PACKAGE=$1
|
||
readonly BRANCH=$2
|
||
readonly DISTRIB="bullseye"
|
||
#readonly DISTRIB="buster"
|
||
readonly DISTRIB_N="11"
|
||
|
||
source /home/vinaigrette/config/config
|
||
source /home/vinaigrette/scripts/common.sh
|
||
|
||
# ##### #
|
||
# Usage #
|
||
# ##### #
|
||
|
||
function usage()
|
||
{
|
||
cat << EOF
|
||
|
||
Usage:
|
||
$THISSCRIPT <project> <branch>
|
||
|
||
Arguments:
|
||
<project> metronome or other project name to be built
|
||
<branch> stable, testing or unstable
|
||
|
||
EOF
|
||
}
|
||
|
||
function main()
|
||
{
|
||
validate_arguments
|
||
cd $GIT_REPOS/$PACKAGE
|
||
tweak_$PACKAGE
|
||
build
|
||
}
|
||
|
||
# ################# #
|
||
# Check user inputs #
|
||
# ################# #
|
||
|
||
function validate_arguments()
|
||
{
|
||
[[ $PACKAGE =~ ^metronome|miniupnpc|gevent-websocket|python-zeroconf|lexicon$ ]] || critical "Invalid package $PACKAGE"
|
||
[[ $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 :|"
|
||
}
|
||
|
||
# ##################### #
|
||
# Build recipe / tweaks #
|
||
# ##################### #
|
||
|
||
function tweak_python-zeroconf()
|
||
{
|
||
readonly VERSION="$(dpkg-parsechangelog -S Version 2>/dev/null)+ynh$DISTRIB_N"
|
||
}
|
||
|
||
function tweak_lexicon()
|
||
{
|
||
readonly VERSION="$(dpkg-parsechangelog -S Version 2>/dev/null)+ynh$DISTRIB_N-1"
|
||
}
|
||
|
||
function tweak_miniupnpc()
|
||
{
|
||
readonly VERSION="$(dpkg-parsechangelog -S Version 2>/dev/null)+ynh$DISTRIB_N"
|
||
}
|
||
|
||
function tweak_gevent-websocket()
|
||
{
|
||
readonly VERSION="$(dpkg-parsechangelog -S Version 2>/dev/null)+ynh$DISTRIB_N"
|
||
}
|
||
|
||
function tweak_metronome()
|
||
{
|
||
readonly VERSION="$(dpkg-parsechangelog -S Version 2>/dev/null)+ynh$DISTRIB_N-1"
|
||
}
|
||
|
||
function build()
|
||
{
|
||
# SVERSION is VERSION without the -1 at the end ...
|
||
local SVERSION=$(echo $VERSION | tr '-' ' ' | awk '{print $1}')
|
||
|
||
cd $GIT_REPOS/$PACKAGE
|
||
|
||
# Tweak the changelog temporarily
|
||
info "Setting version in changelog to ${VERSION}"
|
||
rm -f debian/changelog.dch
|
||
cp debian/changelog debian/changelog.old
|
||
dch --package "${PACKAGE}" \
|
||
--force-bad-version \
|
||
-v "${VERSION}" \
|
||
-D "${BRANCH}" \
|
||
--force-distribution \
|
||
"YunoHost custom build." \
|
||
> /dev/null 2>&1
|
||
|
||
# Create temporary folder
|
||
TMP_FOLDER=$(mktemp -d)
|
||
|
||
# Extract git archive a desired tag
|
||
info "Exporting in $TMP_FOLDER ... "
|
||
git ls-files | xargs tar -czf archive.tar.gz
|
||
cat archive.tar.gz | tar -xz -C $TMP_FOLDER
|
||
# For some reason, these wants archive named
|
||
# 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
|
||
$BUILD_DEB $DISTRIB $BRANCH .
|
||
|
||
# Restore changelog
|
||
info "Restoring previous changelog"
|
||
cd $GIT_REPOS/$PACKAGE
|
||
cp debian/changelog.old debian/changelog
|
||
rm debian/changelog.old
|
||
}
|
||
|
||
[[ "$1" =~ ^-h|--help$ ]] && (usage; exit 0) || main
|