diff options
Diffstat (limited to 'contrib/fj-mkdeb.py')
-rwxr-xr-x | contrib/fj-mkdeb.py | 40 |
1 files changed, 14 insertions, 26 deletions
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) |