Newer
Older
# This file is part of nexdatas - Tango Server for NeXus data writer
#
# Copyright (C) 2017-2017 DESY, Jan Kotanski <jkotan@mail.desy.de>
#
# nexdatas is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# nexdatas is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with nexdatas. If not, see <http://www.gnu.org/licenses/>.
#
for i in "${@:1}"
do
if [[ $i == -* ]] ; then
case $i in
HELP=YES
;;
-e=*|--email=*)
EMAIL="${i#*=}"
;;
-f=*|--fullname=*)
FULLNAME="${i#*=}"
;;
-u=*|--user=*)
export USER="${i#*=}"
;;
-r=*|--release=*)
export RELEASE="${i#*=}"
;;
-ne|--nodebenv)
export NODEBENV=YES
;;
-p|--patch)
export PATCH=YES
;;
*)
# unknown option
;;
esac
else
export PACKAGE=$1
fi
done
DEFRELEASE=jessie
if [[ ! -z $HELP ]] && [[ -z $PACKAGE ]] ; then
echo "Error: PACKAGE variable is not defined"
fi
if [[ ! -z $HELP ]] || [[ -z $PACKAGE ]] ; then
echo "usage: pidpclone <DEB-PACKAGE-NAME> [-p|--patch] [-u=<USER>] [-h|--help]"
echo " [-e=<DEBEMAIL>] [-f=<DEBFULLNAME>] [-ne|--nodebenv] "
echo ""
echo "clone the gbp package repository from stash into the local directory"
echo "and start the patching procedure if the --patch option is given"
echo "(see also pidpbuild)"
echo ""
echo "possible arguments:"
echo " DEB-PACKAGE-NAME debian package name (mandatory)"
echo ""
echo "optional arguments:"
echo " -h, --help show this help message and exit"
echo " -p, --patch start the patching procedure"
echo " -u=, --user= stash user name"
echo " (default: the local user name)"
echo " -ne, --nodebenv don't set default DEBFULLNAME and DEBEMAIL"
echo " -nb, --nonewbash don't open a new bash in the package directory"
echo " -f=, --fullname= debian fullname of the gpg signature,"
echo " i.e. DEBFULLNAME"
echo " -e=, --email= debian email of the gpg signature,"
echo " i.e. DEBEMAIL"
echo " -r=, --release= debian release flavour, e.g. jessie, wheezy"
echo ""
echo "examples:"
echo " pidpclone python-nxstools-extras-p09 --patch"
echo " pidpclone python-nxstools-extras-p06"
echo ""
else
if [ -z $NODEBENV ] ; then
if [[ -z $DEBEMAIL ]] ; then
export DEBEMAIL="fsec-devel@desy.de"
fi
fi
if [[ ! -z $FULLNAME ]] ; then
export DEBFULLNAME=$FULLNAME
fi
if [[ ! -z $EMAIL ]] ; then
export DEBEMAIL=$EMAIL
fi
echo ""
echo " DEBFULLNAME=\"$DEBFULLNAME\""
echo " DEBEMAIL=\"$DEBEMAIL\""
echo ""
if [ -z $USER ] ; then
export USER=$(whoami)
fi
if [ -z $RELEASE ] ; then
export RELEASE=$DEFRELEASE
fi
if ! [[ -d $PACKAGE ]]; then
git clone https://$USER@stash.desy.de/scm/pidp/$PACKAGE.git
fi
if [[ $(git checkout -b upstream/$RELEASE origin/upstream/$RELEASE > /dev/null 2>&1) && $? ]]; then
git checkout upstream/$RELEASE
git pull origin upstream/$RELEASE || true
if [[ $(git checkout -b pristine-tar origin/pristine-tar > /dev/null 2>&1) && $? ]]; then
git checkout pristine-tar
git pull origin pristine-tar || true
fi
if [[ $(git checkout -b debian/$RELEASE origin/debian/$RELEASE > /dev/null 2>&1) && $? ]]; then
git pull origin debian/$RELEASE || true
else
git checkout debian/$RELEASE
git pull origin debian/$RELEASE || true
fi
git clean -f -d
git commit -a -m 'clean the repository' > /dev/null 2>&1 || true
export PIDTOKILL=$$
if [ -z $PATCH ] ; then
echo ""
echo "1) Edit the debian/ configuration"
echo "2) Commit your changes"
else
gbp pq import
export IMPORT=YES
export PIDTOKILL=$$
echo ""
echo "1) Edit the source files"
echo "2) Commit your changes"
if [[ -z $NONEWBASH ]] ; then
exec bash
fi