Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 58 additions & 7 deletions build-deb.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,51 @@
# ------------------------------------------------------------------------------
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran shell check on this script and got this output:

$ shellcheck build-deb.sh

In build-deb.sh line 1:
# ------------------------------------------------------------------------------
^-- SC2148: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.


In build-deb.sh line 62:
debuild -i ${BUILD_OPTS} "$@"
           ^-----------^ SC2086: Double quote to prevent globbing and word splitting.

Did you mean:
debuild -i "${BUILD_OPTS}" "$@"

For more information:
  https://www.shellcheck.net/wiki/SC2148 -- Tips depend on target shell and y...
  https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ...

Personally, I belive that the current line 62 is correct, it may conatin several comman line options.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think double-quoting that will do more harm than good. I see what they're getting at but in this case we want the arguments in the variable to be split apart and interpreted separately.

# Copyright (C) 2012, Robert Johansson <[email protected]>, Raditex Control AB
# All rights reserved.
#
# rSCADA
#
# rSCADA
# http://www.rSCADA.se
# [email protected]
#
#
# ------------------------------------------------------------------------------

# 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
;;
Comment on lines +17 to +27
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block (lines 17-27) would accept misspelled and random flags.

./build-deb --foo --bar -mokey 7 --skip-binary --hello --

No online help/usage.

*)
echo "Usage: $0 [--build-source-pkg] [--skip-binary]"
echo " [{--sign-key|-l} <GPG KEY ID>"
echo " [-- <dpkg-buildpackage options>"
case "$1" in
"-h"|"-?"|--help)
exit 0
;;
*)
echo "Unrecognised argument ${1}"
exit 1
;;
esac
esac
shift
done

if [ ! -f Makefile ]; then
#
# regenerate automake files
#
#
# regenerate automake files
#
echo "Running autotools..."

autoheader \
Expand All @@ -21,5 +55,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