aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Kelvin M. Klann <kmk3.code@protonmail.com>2023-07-30 00:54:04 +0000
committerLibravatar GitHub <noreply@github.com>2023-07-30 00:54:04 +0000
commit4a26d91ae2cedc6733d4df0008ccacc4aca177ba (patch)
tree644ebe2eccff1991e11ff1f6391df0f60e9978f1
parentMerge branch 'master' of ssh://github.com/netblue30/firejail (diff)
parentbuild: use config.sh in more scripts (diff)
downloadfirejail-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--Makefile8
-rwxr-xr-xmkasc.sh2
-rwxr-xr-xplatform/rpm/mkrpm.sh34
-rwxr-xr-xtest/compile/compile.sh43
4 files changed, 46 insertions, 41 deletions
diff --git a/Makefile b/Makefile
index 03ae71026..3055e226a 100644
--- a/Makefile
+++ b/Makefile
@@ -347,12 +347,12 @@ deb: dist config.sh
347 ./mkdeb.sh 347 ./mkdeb.sh
348 348
349.PHONY: test-compile 349.PHONY: test-compile
350test-compile: dist config.mk 350test-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
354rpms: src/man config.mk 354rpms: src/man config.sh
355 ./platform/rpm/mkrpm.sh $(TARNAME) $(VERSION) 355 ./platform/rpm/mkrpm.sh
356 356
357.PHONY: extras 357.PHONY: extras
358extras: all 358extras: all
diff --git a/mkasc.sh b/mkasc.sh
index 62c1b1180..0314c20e5 100755
--- a/mkasc.sh
+++ b/mkasc.sh
@@ -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
8printf 'Calculating SHA256 for all files in /transfer - %s version %s' "$TARNAME" "$VERSION" 8printf '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
11name=$1 11# shellcheck source=config.sh
12. "$(dirname "$0")/../../config.sh" || exit 1
13
14name="$TARNAME"
12# Strip any trailing prefix from the version like -rc1 etc 15# Strip any trailing prefix from the version like -rc1 etc
13version=$(echo "$2" | sed 's/\-.*//g') 16version="$(printf '%s\n' "$VERSION" | sed 's/\-.*//g')"
14config_opt=$3 17config_opt="$*"
15 18
16if [[ ! -f platform/rpm/${name}.spec ]]; then 19if [[ ! -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
19fi 22fi
20 23
21if [[ -z "${version}" ]]; then 24if [[ -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
24fi 27fi
25 28
@@ -28,26 +31,27 @@ if [[ -z "${config_opt}" ]]; then
28fi 31fi
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
31tmpdir=$(mktemp -d) 34tmpdir="$(mktemp -d)"
32mkdir -p ${tmpdir}/{BUILD,RPMS,SOURCES,SPECS,SRPMS} 35mkdir -p "${tmpdir}"/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
33function cleanup { 36function cleanup {
34 rm -rf ${tmpdir} 37 rm -rf "${tmpdir}"
35} 38}
36trap cleanup EXIT 39trap cleanup EXIT
37 40
38# Create the spec file 41# Create the spec file
39tmp_spec_file=${tmpdir}/SPECS/${name}.spec 42tmp_spec_file="${tmpdir}/SPECS/${name}.spec"
40sed -e "s/__NAME__/${name}/g" \ 43sed -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
47tar --exclude='./.git*' --transform "s/^./${name}-${version}/" -czf ${tmpdir}/SOURCES/${name}-${version}.tar.gz . 50tar --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)
50rpmbuild --quiet --define "_topdir ${tmpdir}" -ba ${tmp_spec_file} 54rpmbuild --quiet --define "_topdir ${tmpdir}" -ba "${tmp_spec_file}"
51 55
52# Copy the results to cwd 56# Copy the results to cwd
53mv ${tmpdir}/SRPMS/*.rpm ${tmpdir}/RPMS/*/*rpm . 57mv "${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
16arr[1]="TEST 1: standard compilation" 17arr[1]="TEST 1: standard compilation"
17arr[2]="TEST 2: compile dbus proxy disabled" 18arr[2]="TEST 2: compile dbus proxy disabled"
@@ -51,7 +52,7 @@ print_title() {
51 echo "**************************************************" 52 echo "**************************************************"
52} 53}
53 54
54DIST="$1" 55DIST="$(TARNAME)-$(VERSION)"
55while [[ $# -gt 0 ]]; do # Until you run out of parameters . . . 56while [[ $# -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"
79tar -xJvf ../../"$DIST.tar.xz" 80tar -xJvf ../../"$DIST.tar.xz"
80mv "$DIST" firejail 81mv "$DIST" firejail
81 82
82cd firejail 83cd 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
84make -j4 2>&1 | tee ../output-make 85make -j4 2>&1 | tee ../output-make
85cd .. 86cd ..
@@ -95,7 +96,7 @@ rm output-configure output-make
95# - disable dbus proxy configuration 96# - disable dbus proxy configuration
96#***************************************************************** 97#*****************************************************************
97print_title "${arr[2]}" 98print_title "${arr[2]}"
98cd firejail 99cd firejail || exit 1
99make distclean 100make 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
101make -j4 2>&1 | tee ../output-make 102make -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#*****************************************************************
114print_title "${arr[3]}" 115print_title "${arr[3]}"
115cd firejail 116cd firejail || exit 1
116make distclean 117make 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
118make -j4 2>&1 | tee ../output-make 119make -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#*****************************************************************
131print_title "${arr[4]}" 132print_title "${arr[4]}"
132cd firejail 133cd firejail || exit 1
133make distclean 134make 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
135make -j4 2>&1 | tee ../output-make 136make -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#*****************************************************************
148print_title "${arr[5]}" 149print_title "${arr[5]}"
149cd firejail 150cd firejail || exit 1
150make distclean 151make 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
152make -j4 2>&1 | tee ../output-make 153make -j4 2>&1 | tee ../output-make
@@ -164,7 +165,7 @@ rm output-configure output-make
164# - check compilation 165# - check compilation
165#***************************************************************** 166#*****************************************************************
166print_title "${arr[6]}" 167print_title "${arr[6]}"
167cd firejail 168cd firejail || exit 1
168make distclean 169make 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
170make -j4 2>&1 | tee ../output-make 171make -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#*****************************************************************
183print_title "${arr[7]}" 184print_title "${arr[7]}"
184cd firejail 185cd firejail || exit 1
185make distclean 186make 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
187make -j4 2>&1 | tee ../output-make 188make -j4 2>&1 | tee ../output-make
@@ -198,7 +199,7 @@ rm output-configure output-make
198# - enable selinux 199# - enable selinux
199#***************************************************************** 200#*****************************************************************
200print_title "${arr[8]}" 201print_title "${arr[8]}"
201cd firejail 202cd firejail || exit 1
202make distclean 203make 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
204make -j4 2>&1 | tee ../output-make 205make -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#*****************************************************************
217print_title "${arr[9]}" 218print_title "${arr[9]}"
218cd firejail 219cd firejail || exit 1
219make distclean 220make 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
221make -j4 2>&1 | tee ../output-make 222make -j4 2>&1 | tee ../output-make
@@ -232,7 +233,7 @@ rm output-configure output-make
232# - disable whitelist 233# - disable whitelist
233#***************************************************************** 234#*****************************************************************
234print_title "${arr[10]}" 235print_title "${arr[10]}"
235cd firejail 236cd firejail || exit 1
236make distclean 237make 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
238make -j4 2>&1 | tee ../output-make 239make -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#*****************************************************************
251print_title "${arr[11]}" 252print_title "${arr[11]}"
252cd firejail 253cd firejail || exit 1
253make distclean 254make 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
255make -j4 2>&1 | tee ../output-make 256make -j4 2>&1 | tee ../output-make
@@ -266,7 +267,7 @@ rm output-configure output-make
266# - enable apparmor 267# - enable apparmor
267#***************************************************************** 268#*****************************************************************
268print_title "${arr[12]}" 269print_title "${arr[12]}"
269cd firejail 270cd firejail || exit 1
270make distclean 271make 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
272make -j4 2>&1 | tee ../output-make 273make -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#*****************************************************************
285print_title "${arr[13]}" 286print_title "${arr[13]}"
286cd firejail 287cd firejail || exit 1
287make distclean 288make 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
289make -j4 2>&1 | tee ../output-make 290make -j4 2>&1 | tee ../output-make
@@ -300,7 +301,7 @@ rm output-configure output-make
300# - disable overlayfs 301# - disable overlayfs
301#***************************************************************** 302#*****************************************************************
302print_title "${arr[14]}" 303print_title "${arr[14]}"
303cd firejail 304cd firejail || exit 1
304make distclean 305make 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
306make -j4 2>&1 | tee ../output-make 307make -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#*****************************************************************
319print_title "${arr[15]}" 320print_title "${arr[15]}"
320cd firejail 321cd firejail || exit 1
321make distclean 322make 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
323make -j4 2>&1 | tee ../output-make 324make -j4 2>&1 | tee ../output-make
@@ -334,7 +335,7 @@ rm output-configure output-make
334# - disable manpages 335# - disable manpages
335#***************************************************************** 336#*****************************************************************
336print_title "${arr[16]}" 337print_title "${arr[16]}"
337cd firejail 338cd firejail || exit 1
338make distclean 339make 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
340make -j4 2>&1 | tee ../output-make 341make -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#*****************************************************************
353print_title "${arr[17]}" 354print_title "${arr[17]}"
354cd firejail 355cd firejail || exit 1
355make distclean 356make 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
357make -j4 2>&1 | tee ../output-make 358make -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#*****************************************************************
370print_title "${arr[18]}" 371print_title "${arr[18]}"
371cd firejail 372cd firejail || exit 1
372make distclean 373make 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
374make -j4 2>&1 | tee ../output-make 375make -j4 2>&1 | tee ../output-make
@@ -385,7 +386,7 @@ rm output-configure output-make
385# - enable ids 386# - enable ids
386#***************************************************************** 387#*****************************************************************
387print_title "${arr[19]}" 388print_title "${arr[19]}"
388cd firejail 389cd firejail || exit 1
389make distclean 390make 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
391make -j4 2>&1 | tee ../output-make 392make -j4 2>&1 | tee ../output-make