Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build-deb.sh: Allow building source packages, pass options #178

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
52 changes: 45 additions & 7 deletions build-deb.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,38 @@
# ------------------------------------------------------------------------------
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.

esac
shift
done

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

autoheader \
Expand All @@ -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