Skip to content

Commit 9a832e3

Browse files
committed
package-msi: fixed shellcheck issues
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
1 parent 6d07bfa commit 9a832e3

1 file changed

Lines changed: 31 additions & 31 deletions

File tree

build-scripts/package-msi

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh -x
22

3-
. $(dirname "$0")/functions
3+
. "$(dirname "$0")"/functions
44
. detect-environment
55
. compile-options
66
. version
@@ -50,70 +50,70 @@ fi
5050
CANDLE="wine $WIXPATH/candle.exe"
5151
LIGHT="wine $WIXPATH/light.exe"
5252

53-
if [ -z $JOB_NAME ]; then
53+
if [ -z "$JOB_NAME" ]; then
5454
DIRNAME=build-$VERSION-$ARCH
5555
else
56-
DIRNAME=$(echo ${JOB_NAME} | sed 's/\(.*\)\/.*/\1/g')
56+
DIRNAME=$(echo "${JOB_NAME}" | sed 's/\(.*\)\/.*/\1/g')
5757
fi
5858

5959
PKGD=$BASEDIR/packaging/cfengine-nova/pkg
6060
P=$PKGD/$DIRNAME
6161

6262
pre() {
63-
rm -rf $PKGD
64-
mkdir -p $P/bin
65-
mkdir -p $P/ssl
63+
rm -rf "$PKGD"
64+
mkdir -p "$P"/bin
65+
mkdir -p "$P"/ssl
6666

67-
cp -a $BUILDPREFIX/bin/* $P/bin
68-
cp -a $BUILDPREFIX/ssl/* $P/ssl
69-
cp -a $BASEDIR/cfengine/dist$BUILDPREFIX/bin/* $P/bin
67+
cp -a "$BUILDPREFIX"/bin/* "$P"/bin
68+
cp -a "$BUILDPREFIX"/ssl/* "$P"/ssl
69+
cp -a "$BASEDIR"/cfengine/dist"$BUILDPREFIX"/bin/* "$P"/bin
7070

7171
# TODO make not hard-coded paths for debian/ubuntu installations of mingw
7272
# I couldn't find an easy way to dynamically find the path to this dll so hard-coded
7373
# it is. :(
7474
case "$ARCH" in
7575
x86)
76-
cp -a /usr/i686-w64-mingw32/lib/libwinpthread-1.dll $P/bin/libwinpthread-1.dll
77-
cp -a $BASEDIR/enterprise/libcfenterprise/cf.events.i686.dll $P/bin/cf.events.dll
76+
cp -a /usr/i686-w64-mingw32/lib/libwinpthread-1.dll "$P"/bin/libwinpthread-1.dll
77+
cp -a "$BASEDIR"/enterprise/libcfenterprise/cf.events.i686.dll "$P"/bin/cf.events.dll
7878
;;
7979
x64)
80-
cp -a /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll $P/bin/libwinpthread-1.dll
81-
cp -a $BASEDIR/enterprise/libcfenterprise/cf.events.x86_64.dll $P/bin/cf.events.dll
80+
cp -a /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll "$P"/bin/libwinpthread-1.dll
81+
cp -a "$BASEDIR"/enterprise/libcfenterprise/cf.events.x86_64.dll "$P"/bin/cf.events.dll
8282
;;
8383
*)
8484
echo "Unknown architecture: $ARCH"
8585
exit 1
8686
;;
8787
esac
8888

89-
cp $BASEDIR/buildscripts/packaging/cfengine-nova/cfengine-nova.wxs $P
89+
cp "$BASEDIR"/buildscripts/packaging/cfengine-nova/cfengine-nova.wxs "$P"
9090
# OpenSSL libs have different names on x32 and x64 platforms:
9191
# on 32-bit platforms: libcrypto_1_1.dll and libssl_1_1.dll
9292
# on 64-bit platforms: libcrypto_1_1_x64.dll and libssl_1_1_x64.dll
9393
# So in cfengine-nova.wxs we have names for 64-bit platforms,
9494
# and on 32-bit platforms we remove the -x64 suffix.
9595
if [ "$ARCH" = "x86" ]; then
96-
sed -i '/lib\(crypto\|ssl\)/s/[_-]x64//g' $P/cfengine-nova.wxs
96+
sed -i '/lib\(crypto\|ssl\)/s/[_-]x64//g' "$P"/cfengine-nova.wxs
9797
fi
9898
}
9999

100100
candle() {
101101
REVISION="$1"
102-
$CANDLE -dCfSourceDir=. -dCfVersion=$REVISION -dCfArch=$ARCH cfengine-nova.wxs
102+
$CANDLE -dCfSourceDir=. -dCfVersion="$REVISION" -dCfArch="$ARCH" cfengine-nova.wxs
103103
}
104104

105105
light() {
106106
$LIGHT -sval -sice:ICE20 -ext WixUtilExtension cfengine-nova.wixobj
107107
}
108108

109109
package() {
110-
cd $P
110+
cd "$P"
111111

112-
if [ -z $EXPLICIT_VERSION ]; then
112+
if [ -z "$EXPLICIT_VERSION" ]; then
113113
# First make sure VERSION does not contain a 4th dot, since on windows we'll
114114
# add one later (plus they can only be numeric); so convert
115115
# 3.10.0a.abcdef to 3.10.0a.
116-
VERSION=$(echo $VERSION | sed -e 's/\([^.]*\.[^.]*\.[^.]*\).*/\1/')
116+
VERSION=$(echo "$VERSION" | sed -e 's/\([^.]*\.[^.]*\.[^.]*\).*/\1/')
117117

118118
case $BUILD_TYPE in
119119
RELEASE)
@@ -138,20 +138,20 @@ package() {
138138

139139
# convert any alphabets in revison to int as no alphabets are allowed in windows package version
140140
while true; do
141-
alphabet=$(echo $REVISION | sed -e 's/[^a-zA-Z]*\([a-zA-Z]*\).*/\1/')
141+
alphabet=$(echo "$REVISION" | sed -e 's/[^a-zA-Z]*\([a-zA-Z]*\).*/\1/')
142142
if [ -n "$alphabet" ]; then
143143
convert=$(printf '%d' "'$alphabet")
144-
REVISION=$(echo $REVISION | sed -e "s/$alphabet/$convert/")
144+
REVISION=$(echo "$REVISION" | sed -e "s/$alphabet/$convert/")
145145
else
146146
break
147147
fi
148148
done
149149

150150
# ensure all revision components are 4 digits max (MSI allows each part to be up to 65534, but we limit it to 9999)
151-
REVISION=$(echo $REVISION | tr '.' '\n' | sed 's/\(....\).*/\1/' | tr '\n' '.' | sed 's/\.$//')
151+
REVISION=$(echo "$REVISION" | tr '.' '\n' | sed 's/\(....\).*/\1/' | tr '\n' '.' | sed 's/\.$//')
152152

153153
# ensure revision has exactly 4 components - add .0.0.0 at the end and cut unneded parts
154-
REVISION=$(echo $REVISION.0.0.0 | cut -d '.' -f 1-4)
154+
REVISION=$(echo "$REVISION".0.0.0 | cut -d '.' -f 1-4)
155155

156156
# Wix tools have a ridiculously short maximum file length of 128 characters.
157157
# This is easily exceeded when Jenkins workspace paths are involved. Luckily
@@ -163,9 +163,9 @@ package() {
163163
# more likely to find free letters at the bottom end, so count backwards.
164164
WORKSPACE_DRIVE=
165165
for letter in y x w v u t s r q p o n m l k j i h g f e d; do
166-
if [ ! -e $HOME/.wine/dosdevices/$letter: ]; then
166+
if [ ! -e "$HOME"/.wine/dosdevices/$letter: ]; then
167167
WORKSPACE_DRIVE=$letter:
168-
ln -s $PWD $HOME/.wine/dosdevices/$WORKSPACE_DRIVE
168+
ln -s "$PWD" "$HOME"/.wine/dosdevices/$WORKSPACE_DRIVE
169169
break
170170
fi
171171
done
@@ -180,15 +180,15 @@ package() {
180180

181181
# Make sure the drive letter from above is cleaned up in case this build slave
182182
# is reused.
183-
rm -f $HOME/.wine/dosdevices/$WORKSPACE_DRIVE
183+
rm -f "$HOME"/.wine/dosdevices/$WORKSPACE_DRIVE
184184

185185
return $ret
186186
}
187187

188188
post() {
189-
mkdir -p $BASEDIR/cfengine-nova
190-
mv $P/cfengine-nova.msi $BASEDIR/cfengine-nova
191-
cd $BASEDIR/cfengine-nova
189+
mkdir -p "$BASEDIR"/cfengine-nova
190+
mv "$P"/cfengine-nova.msi "$BASEDIR"/cfengine-nova
191+
cd "$BASEDIR"/cfengine-nova
192192

193193
# For some reason candle is giving file no permissions at all.
194194
chmod 644 cfengine-nova.msi
@@ -204,10 +204,10 @@ post() {
204204

205205
case $ARCH in
206206
x86)
207-
mv cfengine-nova.msi $PKGNAME-i686.msi
207+
mv cfengine-nova.msi "$PKGNAME-i686.msi"
208208
;;
209209
x64)
210-
mv cfengine-nova.msi $PKGNAME-x86_64.msi
210+
mv cfengine-nova.msi "$PKGNAME-x86_64.msi"
211211
;;
212212
esac
213213
}

0 commit comments

Comments
 (0)