diff options
author | 2022-05-13 23:33:20 -0300 | |
---|---|---|
committer | 2022-05-29 18:59:13 -0300 | |
commit | 9a0fbbd719b6d6c6fe46ae0f4b2e0ccd7988edcc (patch) | |
tree | 02e0adba5386a4d9c3319d2eec953d161e56df48 | |
parent | fj-mkdeb.py: run distclean before ./configure (diff) | |
download | firejail-9a0fbbd719b6d6c6fe46ae0f4b2e0ccd7988edcc.tar.gz firejail-9a0fbbd719b6d6c6fe46ae0f4b2e0ccd7988edcc.tar.zst firejail-9a0fbbd719b6d6c6fe46ae0f4b2e0ccd7988edcc.zip |
mkdeb.sh.in: pass remaining arguments to ./configure
Currently, mkdeb.sh (which is used to make a .deb package) runs
./configure with hardcoded options (some of which are automatically
detected based on configure-time variables). To work around the
hardcoding, contrib/fj-mkdeb.py is used to add additional options by
rewriting the actual call to ./configure on mkdeb.sh. For example, the
following invocation adds --disable-firetunnel to mkdeb.sh:
$ ./configure && ./contrib/fj-mkdeb.py --disable-firetunnel
To avoid depending on another script and to avoid re-generating
mkdeb.sh, just let the latter pass the remaining arguments (the first
one is an optional package filename suffix) to ./configure directly.
Example:
$ make distclean && ./configure && make dist &&
./mkdeb.sh "" --disable-firetunnel
Additionally, change contrib/fj-mkdeb.py to do roughly the same as the
above example, by simply forwarding the arguments that it receives to
./mkdeb.sh (which then forwards them to ./configure). Also, remove the
--only-fix-mkdeb option, since the script does not change mkdeb.sh
anymore. With these changes, the script's usage (other than when using
--only-fix-mkdeb) should remain the same.
Note: To clean the generated files and then make a .deb package using
the default configuration, the invocation is still the same:
$ make distclean && ./configure && make deb
Note2: Running ./configure in the above examples is only needed for
generating Makefile/mkdeb.sh from Makefile.in/mkdeb.sh.in after running
distclean, so that running `make` / `./mkdeb.sh` afterwards works.
Should fully fix #772.
Relates to #1205 #3414 #5148.
-rw-r--r-- | .gitlab-ci.yml | 2 | ||||
-rw-r--r-- | Makefile.in | 2 | ||||
-rwxr-xr-x | contrib/fj-mkdeb.py | 40 | ||||
-rwxr-xr-x | mkdeb.sh.in | 12 |
4 files changed, 18 insertions, 38 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4871ef031..af590e2e1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml | |||
@@ -54,7 +54,7 @@ build_apparmor: | |||
54 | script: | 54 | script: |
55 | - apt-get update -qq | 55 | - apt-get update -qq |
56 | - DEBIAN_FRONTEND=noninteractive apt-get install -y -qq build-essential lintian libapparmor-dev pkg-config gawk | 56 | - DEBIAN_FRONTEND=noninteractive apt-get install -y -qq build-essential lintian libapparmor-dev pkg-config gawk |
57 | - ./configure --prefix=/usr --enable-apparmor && make deb-apparmor && dpkg -i firejail*.deb | 57 | - ./configure && make deb-apparmor && dpkg -i firejail*.deb |
58 | - command -V firejail && firejail --version | 58 | - command -V firejail && firejail --version |
59 | - firejail --version | grep -F 'AppArmor support is enabled' | 59 | - firejail --version | grep -F 'AppArmor support is enabled' |
60 | 60 | ||
diff --git a/Makefile.in b/Makefile.in index 0e80fb43a..7d961213a 100644 --- a/Makefile.in +++ b/Makefile.in | |||
@@ -222,7 +222,7 @@ deb: dist | |||
222 | ./mkdeb.sh | 222 | ./mkdeb.sh |
223 | 223 | ||
224 | deb-apparmor: dist | 224 | deb-apparmor: dist |
225 | ./mkdeb.sh -apparmor | 225 | ./mkdeb.sh -apparmor --enable-apparmor |
226 | 226 | ||
227 | test-compile: dist | 227 | test-compile: dist |
228 | cd test/compile; ./compile.sh $(NAME)-$(VERSION) | 228 | cd test/compile; ./compile.sh $(NAME)-$(VERSION) |
diff --git a/contrib/fj-mkdeb.py b/contrib/fj-mkdeb.py index 75fb6cbc8..f6611bee8 100755 --- a/contrib/fj-mkdeb.py +++ b/contrib/fj-mkdeb.py | |||
@@ -3,9 +3,10 @@ | |||
3 | # Copyright (C) 2014-2022 Firejail Authors | 3 | # Copyright (C) 2014-2022 Firejail Authors |
4 | # License GPL v2 | 4 | # License GPL v2 |
5 | 5 | ||
6 | # This script automates the workaround for https://github.com/netblue30/firejail/issues/772 | 6 | # This script automates the creation of a .deb package. It was originally |
7 | # created to work around https://github.com/netblue30/firejail/issues/772 | ||
7 | 8 | ||
8 | import os, shlex, subprocess, sys | 9 | import os, subprocess, sys |
9 | 10 | ||
10 | 11 | ||
11 | def run(srcdir, args): | 12 | def run(srcdir, args): |
@@ -15,41 +16,29 @@ def run(srcdir, args): | |||
15 | print('Error: Not a firejail source tree? Exiting.') | 16 | print('Error: Not a firejail source tree? Exiting.') |
16 | return 1 | 17 | return 1 |
17 | 18 | ||
18 | dry_run = False | 19 | # Ignore unsupported arguments. |
19 | escaped_args = [] | ||
20 | # We need to modify the list as we go. So be sure to copy the list to be iterated! | ||
21 | for a in args[:]: | 20 | for a in args[:]: |
22 | if a.startswith('--prefix'): | 21 | if a.startswith('--prefix'): |
23 | # prefix should ALWAYS be /usr here. Discard user-set values | 22 | # prefix should ALWAYS be /usr here. Discard user-set values |
24 | args.remove(a) | 23 | args.remove(a) |
25 | elif a == '--only-fix-mkdeb': | ||
26 | # for us, not configure | ||
27 | dry_run = True | ||
28 | args.remove(a) | ||
29 | else: | ||
30 | escaped_args.append(shlex.quote(a)) | ||
31 | 24 | ||
32 | # Remove generated files. | 25 | # Remove generated files. |
33 | if not dry_run: | 26 | distclean = subprocess.call(['make', 'distclean']) |
34 | distclean = subprocess.call(['make', 'distclean']) | 27 | if distclean != 0: |
35 | if distclean != 0: | 28 | return distclean |
36 | return distclean | ||
37 | 29 | ||
38 | # Run configure to generate mkdeb.sh. | 30 | # Run configure to generate mkdeb.sh. |
39 | first_config = subprocess.call(['./configure', '--prefix=/usr'] + args) | 31 | first_config = subprocess.call(['./configure', '--prefix=/usr'] + args) |
40 | if first_config != 0: | 32 | if first_config != 0: |
41 | return first_config | 33 | return first_config |
42 | 34 | ||
43 | # Fix up dynamically-generated mkdeb.sh to include custom configure options. | 35 | # Create the dist file used by mkdeb.sh. |
44 | with open('mkdeb.sh', 'rb') as f: | 36 | make_dist = subprocess.call(['make', 'dist']) |
45 | sh = str(f.read(), 'utf_8') | 37 | if make_dist != 0: |
46 | with open('mkdeb.sh', 'wb') as f: | 38 | return make_dist |
47 | f.write(bytes(sh.replace('./configure $CONFIG_ARGS', | ||
48 | './configure $CONFIG_ARGS ' + (' '.join(escaped_args))), 'utf_8')) | ||
49 | |||
50 | if dry_run: return 0 | ||
51 | 39 | ||
52 | return subprocess.call(['make', 'deb']) | 40 | # Run mkdeb.sh with the custom configure options. |
41 | return subprocess.call(['./mkdeb.sh'] + args) | ||
53 | 42 | ||
54 | 43 | ||
55 | if __name__ == '__main__': | 44 | if __name__ == '__main__': |
@@ -57,13 +46,12 @@ if __name__ == '__main__': | |||
57 | print('''Build a .deb of firejail with custom configure options | 46 | print('''Build a .deb of firejail with custom configure options |
58 | 47 | ||
59 | usage: | 48 | usage: |
60 | {script} [--fj-src=SRCDIR] [--only-fix-mkdeb] [CONFIGURE_OPTIONS [...]] | 49 | {script} [--fj-src=SRCDIR] [CONFIGURE_OPTIONS [...]] |
61 | 50 | ||
62 | --fj-src=SRCDIR: manually specify the location of firejail source tree | 51 | --fj-src=SRCDIR: manually specify the location of firejail source tree |
63 | as SRCDIR. If not specified, looks in the parent directory | 52 | as SRCDIR. If not specified, looks in the parent directory |
64 | of the directory where this script is located, and then the | 53 | of the directory where this script is located, and then the |
65 | current working directory, in that order. | 54 | current working directory, in that order. |
66 | --only-fix-mkdeb: don't run configure or make after modifying mkdeb.sh | ||
67 | CONFIGURE_OPTIONS: arguments for configure | 55 | CONFIGURE_OPTIONS: arguments for configure |
68 | '''.format(script=sys.argv[0])) | 56 | '''.format(script=sys.argv[0])) |
69 | sys.exit(0) | 57 | sys.exit(0) |
diff --git a/mkdeb.sh.in b/mkdeb.sh.in index a18ff8021..79f8d748c 100755 --- a/mkdeb.sh.in +++ b/mkdeb.sh.in | |||
@@ -9,17 +9,9 @@ | |||
9 | set -e | 9 | set -e |
10 | NAME=@PACKAGE_NAME@ | 10 | NAME=@PACKAGE_NAME@ |
11 | VERSION=@PACKAGE_VERSION@ | 11 | VERSION=@PACKAGE_VERSION@ |
12 | HAVE_APPARMOR=@HAVE_APPARMOR@ | ||
13 | HAVE_SELINUX=@HAVE_SELINUX@ | ||
14 | EXTRA_VERSION=$1 | 12 | EXTRA_VERSION=$1 |
15 | 13 | ||
16 | CONFIG_ARGS="--prefix=/usr" | 14 | test "$#" -gt 0 && shift |
17 | if [ -n "$HAVE_APPARMOR" ]; then | ||
18 | CONFIG_ARGS="$CONFIG_ARGS --enable-apparmor" | ||
19 | fi | ||
20 | if [ -n "$HAVE_SELINUX" ]; then | ||
21 | CONFIG_ARGS="$CONFIG_ARGS --enable-selinux" | ||
22 | fi | ||
23 | 15 | ||
24 | CODE_ARCHIVE="$NAME-$VERSION.tar.xz" | 16 | CODE_ARCHIVE="$NAME-$VERSION.tar.xz" |
25 | CODE_DIR="$NAME-$VERSION" | 17 | CODE_DIR="$NAME-$VERSION" |
@@ -36,7 +28,7 @@ echo "*****************************************" | |||
36 | tar -xJvf "$CODE_ARCHIVE" | 28 | tar -xJvf "$CODE_ARCHIVE" |
37 | #mkdir -p "$INSTALL_DIR" | 29 | #mkdir -p "$INSTALL_DIR" |
38 | cd "$CODE_DIR" | 30 | cd "$CODE_DIR" |
39 | ./configure $CONFIG_ARGS | 31 | ./configure --prefix=/usr "$@" |
40 | make -j2 | 32 | make -j2 |
41 | mkdir debian | 33 | mkdir debian |
42 | DESTDIR=debian make install-strip | 34 | DESTDIR=debian make install-strip |