Skip to content

Commit 12ce7fe

Browse files
authored
Merge pull request #1964 from larsewi/gniggol
Replaced echo's with logging functions
2 parents 7a66d1b + 46ad17e commit 12ce7fe

File tree

6 files changed

+59
-60
lines changed

6 files changed

+59
-60
lines changed

build-scripts/autogen

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ nova)
3232
;;
3333
*)
3434
if [ -z "${PROJECT}" ]; then
35-
echo "$(basename "$0"): Error: Expected environment variable PROJECT=[community|nova]"
35+
log_error "Expected environment variable PROJECT=[community|nova]"
3636
else
37-
echo "$(basename "$0"): Error: Unknown project '$PROJECT', expected 'community' or 'nova'"
37+
log_error "Unknown project '$PROJECT', expected 'community' or 'nova'"
3838
fi
3939
echo "Usage: PROJECT=[community|nova] $0"
4040
exit 42
@@ -51,15 +51,14 @@ fi
5151
# running the autogen.sh.
5252
for proj in $projects; do
5353
if [ ! -d "$BASEDIR/$proj" ]; then
54-
echo "$(basename "$0"): Error: Expected to find the '$proj' repository in '$BASEDIR', but it's not there"
55-
exit 1
54+
fatal "Expected to find the '$proj' repository in '$BASEDIR', but it's not there"
5655
fi
5756
done
5857

