diff options
author | 2023-07-30 00:54:04 +0000 | |
---|---|---|
committer | 2023-07-30 00:54:04 +0000 | |
commit | 4a26d91ae2cedc6733d4df0008ccacc4aca177ba (patch) | |
tree | 644ebe2eccff1991e11ff1f6391df0f60e9978f1 | |
parent | Merge branch 'master' of ssh://github.com/netblue30/firejail (diff) | |
parent | build: use config.sh in more scripts (diff) | |
download | firejail-4a26d91ae2cedc6733d4df0008ccacc4aca177ba.tar.gz firejail-4a26d91ae2cedc6733d4df0008ccacc4aca177ba.tar.zst firejail-4a26d91ae2cedc6733d4df0008ccacc4aca177ba.zip |
Merge pull request #5927 from kmk3/build-use-config-sh
build: fix some shellcheck issues & use config.sh in more scripts
-rw-r--r-- | Makefile | 8 | ||||
-rwxr-xr-x | mkasc.sh | 2 | ||||
-rwxr-xr-x | platform/rpm/mkrpm.sh | 34 | ||||
-rwxr-xr-x | test/compile/compile.sh | 43 |
4 files changed, 46 insertions, 41 deletions
@@ -347,12 +347,12 @@ deb: dist config.sh | |||
347 | ./mkdeb.sh | 347 | ./mkdeb.sh |
348 | 348 | ||
349 | .PHONY: test-compile | 349 | .PHONY: test-compile |
350 | test-compile: dist config.mk | 350 | test-compile: dist config.sh |
351 | cd test/compile; ./compile.sh $(TARNAME)-$(VERSION) | 351 | cd test/compile; ./compile.sh |
352 | 352 | ||
353 | .PHONY: rpms | 353 | .PHONY: rpms |
354 | rpms: src/man config.mk | 354 | rpms: src/man config.sh |
355 | ./platform/rpm/mkrpm.sh $(TARNAME) $(VERSION) | 355 | ./platform/rpm/mkrpm.sh |
356 | 356 | ||
357 | .PHONY: extras | 357 | .PHONY: extras |
358 | extras: all | 358 | extras: all |
@@ -3,7 +3,7 @@ | |||
3 | # Copyright (C) 2014-2023 Firejail Authors | 3 | # Copyright (C) 2014-2023 Firejail Authors |
4 | # License GPL v2 | 4 | # License GPL v2 |
5 | 5 | ||
6 | . "$(dirname "$0")/config.sh" | 6 | . "$(dirname "$0")/config.sh" || exit 1 |
7 | 7 | ||
8 | printf 'Calculating SHA256 for all files in /transfer - %s version %s' "$TARNAME" "$VERSION" | 8 | printf 'Calculating SHA256 for all files in /transfer - %s version %s' "$TARNAME" "$VERSION" |
9 | 9 | ||
diff --git a/platform/rpm/mkrpm.sh b/platform/rpm/mkrpm.sh index d32ccd360..0572480c6 100755 --- a/platform/rpm/mkrpm.sh +++ b/platform/rpm/mkrpm.sh | |||
@@ -3,23 +3,26 @@ | |||
3 | # Copyright (C) 2014-2023 Firejail Authors | 3 | # Copyright (C) 2014-2023 Firejail Authors |
4 | # License GPL v2 | 4 | # License GPL v2 |
5 | # | 5 | # |
6 | # Usage: ./platform/rpm/mkrpm.sh firejail <version> "<config options>" | 6 | # Usage: ./platform/rpm/mkrpm.sh <config options> |
7 | # | 7 | # |
8 | # Builds rpms in a temporary directory then places the result in the | 8 | # Builds rpms in a temporary directory then places the result in the |
9 | # current working directory. | 9 | # current working directory. |
10 | 10 | ||
11 | name=$1 | 11 | # shellcheck source=config.sh |
12 | . "$(dirname "$0")/../../config.sh" || exit 1 | ||
13 | |||
14 | name="$TARNAME" | ||
12 | # Strip any trailing prefix from the version like -rc1 etc | 15 | # Strip any trailing prefix from the version like -rc1 etc |
13 | version=$(echo "$2" | sed 's/\-.*//g') | 16 | version="$(printf '%s\n' "$VERSION" | sed 's/\-.*//g')" |
14 | config_opt=$3 | 17 | config_opt="$*" |
15 | 18 | ||
16 | if [[ ! -f platform/rpm/${name}.spec ]]; then | 19 | if [[ ! -f "platform/rpm/${name}.spec" ]]; then |
17 | echo error: spec file not found for name \"${name}\" | 20 | printf 'error: spec file not found for name %s\n' "${name}" >&2 |
18 | exit 1 | 21 | exit 1 |
19 | fi | 22 | fi |
20 | 23 | ||
21 | if [[ -z "${version}" ]]; then | 24 | if [[ -z "${version}" ]]; then |
22 | echo error: version must be given | 25 | printf 'error: version must be given\n' >&2 |
23 | exit 1 | 26 | exit 1 |
24 | fi | 27 | fi |
25 | 28 | ||
@@ -28,26 +31,27 @@ if [[ -z "${config_opt}" ]]; then | |||
28 | fi | 31 | fi |
29 | 32 | ||
30 | # Make a temporary directory and arrange to clean up on exit | 33 | # Make a temporary directory and arrange to clean up on exit |
31 | tmpdir=$(mktemp -d) | 34 | tmpdir="$(mktemp -d)" |
32 | mkdir -p ${tmpdir}/{BUILD,RPMS,SOURCES,SPECS,SRPMS} | 35 | mkdir -p "${tmpdir}"/{BUILD,RPMS,SOURCES,SPECS,SRPMS} |
33 | function cleanup { | 36 | function cleanup { |
34 | rm -rf ${tmpdir} | 37 | rm -rf "${tmpdir}" |
35 | } | 38 | } |
36 | trap cleanup EXIT | 39 | trap cleanup EXIT |
37 | 40 | ||
38 | # Create the spec file | 41 | # Create the spec file |
39 | tmp_spec_file=${tmpdir}/SPECS/${name}.spec | 42 | tmp_spec_file="${tmpdir}/SPECS/${name}.spec" |
40 | sed -e "s/__NAME__/${name}/g" \ | 43 | sed -e "s/__NAME__/${name}/g" \ |
41 | -e "s/__VERSION__/${version}/g" \ | 44 | -e "s/__VERSION__/${version}/g" \ |
42 | -e "s/__CONFIG_OPT__/${config_opt}/g" \ | 45 | -e "s/__CONFIG_OPT__/${config_opt}/g" \ |
43 | platform/rpm/${name}.spec >${tmp_spec_file} | 46 | "platform/rpm/${name}.spec" >"${tmp_spec_file}" |
44 | # FIXME: We could parse RELNOTES and create a %changelog section here | 47 | # FIXME: We could parse RELNOTES and create a %changelog section here |
45 | 48 | ||
46 | # Copy the source to build into a tarball | 49 | # Copy the source to build into a tarball |
47 | tar --exclude='./.git*' --transform "s/^./${name}-${version}/" -czf ${tmpdir}/SOURCES/${name}-${version}.tar.gz . | 50 | tar --exclude='./.git*' --transform "s/^./${name}-${version}/" \ |
51 | -czf "${tmpdir}/SOURCES/${name}-${version}.tar.gz" . | ||
48 | 52 | ||
49 | # Build the files (rpm, debug rpm and source rpm) | 53 | # Build the files (rpm, debug rpm and source rpm) |
50 | rpmbuild --quiet --define "_topdir ${tmpdir}" -ba ${tmp_spec_file} | 54 | rpmbuild --quiet --define "_topdir ${tmpdir}" -ba "${tmp_spec_file}" |
51 | 55 | ||
52 | # Copy the results to cwd | 56 | # Copy the results to cwd |
53 | mv ${tmpdir}/SRPMS/*.rpm ${tmpdir}/RPMS/*/*rpm . | 57 | mv "${tmpdir}/SRPMS"/*.rpm "${tmpdir}/RPMS"/*/*rpm . |
diff --git a/test/compile/compile.sh b/test/compile/compile.sh index da6e43a5a..0e3425f8d 100755 --- a/test/compile/compile.sh +++ b/test/compile/compile.sh | |||
@@ -11,7 +11,8 @@ | |||
11 | # install contrib scripts | 11 | # install contrib scripts |
12 | # --enable-analyzer enable GCC 10 static analyzer | 12 | # --enable-analyzer enable GCC 10 static analyzer |
13 | 13 | ||
14 | 14 | # shellcheck source=config.sh | |
15 | . "$(dirname "$0")/../../config.sh" || exit 1 | ||
15 | 16 | ||
16 | arr[1]="TEST 1: standard compilation" | 17 | arr[1]="TEST 1: standard compilation" |
17 | arr[2]="TEST 2: compile dbus proxy disabled" | 18 | arr[2]="TEST 2: compile dbus proxy disabled" |
@@ -51,7 +52,7 @@ print_title() { | |||
51 | echo "**************************************************" | 52 | echo "**************************************************" |
52 | } | 53 | } |
53 | 54 | ||
54 | DIST="$1" | 55 | DIST="$(TARNAME)-$(VERSION)" |
55 | while [[ $# -gt 0 ]]; do # Until you run out of parameters . . . | 56 | while [[ $# -gt 0 ]]; do # Until you run out of parameters . . . |
56 | case "$1" in | 57 | case "$1" in |
57 | --clean) | 58 | --clean) |
@@ -79,7 +80,7 @@ echo "$DIST" | |||
79 | tar -xJvf ../../"$DIST.tar.xz" | 80 | tar -xJvf ../../"$DIST.tar.xz" |
80 | mv "$DIST" firejail | 81 | mv "$DIST" firejail |
81 | 82 | ||
82 | cd firejail | 83 | cd firejail || exit 1 |
83 | ./configure --prefix=/usr --enable-fatal-warnings 2>&1 | tee ../output-configure | 84 | ./configure --prefix=/usr --enable-fatal-warnings 2>&1 | tee ../output-configure |
84 | make -j4 2>&1 | tee ../output-make | 85 | make -j4 2>&1 | tee ../output-make |
85 | cd .. | 86 | cd .. |
@@ -95,7 +96,7 @@ rm output-configure output-make | |||
95 | # - disable dbus proxy configuration | 96 | # - disable dbus proxy configuration |
96 | #***************************************************************** | 97 | #***************************************************************** |
97 | print_title "${arr[2]}" | 98 | print_title "${arr[2]}" |
98 | cd firejail | 99 | cd firejail || exit 1 |
99 | make distclean | 100 | make distclean |
100 | ./configure --prefix=/usr --disable-dbusproxy --enable-fatal-warnings 2>&1 | tee ../output-configure | 101 | ./configure --prefix=/usr --disable-dbusproxy --enable-fatal-warnings 2>&1 | tee ../output-configure |
101 | make -j4 2>&1 | tee ../output-make | 102 | make -j4 2>&1 | tee ../output-make |
@@ -112,7 +113,7 @@ rm output-configure output-make | |||
112 | # - disable chroot configuration | 113 | # - disable chroot configuration |
113 | #***************************************************************** | 114 | #***************************************************************** |
114 | print_title "${arr[3]}" | 115 | print_title "${arr[3]}" |
115 | cd firejail | 116 | cd firejail || exit 1 |
116 | make distclean | 117 | make distclean |
117 | ./configure --prefix=/usr --disable-chroot --enable-fatal-warnings 2>&1 | tee ../output-configure | 118 | ./configure --prefix=/usr --disable-chroot --enable-fatal-warnings 2>&1 | tee ../output-configure |
118 | make -j4 2>&1 | tee ../output-make | 119 | make -j4 2>&1 | tee ../output-make |
@@ -129,7 +130,7 @@ rm output-configure output-make | |||
129 | # - disable firetunnel configuration | 130 | # - disable firetunnel configuration |
130 | #***************************************************************** | 131 | #***************************************************************** |
131 | print_title "${arr[4]}" | 132 | print_title "${arr[4]}" |
132 | cd firejail | 133 | cd firejail || exit 1 |
133 | make distclean | 134 | make distclean |
134 | ./configure --prefix=/usr --disable-firetunnel --enable-fatal-warnings 2>&1 | tee ../output-configure | 135 | ./configure --prefix=/usr --disable-firetunnel --enable-fatal-warnings 2>&1 | tee ../output-configure |
135 | make -j4 2>&1 | tee ../output-make | 136 | make -j4 2>&1 | tee ../output-make |
@@ -146,7 +147,7 @@ rm output-configure output-make | |||
146 | # - disable user namespace configuration | 147 | # - disable user namespace configuration |
147 | #***************************************************************** | 148 | #***************************************************************** |
148 | print_title "${arr[5]}" | 149 | print_title "${arr[5]}" |
149 | cd firejail | 150 | cd firejail || exit 1 |
150 | make distclean | 151 | make distclean |
151 | ./configure --prefix=/usr --disable-userns --enable-fatal-warnings 2>&1 | tee ../output-configure | 152 | ./configure --prefix=/usr --disable-userns --enable-fatal-warnings 2>&1 | tee ../output-configure |
152 | make -j4 2>&1 | tee ../output-make | 153 | make -j4 2>&1 | tee ../output-make |
@@ -164,7 +165,7 @@ rm output-configure output-make | |||
164 | # - check compilation | 165 | # - check compilation |
165 | #***************************************************************** | 166 | #***************************************************************** |
166 | print_title "${arr[6]}" | 167 | print_title "${arr[6]}" |
167 | cd firejail | 168 | cd firejail || exit 1 |
168 | make distclean | 169 | make distclean |
169 | ./configure --prefix=/usr --disable-network --enable-fatal-warnings 2>&1 | tee ../output-configure | 170 | ./configure --prefix=/usr --disable-network --enable-fatal-warnings 2>&1 | tee ../output-configure |
170 | make -j4 2>&1 | tee ../output-make | 171 | make -j4 2>&1 | tee ../output-make |
@@ -181,7 +182,7 @@ rm output-configure output-make | |||
181 | # - disable X11 support | 182 | # - disable X11 support |
182 | #***************************************************************** | 183 | #***************************************************************** |
183 | print_title "${arr[7]}" | 184 | print_title "${arr[7]}" |
184 | cd firejail | 185 | cd firejail || exit 1 |
185 | make distclean | 186 | make distclean |
186 | ./configure --prefix=/usr --disable-x11 --enable-fatal-warnings 2>&1 | tee ../output-configure | 187 | ./configure --prefix=/usr --disable-x11 --enable-fatal-warnings 2>&1 | tee ../output-configure |
187 | make -j4 2>&1 | tee ../output-make | 188 | make -j4 2>&1 | tee ../output-make |
@@ -198,7 +199,7 @@ rm output-configure output-make | |||
198 | # - enable selinux | 199 | # - enable selinux |
199 | #***************************************************************** | 200 | #***************************************************************** |
200 | print_title "${arr[8]}" | 201 | print_title "${arr[8]}" |
201 | cd firejail | 202 | cd firejail || exit 1 |
202 | make distclean | 203 | make distclean |
203 | ./configure --prefix=/usr --enable-selinux --enable-fatal-warnings 2>&1 | tee ../output-configure | 204 | ./configure --prefix=/usr --enable-selinux --enable-fatal-warnings 2>&1 | tee ../output-configure |
204 | make -j4 2>&1 | tee ../output-make | 205 | make -j4 2>&1 | tee ../output-make |
@@ -215,7 +216,7 @@ rm output-configure output-make | |||
215 | # - disable file transfer | 216 | # - disable file transfer |
216 | #***************************************************************** | 217 | #***************************************************************** |
217 | print_title "${arr[9]}" | 218 | print_title "${arr[9]}" |
218 | cd firejail | 219 | cd firejail || exit 1 |
219 | make distclean | 220 | make distclean |
220 | ./configure --prefix=/usr --disable-file-transfer --enable-fatal-warnings 2>&1 | tee ../output-configure | 221 | ./configure --prefix=/usr --disable-file-transfer --enable-fatal-warnings 2>&1 | tee ../output-configure |
221 | make -j4 2>&1 | tee ../output-make | 222 | make -j4 2>&1 | tee ../output-make |
@@ -232,7 +233,7 @@ rm output-configure output-make | |||
232 | # - disable whitelist | 233 | # - disable whitelist |
233 | #***************************************************************** | 234 | #***************************************************************** |
234 | print_title "${arr[10]}" | 235 | print_title "${arr[10]}" |
235 | cd firejail | 236 | cd firejail || exit 1 |
236 | make distclean | 237 | make distclean |
237 | ./configure --prefix=/usr --disable-whitelist --enable-fatal-warnings 2>&1 | tee ../output-configure | 238 | ./configure --prefix=/usr --disable-whitelist --enable-fatal-warnings 2>&1 | tee ../output-configure |
238 | make -j4 2>&1 | tee ../output-make | 239 | make -j4 2>&1 | tee ../output-make |
@@ -249,7 +250,7 @@ rm output-configure output-make | |||
249 | # - disable global config | 250 | # - disable global config |
250 | #***************************************************************** | 251 | #***************************************************************** |
251 | print_title "${arr[11]}" | 252 | print_title "${arr[11]}" |
252 | cd firejail | 253 | cd firejail || exit 1 |
253 | make distclean | 254 | make distclean |
254 | ./configure --prefix=/usr --disable-globalcfg --enable-fatal-warnings 2>&1 | tee ../output-configure | 255 | ./configure --prefix=/usr --disable-globalcfg --enable-fatal-warnings 2>&1 | tee ../output-configure |
255 | make -j4 2>&1 | tee ../output-make | 256 | make -j4 2>&1 | tee ../output-make |
@@ -266,7 +267,7 @@ rm output-configure output-make | |||
266 | # - enable apparmor | 267 | # - enable apparmor |
267 | #***************************************************************** | 268 | #***************************************************************** |
268 | print_title "${arr[12]}" | 269 | print_title "${arr[12]}" |
269 | cd firejail | 270 | cd firejail || exit 1 |
270 | make distclean | 271 | make distclean |
271 | ./configure --prefix=/usr --enable-apparmor --enable-fatal-warnings 2>&1 | tee ../output-configure | 272 | ./configure --prefix=/usr --enable-apparmor --enable-fatal-warnings 2>&1 | tee ../output-configure |
272 | make -j4 2>&1 | tee ../output-make | 273 | make -j4 2>&1 | tee ../output-make |
@@ -283,7 +284,7 @@ rm output-configure output-make | |||
283 | # - enable busybox workaround | 284 | # - enable busybox workaround |
284 | #***************************************************************** | 285 | #***************************************************************** |
285 | print_title "${arr[13]}" | 286 | print_title "${arr[13]}" |
286 | cd firejail | 287 | cd firejail || exit 1 |
287 | make distclean | 288 | make distclean |
288 | ./configure --prefix=/usr --enable-busybox-workaround --enable-fatal-warnings 2>&1 | tee ../output-configure | 289 | ./configure --prefix=/usr --enable-busybox-workaround --enable-fatal-warnings 2>&1 | tee ../output-configure |
289 | make -j4 2>&1 | tee ../output-make | 290 | make -j4 2>&1 | tee ../output-make |
@@ -300,7 +301,7 @@ rm output-configure output-make | |||
300 | # - disable overlayfs | 301 | # - disable overlayfs |
301 | #***************************************************************** | 302 | #***************************************************************** |
302 | print_title "${arr[14]}" | 303 | print_title "${arr[14]}" |
303 | cd firejail | 304 | cd firejail || exit 1 |
304 | make distclean | 305 | make distclean |
305 | ./configure --prefix=/usr --disable-overlayfs --enable-fatal-warnings 2>&1 | tee ../output-configure | 306 | ./configure --prefix=/usr --disable-overlayfs --enable-fatal-warnings 2>&1 | tee ../output-configure |
306 | make -j4 2>&1 | tee ../output-make | 307 | make -j4 2>&1 | tee ../output-make |
@@ -317,7 +318,7 @@ rm output-configure output-make | |||
317 | # - disable private home | 318 | # - disable private home |
318 | #***************************************************************** | 319 | #***************************************************************** |
319 | print_title "${arr[15]}" | 320 | print_title "${arr[15]}" |
320 | cd firejail | 321 | cd firejail || exit 1 |
321 | make distclean | 322 | make distclean |
322 | ./configure --prefix=/usr --disable-private-home --enable-fatal-warnings 2>&1 | tee ../output-configure | 323 | ./configure --prefix=/usr --disable-private-home --enable-fatal-warnings 2>&1 | tee ../output-configure |
323 | make -j4 2>&1 | tee ../output-make | 324 | make -j4 2>&1 | tee ../output-make |
@@ -334,7 +335,7 @@ rm output-configure output-make | |||
334 | # - disable manpages | 335 | # - disable manpages |
335 | #***************************************************************** | 336 | #***************************************************************** |
336 | print_title "${arr[16]}" | 337 | print_title "${arr[16]}" |
337 | cd firejail | 338 | cd firejail || exit 1 |
338 | make distclean | 339 | make distclean |
339 | ./configure --prefix=/usr --disable-man --enable-fatal-warnings 2>&1 | tee ../output-configure | 340 | ./configure --prefix=/usr --disable-man --enable-fatal-warnings 2>&1 | tee ../output-configure |
340 | make -j4 2>&1 | tee ../output-make | 341 | make -j4 2>&1 | tee ../output-make |
@@ -351,7 +352,7 @@ rm output-configure output-make | |||
351 | # - disable tmpfs as regular user" | 352 | # - disable tmpfs as regular user" |
352 | #***************************************************************** | 353 | #***************************************************************** |
353 | print_title "${arr[17]}" | 354 | print_title "${arr[17]}" |
354 | cd firejail | 355 | cd firejail || exit 1 |
355 | make distclean | 356 | make distclean |
356 | ./configure --prefix=/usr --disable-usertmpfs --enable-fatal-warnings 2>&1 | tee ../output-configure | 357 | ./configure --prefix=/usr --disable-usertmpfs --enable-fatal-warnings 2>&1 | tee ../output-configure |
357 | make -j4 2>&1 | tee ../output-make | 358 | make -j4 2>&1 | tee ../output-make |
@@ -368,7 +369,7 @@ rm output-configure output-make | |||
368 | # - disable private home feature | 369 | # - disable private home feature |
369 | #***************************************************************** | 370 | #***************************************************************** |
370 | print_title "${arr[18]}" | 371 | print_title "${arr[18]}" |
371 | cd firejail | 372 | cd firejail || exit 1 |
372 | make distclean | 373 | make distclean |
373 | ./configure --prefix=/usr --disable-private-home --enable-fatal-warnings 2>&1 | tee ../output-configure | 374 | ./configure --prefix=/usr --disable-private-home --enable-fatal-warnings 2>&1 | tee ../output-configure |
374 | make -j4 2>&1 | tee ../output-make | 375 | make -j4 2>&1 | tee ../output-make |
@@ -385,7 +386,7 @@ rm output-configure output-make | |||
385 | # - enable ids | 386 | # - enable ids |
386 | #***************************************************************** | 387 | #***************************************************************** |
387 | print_title "${arr[19]}" | 388 | print_title "${arr[19]}" |
388 | cd firejail | 389 | cd firejail || exit 1 |
389 | make distclean | 390 | make distclean |
390 | ./configure --prefix=/usr --enable-ids --enable-fatal-warnings 2>&1 | tee ../output-configure | 391 | ./configure --prefix=/usr --enable-ids --enable-fatal-warnings 2>&1 | tee ../output-configure |
391 | make -j4 2>&1 | tee ../output-make | 392 | make -j4 2>&1 | tee ../output-make |