diff options
author | 2020-09-10 05:48:29 -0500 | |
---|---|---|
committer | 2020-09-10 05:48:29 -0500 | |
commit | 5bcc78629e8982b95a08c224ecfe7d5bd453a332 (patch) | |
tree | b99bd79e943661e5a7e759274c48735d0a652b9c | |
parent | disable dbus proxy at compile time (default enabled) - part 2 (diff) | |
parent | Update fj-mkdeb.py (diff) | |
download | firejail-5bcc78629e8982b95a08c224ecfe7d5bd453a332.tar.gz firejail-5bcc78629e8982b95a08c224ecfe7d5bd453a332.tar.zst firejail-5bcc78629e8982b95a08c224ecfe7d5bd453a332.zip |
Merge pull request #3621 from laniakea64/fj-mkdeb-py
Update fj-mkdeb.py
-rwxr-xr-x | contrib/fj-mkdeb.py | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/contrib/fj-mkdeb.py b/contrib/fj-mkdeb.py index 429cb9db4..487df4c83 100755 --- a/contrib/fj-mkdeb.py +++ b/contrib/fj-mkdeb.py | |||
@@ -5,12 +5,16 @@ | |||
5 | 5 | ||
6 | # This script automates the workaround for https://github.com/netblue30/firejail/issues/772 | 6 | # This script automates the workaround for https://github.com/netblue30/firejail/issues/772 |
7 | 7 | ||
8 | import os, re, shlex, subprocess, sys | 8 | import os, shlex, subprocess, sys |
9 | 9 | ||
10 | 10 | ||
11 | def run(srcdir, args): | 11 | def run(srcdir, args): |
12 | if srcdir: os.chdir(srcdir) | 12 | if srcdir: os.chdir(srcdir) |
13 | 13 | ||
14 | if not (os.path.isfile('./mkdeb.sh.in')): | ||
15 | print('Error: Not a firejail source tree? Exiting.') | ||
16 | return 1 | ||
17 | |||
14 | dry_run = False | 18 | dry_run = False |
15 | escaped_args = [] | 19 | escaped_args = [] |
16 | # We need to modify the list as we go. So be sure to copy the list to be iterated! | 20 | # We need to modify the list as we go. So be sure to copy the list to be iterated! |
@@ -25,23 +29,21 @@ def run(srcdir, args): | |||
25 | else: | 29 | else: |
26 | escaped_args.append(shlex.quote(a)) | 30 | escaped_args.append(shlex.quote(a)) |
27 | 31 | ||
28 | # Fix up mkdeb.sh to include custom configure options. | 32 | # Run configure to generate mkdeb.sh. |
33 | first_config = subprocess.call(['./configure', '--prefix=/usr'] + args) | ||
34 | if first_config != 0: | ||
35 | return first_config | ||
36 | |||
37 | # Fix up dynamically-generated mkdeb.sh to include custom configure options. | ||
29 | with open('mkdeb.sh', 'rb') as f: | 38 | with open('mkdeb.sh', 'rb') as f: |
30 | sh = str(f.read(), 'utf_8') | 39 | sh = str(f.read(), 'utf_8') |
31 | rx = re.compile(r'^\./configure\s.*$', re.M) | ||
32 | with open('mkdeb.sh', 'wb') as f: | 40 | with open('mkdeb.sh', 'wb') as f: |
33 | f.write( | 41 | f.write(bytes(sh.replace('./configure $CONFIG_ARGS', |
34 | bytes( | 42 | './configure $CONFIG_ARGS ' + (' '.join(escaped_args))), 'utf_8')) |
35 | rx.sub('./configure --prefix=/usr ' + (' '.join(escaped_args)), | ||
36 | sh), 'utf_8')) | ||
37 | 43 | ||
38 | if dry_run: return 0 | 44 | if dry_run: return 0 |
39 | 45 | ||
40 | # now run configure && make | 46 | return subprocess.call(['make', 'deb']) |
41 | if subprocess.call(['./configure', '--prefix=/usr'] + args) == 0: | ||
42 | subprocess.call(['make', 'deb']) | ||
43 | |||
44 | return 0 | ||
45 | 47 | ||
46 | 48 | ||
47 | if __name__ == '__main__': | 49 | if __name__ == '__main__': |
@@ -71,9 +73,9 @@ usage: | |||
71 | if not (srcdir): | 73 | if not (srcdir): |
72 | # srcdir not manually specified, try to auto-detect | 74 | # srcdir not manually specified, try to auto-detect |
73 | srcdir = os.path.dirname(os.path.abspath(sys.argv[0] + '/..')) | 75 | srcdir = os.path.dirname(os.path.abspath(sys.argv[0] + '/..')) |
74 | if not (os.path.isfile(srcdir + '/mkdeb.sh')): | 76 | if not (os.path.isfile(srcdir + '/mkdeb.sh.in')): |
75 | # Script is probably installed. Check the cwd. | 77 | # Script is probably installed. Check the cwd. |
76 | if os.path.isfile('./mkdeb.sh'): | 78 | if os.path.isfile('./mkdeb.sh.in'): |
77 | srcdir = None | 79 | srcdir = None |
78 | else: | 80 | else: |
79 | print( | 81 | print( |