Skip to content

Commit a2aa5a2

Browse files
committed
bootstrap-tarballs: Fixed shellcheck issues
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
1 parent 62c8820 commit a2aa5a2

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

build-scripts/bootstrap-tarballs

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ _dir=$(readlink -e "$(dirname "$0")")
44
# refactored a few functions into single file scripts for easier development/debugging, see ENT-12741 and ENT-12595
55
# Easier to add a path to a script than source a file of functions.
66
export PATH="$_dir"/bin:$PATH
7-
. `dirname "$0"`/functions
7+
. "$(dirname "$0")"/functions
88
. detect-environment
99
. compile-options
1010
. version
1111

12-
mkdir -p $BASEDIR/output/tarballs
12+
mkdir -p "$BASEDIR"/output/tarballs
1313

1414
# the first part of the script is not really critical
1515
set +e
@@ -33,105 +33,105 @@ for repo_spec in cfengine/buildscripts cfengine/core cfengine/masterfiles cfengi
3333

3434
# Convert to uppercase, swap hyphens with underscore and append '_REV'
3535
# E.g. 'mission-portal' -> 'MISSION_PORTAL_REV'
36-
rev_param_name="$(echo $repo | tr '[:lower:]-' '[:upper:]_')_REV"
36+
rev_param_name="$(echo "$repo" | tr '[:lower:]-' '[:upper:]_')_REV"
3737

3838
# Try to dereference the result from above and skip the rest of the loop
3939
# unless the variable is defined.
40-
revision="$(echo ${!rev_param_name})" || continue # dereference
40+
revision="${!rev_param_name}" || continue
4141

4242
# remove "origin/" (if any)
4343
revision="${revision##origin/}"
4444

4545
# Check to see if the resolved variable starts with 'pull/'
4646
if expr "$revision" : "pull/" >/dev/null; then
4747
# Extract the revision number. E.g. 'pull/1755' -> '1755'
48-
pr_nr="$(echo $revision | cut -d/ -f2)"
48+
pr_nr="$(echo "$revision" | cut -d/ -f2)"
4949

50-
get-github-pull-request-info "$repo_spec" "$pr_nr" >> $BASEDIR/output/PRs
50+
get-github-pull-request-info "$repo_spec" "$pr_nr" >> "$BASEDIR"/output/PRs
5151
fi
5252
done
5353

5454
# now script failures should fail the script
5555
set -e
5656

5757
# Build tarball from core repository
58-
cd $BASEDIR/core
58+
cd "$BASEDIR"/core
5959
rm cfengine-3.*.tar.gz || true
60-
git rev-parse HEAD > $BASEDIR/output/core-commitID
60+
git rev-parse HEAD > "$BASEDIR"/output/core-commitID
6161
# Configure in order to run "make dist", deleted later.
6262
./configure -C
6363
make dist
64-
mv cfengine-3.*.tar.gz $BASEDIR/output/tarballs/
64+
mv cfengine-3.*.tar.gz "$BASEDIR"/output/tarballs/
6565
make distclean
6666

6767
# Build tarballs from masterfiles repository
68-
cd $BASEDIR/masterfiles
68+
cd "$BASEDIR"/masterfiles
6969
rm cfengine-masterfiles*.tar.gz || true
70-
git rev-parse HEAD > $BASEDIR/output/masterfiles-commitID
70+
git rev-parse HEAD > "$BASEDIR"/output/masterfiles-commitID
7171
# Configure in order to run "make dist", deleted later.
7272
./configure
7373
make dist # source tarball
7474
make tar-package # package tarball (containing all files as if they were
7575
# installed under "prefix".)
76-
mv cfengine-masterfiles*.tar.gz $BASEDIR/output/tarballs/
76+
mv cfengine-masterfiles*.tar.gz "$BASEDIR"/output/tarballs/
7777
make distclean
7878