5958
# Run autogen.sh on each repository
6059
for proj in $projects; do
6160
# autogen.sh is quite verbose, so only print the output in case of failure
62-
echo "$(basename "$0"): Debug: Running autogen.sh for project $proj..."
61+
log_debug "Running autogen.sh for project $proj..."
6362
(
6463
cd "$BASEDIR/$proj"
6564
NO_CONFIGURE=1 run_and_print_on_failure ./autogen.sh

build-scripts/bootstrap-tarballs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,27 +94,27 @@ cd "$BASEDIR"/core
9494
rm -f cfengine-3.*.tar.gz
9595
git rev-parse HEAD >"$BASEDIR"/output/core-commitID
9696
# Configure in order to run "make dist", deleted later.
97-
echo "$(basename "$0"): Debug: Running configure on core repository..."
97+
log_debug "Running configure on core repository..."
9898
run_and_print_on_failure ./configure -C
99-
echo "$(basename "$0"): Debug: Running make dist on core repository..."
99+
log_debug "Running make dist on core repository..."
100100
run_and_print_on_failure make dist
101101
mv cfengine-3.*.tar.gz "$BASEDIR"/output/tarballs/
102-
echo "$(basename "$0"): Debug: Running make distclean on core repository..."
102+
log_debug "Running make distclean on core repository..."
103103
run_and_print_on_failure make distclean
104104

105105
# Build tarballs from masterfiles repository
106106
cd "$BASEDIR"/masterfiles
107107
rm -f cfengine-masterfiles*.tar.gz
108108
git rev-parse HEAD >"$BASEDIR"/output/masterfiles-commitID
109109
# Configure in order to run "make dist", deleted later.
110-
echo "$(basename "$0"): Debug: Running configure on masterfiles repository..."
110+
log_debug "Running configure on masterfiles repository..."
111111
run_and_print_on_failure ./configure
112-
echo "$(basename "$0"): Debug: Running make dist on masterfiles repository..."
112+
log_debug "Running make dist on masterfiles repository..."
113113
run_and_print_on_failure make dist # source tarball
114-
echo "$(basename "$0"): Debug: Running make tar-package on masterfiles repository..."
114+
log_debug "Running make tar-package on masterfiles repository..."
115115
run_and_print_on_failure make tar-package # package tarball (containing all files as if they were installed under "prefix".)
116116
mv cfengine-masterfiles*.tar.gz "$BASEDIR"/output/tarballs/
117-
echo "$(basename "$0"): Debug: Running make distclean on masterfiles repository..."
117+
log_debug "Running make distclean on masterfiles repository..."
118118
run_and_print_on_failure make distclean
119119

120120
# Compute a checksum list that can be used to verify the integrity of the
@@ -126,7 +126,7 @@ sha256sum -- *.tar.gz >sha256sums.txt
126126
CKSUM=$(sum sha256sums.txt | cut -d ' ' -f 1)
127127
mv sha256sums.txt sha256sums."$CKSUM".txt
128128

129-
echo "$(basename "$0"): Debug: Installing javascript npm dependencies..."
129+
log_debug "Installing javascript npm dependencies..."
130130
(
131131
if test -f "$BASEDIR"/mission-portal/public/scripts/package.json; then
132132
cd "$BASEDIR"/mission-portal/public/scripts
@@ -142,7 +142,7 @@ echo "$(basename "$0"): Debug: Installing javascript npm dependencies..."
142142
fi
143143
)
144144

145-
echo "$(basename "$0"): Debug: Installing PHP composer dependencies from mission-portal repository..."
145+
log_debug "Installing PHP composer dependencies from mission-portal repository..."
146146
(
147147
if test -f "$BASEDIR"/mission-portal/composer.json; then
148148
cd "$BASEDIR"/mission-portal
@@ -151,7 +151,7 @@ echo "$(basename "$0"): Debug: Installing PHP composer dependencies from mission
151151
fi
152152
)
153153

154-
echo "$(basename "$0"): Debug: Installing PHP composer dependencies from nova repository..."
154+
log_debug "Installing PHP composer dependencies from nova repository..."
155155
(
156156
if test -f "$BASEDIR"/nova/api/http/composer.json; then
157157
cd "$BASEDIR"/nova/api/http
@@ -160,15 +160,15 @@ echo "$(basename "$0"): Debug: Installing PHP composer dependencies from nova re
160160
fi
161161
)
162162

163-
echo "$(basename "$0"): Debug: Compiling Mission Portal styles..."
163+
log_debug "Compiling Mission Portal styles..."
164164
(
165165
if test -f "$BASEDIR"/mission-portal/public/themes/default/bootstrap/cfengine_theme.less; then
166166
cd "$BASEDIR"/mission-portal/public/themes/default/bootstrap
167167
run_and_print_on_failure npx -p less lessc --compress ./cfengine_theme.less ./compiled/css/cfengine.less.css
168168
fi
169169
)
170170

171-
echo "$(basename "$0"): Debug: Installing LDAP API PHP composer dependencies..."
171+
log_debug "Installing LDAP API PHP composer dependencies..."
172172
(
173173
if test -f "$BASEDIR"/mission-portal/ldap/composer.json; then
174174
cd "$BASEDIR"/mission-portal/ldap

build-scripts/clean-buildmachine

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
uninstall_cfbuild
1313

1414
if [ -z "$PREFIX" ] || [ "$PREFIX" = "/" ]; then
15-
echo "$(basename "$0"): Error: \$PREFIX is not defined, is empty, or is set to the root directory. Aborting to prevent accidental deletion."
16-
exit 1
15+
fatal "\$PREFIX is not defined, is empty, or is set to the root directory. Aborting to prevent accidental deletion."
1716
fi
1817

19-
echo "$(basename "$0"): Debug: Cleaning build host by deleting $PREFIX"
18+
log_debug "Cleaning build host by deleting $PREFIX"
2019
case $OS in
2120
aix)
2221
sudo rm -rf "$PREFIX"/*

build-scripts/compare-versions

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ nova)
3232
;;
3333
*)
3434
if [ -z "${PROJECT}" ]; then
35-
echo "$(basename "$0"): Error: Expected environment variable PROJECT=[community|nova]"
35+
log_error "Expected environment variable PROJECT=[community|nova]"
3636
else
37-
echo "$(basename "$0"): Error: Unknown project '$PROJECT', expected 'community' or 'nova'"
37+
log_error "Unknown project '$PROJECT', expected 'community' or 'nova'"
3838
fi
3939
echo "Usage: PROJECT=[community|nova] $0"
4040
exit 42
@@ -59,7 +59,7 @@ for proj_i in $projects; do
5959
version_j=$(<"$BASEDIR/$proj_j/CFVERSION" tr ' ' '\n' |
6060
sed -e 's/\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/')
6161
if [ "$version_i" != "$version_j" ]; then
62-
echo "$(basename "$0"): Error: Detected version mismatch: $proj_i $version_i != $proj_j $version_j"
62+
log_error "Detected version mismatch: $proj_i $version_i != $proj_j $version_j"
6363
exit 33
6464
fi
6565
done

build-scripts/compile

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,30 +28,30 @@ nova)
2828
NOVA=yes
2929
;;
3030
*)
31-
echo "$(basename "$0"): Error: Unknown project '$PROJECT'"
31+
log_error "Unknown project '$PROJECT'"
3232
exit 42
3333
;;
3434
esac
3535

36-
echo "$(basename "$0"): Debug: Running make in core repo..."
36+
log_debug "Running make in core repo..."
3737
run_and_print_on_failure "$MAKE" -C "$BASEDIR"/core -k
38-
echo "$(basename "$0"): Debug: Running make install in core repo..."
38+
log_debug "Running make install in core repo..."
3939
run_and_print_on_failure "$MAKE" -C "$BASEDIR"/core install DESTDIR="$BASEDIR"/cfengine/dist
4040

4141
if [ "$NOVA" = yes ]; then
42-
echo "$(basename "$0"): Debug: Running make in enterprise repo..."
42+
log_debug "Running make in enterprise repo..."
4343
run_and_print_on_failure "$MAKE" -C "$BASEDIR"/enterprise -k
44-
echo "$(basename "$0"): Debug: Running make install in enterprise repo..."
44+
log_debug "Running make install in enterprise repo..."
4545
run_and_print_on_failure "$MAKE" -C "$BASEDIR"/enterprise install DESTDIR="$BASEDIR"/cfengine/dist
4646
if [ "$ROLE" = hub ]; then
47-
echo "$(basename "$0"): Debug: Running make in nova repo..."
47+
log_debug "Running make in nova repo..."
4848
run_and_print_on_failure "$MAKE" -C "$BASEDIR"/nova -k
49-
echo "$(basename "$0"): Debug: Running make install in nova repo..."
49+
log_debug "Running make install in nova repo..."
5050
run_and_print_on_failure "$MAKE" -C "$BASEDIR"/nova install DESTDIR="$BASEDIR"/cfengine/dist
51-
echo "$(basename "$0"): Debug: Running make install in masterfiles repo..."
51+
log_debug "Running make install in masterfiles repo..."
5252
run_and_print_on_failure "$MAKE" -C "$BASEDIR"/masterfiles install DESTDIR="$BASEDIR"/cfengine/dist
5353
fi
5454
else
55-
echo "$(basename "$0"): Debug: Running make install in masterfiles repo..."
55+
log_debug "Running make install in masterfiles repo..."
5656
run_and_print_on_failure "$MAKE" -C "$BASEDIR"/masterfiles install DESTDIR="$BASEDIR"/cfengine/dist
5757
fi

build-scripts/detect-environment

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ detect_cross_target() {
3232
esac
3333

3434
if [ -n "$CROSS_TARGET" ]; then
35-
echo "Detected cross target $CROSS_TARGET"
35+
log_debug "Detected cross target $CROSS_TARGET"
3636
else
37-
echo "No cross target detected"
37+
log_debug "No cross target detected"
3838
fi
3939
}
4040

@@ -91,7 +91,7 @@ detect_os() {
9191
OS_VERSION=$UNAME_R
9292
;;
9393
*)
94-
echo "Unable to detect operating system: $UNAME_S"
94+
log_error "Unable to detect operating system: $UNAME_S"
9595
exit 42
9696
;;
9797
esac
@@ -101,12 +101,12 @@ detect_os() {
101101
OS=mingw
102102
;;
103103
*)
104-
echo "Unknown cross-compilation target: $CROSS_TARGET"
104+
log_error "Unknown cross-compilation target: $CROSS_TARGET"
105105
exit 42
106106
;;
107107
esac
108108

109-
echo "Detected OS $OS $OS_VERSION"
109+
log_debug "Detected OS $OS $OS_VERSION"
110110
export OS OS_VERSION
111111
}
112112

@@ -129,7 +129,7 @@ detect_distribution() {
129129
OS=rhel
130130
;;
131131
*)
132-
echo "Error: Could not determine Linux distro from /etc/redhat-release: $REL"
132+
log_error "Could not determine Linux distro from /etc/redhat-release: $REL"
133133
exit 42
134134
;;
135135
esac
@@ -141,7 +141,7 @@ detect_distribution() {
141141

142142
# Make sure we actually found a match
143143
if [ -z "$version_string" ]; then
144-
echo "Error: Could not determine version number from /etc/redhat-release: $REL"
144+
log_error "Could not determine version number from /etc/redhat-release: $REL"
145145
exit 42
146146
fi
147147
OS_VERSION=$version_string
@@ -173,7 +173,7 @@ detect_distribution() {
173173
case "$REL" in
174174
[0-9][0-9].[0-9][0-9]) ;;
175175
*)
176-
echo "Unknown Ubuntu release: $REL"
176+
log_error "Unknown Ubuntu release: $REL"
177177
exit 42
178178
;;
179179
esac
@@ -188,7 +188,7 @@ detect_distribution() {
188188

189189
REL=$(cat /etc/debian_version)
190190
if ! echo "$REL" | grep -E '^[0-9]+\.[0-9]+(\.[0-9]+)?$' >/dev/null; then
191-
echo "Unable to detect version of Debian: $REL"
191+
log_error "Unable to detect version of Debian: $REL"
192192
exit 42
193193
fi
194194

@@ -222,12 +222,12 @@ detect_distribution() {
222222
fi
223223

224224
if [ -z "$OS" ]; then
225-
echo "Failed to detect Linux distribution"
225+
log_error "Failed to detect Linux distribution"
226226
exit 42
227227
fi
228228

229229
if [ -z "$OS_VERSION" ]; then
230-
echo "Failed to detect Linux distribution version"
230+
log_error "Failed to detect Linux distribution version"
231231
exit 42
232232
fi
233233
}
@@ -252,7 +252,7 @@ detect_packaging() {
252252
elif [ -f /usr/sbin/swinstall ]; then
253253
DEP_PACKAGING=hpux
254254
else
255-
echo "Unknown packaging system"
255+
log_error "Unknown packaging system"
256256
exit 42
257257
fi
258258

@@ -268,8 +268,8 @@ detect_packaging() {
268268
;;
269269
esac
270270

271-
echo "Detected dependency packaging $DEP_PACKAGING"
272-
echo "Detected packaging $PACKAGING"
271+
log_debug "Detected dependency packaging $DEP_PACKAGING"
272+
log_debug "Detected packaging $PACKAGING"
273273
export DEP_PACKAGING PACKAGING
274274
}
275275

@@ -293,7 +293,8 @@ detect_arch() {
293293
ARCH=i86pc
294294
;;
295295
*)
296-
echo "Unknown Solaris architecture: $UNAME_M"
296+
log_error "Unknown Solaris architecture: $UNAME_M"
297+
exit 42
297298
;;
298299
esac
299300
;;
@@ -305,7 +306,7 @@ detect_arch() {
305306
ARCH=$UNAME_M
306307
;;
307308
*)
308-
echo "Unknown packaging system"
309+
log_error "Unknown packaging system"
309310
exit 42
310311
;;
311312
esac
@@ -322,12 +323,12 @@ detect_arch() {
322323
ARCH=x64
323324
;;
324325
*)
325-
echo "Unknown cross-compilation target: $CROSS_TARGET"
326+
log_error "Unknown cross-compilation target: $CROSS_TARGET"
326327
exit 42
327328
;;
328329
esac
329330

330-
echo "Detected architecture $ARCH"
331+
log_debug "Detected architecture $ARCH"
331332
export ARCH
332333
}
333334

@@ -341,9 +342,9 @@ detect_tools() {
341342

342343
if $MAKE -v | grep GNU; then
343344
export MAKE
344-
echo "Detected make path $MAKE"
345+
log_debug "Detected make path $MAKE"
345346
else
346-
echo "Error: GNU Make not found"
347+
log_error "GNU Make not found"
347348
exit 42
348349
fi
349350

@@ -353,12 +354,12 @@ detect_tools() {
353354
# systems. We use it to kill processes that can mess with the build process.
354355
FUSER=$(func_whereis fuser)
355356
export FUSER
356-
echo "Detected fuser path $FUSER"
357+
log_debug "Detected fuser path $FUSER"
357358

358359
# We use patch to apply patches to the dependencies.
359360
PATCH=$(func_whereis gpatch patch)
360361
export PATCH
361-
echo "Detected patch path $PATCH"
362+
log_debug "Detected patch path $PATCH"
362363
}
363364

364365
# This function appends the -j/--jobs option to the MAKEFLAGS environment
@@ -368,29 +369,29 @@ detect_tools() {
368369
detect_cores() {
369370
case "$OS_FAMILY" in
370371
aix)
371-
echo "Detected OS family is aix"
372+
log_debug "Detected OS family is aix"
372373
NUM_CORES="$(lscfg | grep -c proc)"
373374
;;
374375
solaris)
375-
echo "Detected OS family is solaris"
376+
log_debug "Detected OS family is solaris"
376377
NUM_CORES="$(psrinfo | wc -l)"
377378
;;
378379
linux)
379-
echo "Detected OS family is linux"
380+
log_debug "Detected OS family is linux"
380381
NUM_CORES="$(grep -c '^processor' /proc/cpuinfo)"
381382
;;
382383
hpux)
383-
echo "Detected OS family is hpux"
384+
log_debug "Detected OS family is hpux"
384385
NUM_CORES="$(ioscan -k -C processor | grep -c processor)"
385386
;;
386387
*)
387-
echo "Detected OS family is UNKNOWN, defaulting amount of CPU cores to 1"
388+
log_debug "Detected OS family is UNKNOWN, defaulting amount of CPU cores to 1"
388389
NUM_CORES=1
389390
;;
390391
esac
391392

392393
# Make number of jobs one higher than core count, to account for I/O, network, etc.
393-
echo "Detected amount of CPU cores is $NUM_CORES"
394+
log_debug "Detected amount of CPU cores is $NUM_CORES"
394395
MAKEFLAGS="${MAKEFLAGS:--j$((NUM_CORES + 1))}"
395396
export MAKEFLAGS
396397
}

0 commit comments

Comments
 (0)