vinaigrette/ynh-build
2017-08-31 15:14:12 +02:00

102 lines
1.9 KiB
Bash
Executable file
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
source /home/vinaigrette/config/config
# ##### #
# Usage #
# ##### #
usage() {
cat << EOF
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)
EOF
}
if [[ $1 == "-h" ]]; then
usage
exit 0
fi
# ################# #
# Check user inputs #
# ################# #
PROJECT=$1
BRANCH=$2
DISTRIB=$3
VERSION=$4
## Project
if [[ ! $PROJECT =~ ^yunohost|yunohost-admin|moulinette|SSOwat$ ]]; then
echo "Invalid project $PROJECT"
usage
exit 1
fi
## Branch
if [[ ! $BRANCH =~ ^testing|stable$ ]]; then
echo "Invalid branch $BRANCH"
usage
exit 2
fi
# Distribution
if [[ ! $DISTRIB =~ ^jessie|stretch$ ]]; then
echo "Invalid distribution $DISTRIB"
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 .