7979
# Compute a checksum list that can be used to verify the integrity of the
8080
# tarballs
81-
cd $BASEDIR/output/tarballs
82-
sha256sum *.tar.gz > sha256sums.txt
81+
cd "$BASEDIR"/output/tarballs
82+
sha256sum -- *.tar.gz > sha256sums.txt
8383
# Add the BSD (16-bit) checksum of the checksum list to it's filename. This way
8484
# you can verify the integrity of the checksum list itself.
85-
CKSUM=`sum sha256sums.txt | cut -d ' ' -f 1`
86-
mv sha256sums.txt sha256sums.$CKSUM.txt
85+
CKSUM=$(sum sha256sums.txt | cut -d ' ' -f 1)
86+
mv sha256sums.txt sha256sums."$CKSUM".txt
8787

8888
# Install javascript dependencies
8989
(
90-
if test -f "$BASEDIR/mission-portal/public/scripts/package.json"; then
91-
cd $BASEDIR/mission-portal/public/scripts
90+
if test -f "$BASEDIR"/mission-portal/public/scripts/package.json; then
91+
cd "$BASEDIR"/mission-portal/public/scripts
9292
# display node & npm versions
9393
npm --version
9494
node --version
9595
# install dependencies from npmjs
96-
npm ci --prefix $BASEDIR/mission-portal/public/scripts/
96+
npm ci --prefix "$BASEDIR"/mission-portal/public/scripts/
9797
# build react components
98-
npm run build --prefix $BASEDIR/mission-portal/public/scripts/
98+
npm run build --prefix "$BASEDIR"/mission-portal/public/scripts/
9999
# remove the packages specified in devDependencies
100-
npm prune --omit=dev --prefix $BASEDIR/mission-portal/public/scripts/
100+
npm prune --omit=dev --prefix "$BASEDIR"/mission-portal/public/scripts/
101101

102102
fi
103103
)
104104

105105
# Install PHP dependencies from the mission-portal repository
106106
(
107-
if test -f "$BASEDIR/mission-portal/composer.json"; then
108-
cd $BASEDIR/mission-portal
107+
if test -f "$BASEDIR"/mission-portal/composer.json; then
108+
cd "$BASEDIR"/mission-portal
109109
# install PHP dependencies from composer
110110
php /usr/bin/composer.phar install --no-dev
111111
fi
112112
)
113113

114114
# Install PHP dependencies from the nova repository
115115
(
116-
if test -f "$BASEDIR/nova/api/http/composer.json"; then
117-
cd $BASEDIR/nova/api/http
116+
if test -f "$BASEDIR"/nova/api/http/composer.json; then
117+
cd "$BASEDIR"/nova/api/http
118118
# install PHP dependencies from composer
119119
php /usr/bin/composer.phar install --no-dev --ignore-platform-reqs
120120
fi
121121
)
122122

123123
# Compile Mission Portal styles
124124
(
125-
if test -f "$BASEDIR/mission-portal/public/themes/default/bootstrap/cfengine_theme.less"; then
126-
cd $BASEDIR/mission-portal/public/themes/default/bootstrap
125+
if test -f "$BASEDIR"/mission-portal/public/themes/default/bootstrap/cfengine_theme.less; then
126+
cd "$BASEDIR"/mission-portal/public/themes/default/bootstrap
127127
npx -p less lessc --compress ./cfengine_theme.less ./compiled/css/cfengine.less.css
128128
fi
129129
)
130130

131131
# Install LDAP API dependencies
132132
(
133-
if test -f "$BASEDIR/mission-portal/ldap/composer.json"; then
134-
cd $BASEDIR/mission-portal/ldap
133+
if test -f "$BASEDIR"/mission-portal/ldap/composer.json; then
134+
cd "$BASEDIR"/mission-portal/ldap
135135
# install PHP dependencies from composer
136136
php /usr/bin/composer.phar install --no-dev
137137
fi

0 commit comments

Comments
 (0)