2017-08-29 17:17:25 +02:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
2017-08-30 05:51:28 +02:00
|
|
|
|
source /home/vinaigrette/config/config
|
2017-08-29 17:17:25 +02:00
|
|
|
|
|
|
|
|
|
# ##### #
|
|
|
|
|
# Usage #
|
|
|
|
|
# ##### #
|
|
|
|
|
|
|
|
|
|
usage() {
|
2017-08-31 15:14:12 +02:00
|
|
|
|
cat << EOF
|
2017-08-29 17:17:25 +02:00
|
|
|
|
Usage:
|
|
|
|
|
`basename $0` <project> <branch> <version>
|
|
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
|
<project> moulinette, yunohost, yunohost-admin or SSOwat
|
|
|
|
|
<branch> testing or stable
|
|
|
|
|
<distrib> jessie or stretch
|
|
|
|
|
<version> x.y.z (ex: 2.6.1)
|
2017-08-31 15:14:12 +02:00
|
|
|
|
EOF
|
2017-08-29 17:17:25 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if [[ $1 == "-h" ]]; then
|
|
|
|
|
usage
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# ################# #
|
|
|
|
|
# Check user inputs #
|
|
|
|
|
# ################# #
|
|
|
|
|
|
2017-08-31 15:14:12 +02:00
|
|
|
|
PROJECT=$1
|
|
|
|
|
BRANCH=$2
|
|
|
|
|
DISTRIB=$3
|
|
|
|
|
VERSION=$4
|
|
|
|
|
|
2017-08-29 17:17:25 +02:00
|
|
|
|
## Project
|
2017-08-31 15:14:12 +02:00
|
|
|
|
if [[ ! $PROJECT =~ ^yunohost|yunohost-admin|moulinette|SSOwat$ ]]; then
|
|
|
|
|
echo "Invalid project $PROJECT"
|
2017-08-29 17:17:25 +02:00
|
|
|
|
usage
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
## Branch
|
2017-08-31 15:14:12 +02:00
|
|
|
|
if [[ ! $BRANCH =~ ^testing|stable$ ]]; then
|
|
|
|
|
echo "Invalid branch $BRANCH"
|
2017-08-29 17:17:25 +02:00
|
|
|
|
usage
|
|
|
|
|
exit 2
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Distribution
|
2017-08-31 15:14:12 +02:00
|
|
|
|
if [[ ! $DISTRIB =~ ^jessie|stretch$ ]]; then
|
|
|
|
|
echo "Invalid distribution $DISTRIB"
|
2017-08-29 17:17:25 +02:00
|
|
|
|
usage
|
|
|
|
|
exit 3
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Version
|
|
|
|
|
if [ -z "$VERSION" ]; then
|
|
|
|
|
echo "Invalid version $VERSION"
|
|
|
|
|
usage
|
|
|
|
|
exit 4
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Sum up configuration
|
|
|
|
|
echo "## #################################################### ##"
|
|
|
|
|
echo "## Building $PROJECT $BRANCH release - $VERSION version"
|
|
|
|
|
echo "## #################################################### ##"
|
|
|
|
|
|
|
|
|
|
# Update project's repository
|
|
|
|
|
echo ""
|
|
|
|
|
echo "## Updating $GIT_REPOS/$PROJECT repository ..."
|
|
|
|
|
cd $GIT_REPOS/$PROJECT
|
|
|
|
|
git fetch --quiet
|
|
|
|
|
git fetch --tags --quiet
|
|
|
|
|
git checkout $BRANCH --quiet
|
|
|
|
|
git pull origin $BRANCH --quiet
|
|
|
|
|
|
|
|
|
|
# Check if tag really exists
|
|
|
|
|
if git rev-parse "debian/$VERSION" >/dev/null 2>&1; then
|
|
|
|
|
TAG="debian/$VERSION"
|
|
|
|
|
else
|
|
|
|
|
echo "Invalid version $VERSION (there's no debian/$VERSION tag in the git repo !)"
|
|
|
|
|
usage
|
|
|
|
|
exit
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Create temporary folder
|
|
|
|
|
TMP_FOLDER=$(mktemp -d)
|
|
|
|
|
|
|
|
|
|
# Extract git archive a desired tag
|
|
|
|
|
echo ""
|
|
|
|
|
echo "## Exporting in $TMP_FOLDER ..."
|
|
|
|
|
git archive $TAG --format=tar | tar -x -C $TMP_FOLDER
|
|
|
|
|
|
|
|
|
|
# Build Debian package
|
|
|
|
|
echo ""
|
|
|
|
|
echo "## Building Debian package ..."
|
|
|
|
|
echo ""
|
|
|
|
|
cd $TMP_FOLDER
|
|
|
|
|
$BUILD_DEB -d $BRANCH -c $DISTRIB .
|
|
|
|
|
|