#!/bin/bash # 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/>. # set -e PIDPVERSION="1.5.2" for i in "${@:1}" do if [[ $i == -* ]] ; then case $i in -h*|--help*) HELP=YES ;; -e=*|--email=*) EMAIL="${i#*=}" ;; -f=*|--fullname=*) FULLNAME="${i#*=}" ;; -v=*|--srcversion=*) export SRCVERSION="${i#*=}" ;; -ne|--nodebenv) export NODEBENV=YES ;; -nb|--nonewbash) export NONEWBASH=YES ;; -nd|--nodhmake) export NODHMAKE=YES ;; -ns|--nosignature) export NOSIGNATURE=YES ;; -c|--continue) export CONTINUE=YES ;; -r=*|--release=*) export RELEASE="${i#*=}" ;; *) # unknown option ;; esac else if [[ -z $PACKAGE ]] || [[ ! -z $TARBALL ]] ; then export PACKAGE=$i else export TARBALL=$i fi fi done DEFRELEASE=jessie if [[ ! -z $HELP ]] && [[ -z $PACKAGE ]] ; then echo "Error: PACKAGE variable is not defined" fi if [[ ! -z $HELP ]] && [[ -z $TARBALL ]] ; then echo "Error: TARBALL variable is not defined" fi if [[ ! -z $HELP ]] || [[ -z $PACKAGE ]] || [[ -z $TARBALL ]] ; then echo "pidpbuild version $PIDPVERSION" echo "" echo "usage: pidpcreate <DEB-PACKAGE-NAME> <TARBALL> [-v=<SRCVERSION>] [-ns|--no-signature]" echo " [-e=<DEBEMAIL>] [-f=<DEBFULLNAME>] [-ne|--nodebenv]" echo " [-c|--continue] [-h|--help]" echo "" echo "create a new gbp package repository" echo "" echo "possible arguments:" echo " DEB-PACKAGE-NAME debian package name (mandatory)" echo " TARBALL source tarball, i.e. *.tar.gz (optional)" echo "" echo "optional arguments:" echo " -h, --help show this help message and exit" echo " -v=, --srcversion= the tarball source version, i.e. 1.1.2" echo " -ns, --nosiganture don't sign the package" echo " -ne, --nodebenv don't set default DEBFULLNAME and DEBEMAIL" echo " -nb, --nonewbash don't open a new bash in the package directory" echo " -nd, --nodhmake don't use dhmake" 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. stretch, jessie, wheezy" echo "" echo "examples:" echo " pidpcreate python-nxstools-extras-p09 ../nexdatas.extrasp09-1.2.4.tar.gz" echo " pidpcreate python-nxstools-extras-p09 ../nexdatas.extrasp09.tar.gz -v=1.3.2" echo " pidpcreate --continue" echo "" else if [ -z $NODEBENV ] ; then if [[ -z $DEBEMAIL ]] ; then export DEBEMAIL="fsec-devel@desy.de" fi if [[ -z $DEBFULLNAME ]] ; then export DEBFULLNAME="FS-EC DESY Group" fi fi if [[ ! -z $FULLNAME ]] ; then export DEBFULLNAME=$FULLNAME fi if [[ ! -z $EMAIL ]] ; then export DEBEMAIL=$EMAIL fi if [[ -z $RELEASE ]] ; then export RELEASE=$DEFRELEASE fi echo "" echo " PACKAGE=\"$PACKAGE\"" echo " TARBALL=\"$TARBALL\"" echo "" echo " DEBFULLNAME=\"$DEBFULLNAME\"" echo " DEBEMAIL=\"$DEBEMAIL\"" echo "" mkdir $PACKAGE cd $PACKAGE git init . git config core.autocrlf false git checkout --orphan upstream/$RELEASE git commit --allow-empty -m "Initial upstream branch." git branch debian/$RELEASE git checkout -f debian/$RELEASE if [[ -z $SRCVERSION ]] ; then TB=${TARBALL::-7} VER=${TB##*-} SRCVERSION=${VER##*_} fi echo "" echo " SRCVERSION=\"$SRCVERSION\"" echo "" if ! [[ $TARBALL == /* ]] ; then TARBALL=../$TARBALL fi gbp import-orig --pristine-tar --debian-branch=debian/$RELEASE \ --upstream-branch=upstream/$RELEASE -u $SRCVERSION \ --upstream-tag=upstream/$RELEASE/$SRCVERSION $TARBALL <<< $"$PACKAGE" if [[ -z $NODHMAKE ]] ; then dh_make -p ${PACKAGE}_${SRCVERSION} fi echo "[DEFAULT]" > debian/gbp.conf echo "debian-branch = debian/$RELEASE" >> debian/gbp.conf echo "upstream-branch = upstream/$RELEASE" >> debian/gbp.conf echo "debian-tag = debian/$RELEASE/%(version)s" >> debian/gbp.conf echo "upstream-tag = upstream/$RELEASE/%(version)s" >> debian/gbp.conf echo "" >> debian/gbp.conf echo "[buildpackage]" >> debian/gbp.conf echo "git-debian-branch = debian/$RELEASE" >> debian/gbp.conf echo "git-debian-tag = debian/$RELEASE/%(version)s" >> debian/gbp.conf echo "git-upstream-tag = upstream/$RELEASE/%(version)s" >> debian/gbp.conf echo "" >> debian/gbp.conf echo "[import-orig]" >> debian/gbp.conf echo "pristine-tar = True" >> debian/gbp.conf git add debian/gbp.conf git commit debian/gbp.conf -m "add configuration of gbp" export PIDTOKILL=$$ echo "" echo "To continue:" echo "1) Edit the debian/ configuration" echo "2) Commit your changes" echo "3) Execute \"pidpbuild --continue\"" echo "" echo "" echo "To push changes into STASH repository:" echo "4) Create a new stash repository with its name: \"${PACKAGE}\"" echo " at https://stash.desy.de/projects/PIDP" echo "5) Execute \"pidppush ${PACKAGE}\"" echo "4) Set debian/$RELEASE as a default branch" echo " at https://stash.desy.de/projects/PIDP/${PACKAGE}/settings" echo "" if [[ -z $NONEWBASH ]] ; then exec bash fi fi