From 5173683c9137d43dbd4c15ab2c8226ec3b96938b Mon Sep 17 00:00:00 2001 From: Stuart Longland Date: Mon, 20 Jul 2020 08:54:45 +1000 Subject: [PATCH 1/2] build-deb.sh: Allow building source packages, pass options Allow end users to build source packages, sign packages with their own GnuPG key, and perform other interactions with `dpkg-buildpackage`. --- build-deb.sh | 52 +++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 7 deletions(-) diff --git a/build-deb.sh b/build-deb.sh index 77f3a6be..8d21c5e7 100755 --- a/build-deb.sh +++ b/build-deb.sh @@ -1,17 +1,38 @@ # ------------------------------------------------------------------------------ # Copyright (C) 2012, Robert Johansson , Raditex Control AB # All rights reserved. -# -# rSCADA +# +# rSCADA # http://www.rSCADA.se # info@raditex.nu -# +# # ------------------------------------------------------------------------------ +# Default settings +BUILD_BINARY=1 +BUILD_SOURCE=0 +SIGN_KEY= + +while [ $# -gt 0 ] && [ "$1" != "--" ]; do + case "$1" in + --build-source-pkg) + BUILD_SOURCE=1 + ;; + --skip-binary) + BUILD_BINARY=0 + ;; + --sign-key|-l) + SIGN_KEY=$2 + shift + ;; + esac + shift +done + if [ ! -f Makefile ]; then - # - # regenerate automake files - # + # + # regenerate automake files + # echo "Running autotools..." autoheader \ @@ -21,5 +42,22 @@ if [ ! -f Makefile ]; then && autoconf fi -debuild -i -us -uc -b +# Determine what build options to pass for source-only, +# binary-only and binary+source builds. +BUILD_OPTS= +if [ ${BUILD_SOURCE} = 1 ]; then + if [ ${BUILD_BINARY} = 0 ]; then + BUILD_OPTS=-S + fi +elif [ ${BUILD_BINARY} = 1 ]; then + BUILD_OPTS=-b +fi + +if [ -n "${SIGN_KEY}" ]; then + BUILD_OPTS="${BUILD_OPTS} -k ${SIGN_KEY}" +else + BUILD_OPTS="${BUILD_OPTS} -us -uc" +fi + +debuild -i ${BUILD_OPTS} "$@" #sudo pbuilder build $(NAME)_$(VERSION)-1.dsc From 2bf18df526002bea7cc5515da500256be6cfe0bb Mon Sep 17 00:00:00 2001 From: Stuart Longland Date: Tue, 21 Jul 2020 10:49:01 +1000 Subject: [PATCH 2/2] build-deb.sh: Add help, handle unknown arguments ``` RC=0 stuartl@rikishi ~/vrt/projects/metermaster/libs/libmbus $ ./build-deb.sh --foo --bar -mokey 7 --skip-binary --hello -- Usage: ./build-deb.sh [--build-source-pkg] [--skip-binary] [{--sign-key|-l} ] [-- ] Unrecognised argument --foo RC=1 stuartl@rikishi ~/vrt/projects/metermaster/libs/libmbus $ ./build-deb.sh -h Usage: ./build-deb.sh [--build-source-pkg] [--skip-binary] [{--sign-key|-l} ] [-- ] RC=0 stuartl@rikishi ~/vrt/projects/metermaster/libs/libmbus $ ./build-deb.sh -? Usage: ./build-deb.sh [--build-source-pkg] [--skip-binary] [{--sign-key|-l} ] [-- ] RC=0 stuartl@rikishi ~/vrt/projects/metermaster/libs/libmbus $ ./build-deb.sh --help Usage: ./build-deb.sh [--build-source-pkg] [--skip-binary] [{--sign-key|-l} ] [-- ] ``` --- build-deb.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/build-deb.sh b/build-deb.sh index 8d21c5e7..dd651a4b 100755 --- a/build-deb.sh +++ b/build-deb.sh @@ -25,6 +25,19 @@ while [ $# -gt 0 ] && [ "$1" != "--" ]; do SIGN_KEY=$2 shift ;; + *) + echo "Usage: $0 [--build-source-pkg] [--skip-binary]" + echo " [{--sign-key|-l} " + echo " [-- " + case "$1" in + "-h"|"-?"|--help) + exit 0 + ;; + *) + echo "Unrecognised argument ${1}" + exit 1 + ;; + esac esac shift done