diff options
Diffstat (limited to 'contrib/fj-mkdeb.py')
-rwxr-xr-x | contrib/fj-mkdeb.py | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/contrib/fj-mkdeb.py b/contrib/fj-mkdeb.py deleted file mode 100755 index 3cc13b758..000000000 --- a/contrib/fj-mkdeb.py +++ /dev/null | |||
@@ -1,74 +0,0 @@ | |||
1 | #!/usr/bin/env python3 | ||
2 | |||
3 | # This script is automate the workaround for https://github.com/netblue30/firejail/issues/772 | ||
4 | |||
5 | import os, re, shlex, subprocess, sys | ||
6 | |||
7 | def run(srcdir, args): | ||
8 | if srcdir: os.chdir(srcdir) | ||
9 | |||
10 | dry_run=False | ||
11 | escaped_args=[] | ||
12 | # We need to modify the list as we go. So be sure to copy the list to be iterated! | ||
13 | for a in args[:]: | ||
14 | if a.startswith('--prefix'): | ||
15 | # prefix should ALWAYS be /usr here. Discard user-set values | ||
16 | args.remove(a) | ||
17 | elif a == '--only-fix-mkdeb': | ||
18 | # for us, not configure | ||
19 | dry_run=True | ||
20 | args.remove(a) | ||
21 | else: | ||
22 | escaped_args.append(shlex.quote(a)) | ||
23 | |||
24 | # Fix up mkdeb.sh to include custom configure options. | ||
25 | with open('mkdeb.sh', 'rb') as f: | ||
26 | sh=str(f.read(), 'utf_8') | ||
27 | rx=re.compile(r'^\./configure\s.*$', re.M) | ||
28 | with open('mkdeb.sh', 'wb') as f: | ||
29 | f.write(bytes(rx.sub('./configure --prefix=/usr '+(' '.join(escaped_args)), sh), 'utf_8')) | ||
30 | |||
31 | if dry_run: return 0 | ||
32 | |||
33 | # now run configure && make | ||
34 | if subprocess.call(['./configure', '--prefix=/usr']+args) == 0: | ||
35 | subprocess.call(['make', 'deb']) | ||
36 | |||
37 | return 0 | ||
38 | |||
39 | |||
40 | if __name__ == '__main__': | ||
41 | if len(sys.argv) == 2 and sys.argv[1] == '--help': | ||
42 | print('''Build a .deb of firejail with custom configure options | ||
43 | |||
44 | usage: | ||
45 | {script} [--fj-src=SRCDIR] [--only-fix-mkdeb] [CONFIGURE_OPTIONS [...]] | ||
46 | |||
47 | --fj-src=SRCDIR: manually specify the location of firejail source tree | ||
48 | as SRCDIR. If not specified, looks in the parent directory | ||
49 | of the directory where this script is located, and then the | ||
50 | current working directory, in that order. | ||
51 | --only-fix-mkdeb: don't run configure or make after modifying mkdeb.sh | ||
52 | CONFIGURE_OPTIONS: arguments for configure | ||
53 | '''.format(script=sys.argv[0])) | ||
54 | sys.exit(0) | ||
55 | else: | ||
56 | # Find the source directory | ||
57 | srcdir=None | ||
58 | args=sys.argv[1:] | ||
59 | for a in args: | ||
60 | if a.startswith('--fj-src='): | ||
61 | args.remove(a) | ||
62 | srcdir=a[9:] | ||
63 | break | ||
64 | if not(srcdir): | ||
65 | # srcdir not manually specified, try to auto-detect | ||
66 | srcdir=os.path.dirname(os.path.abspath(sys.argv[0]+'/..')) | ||
67 | if not(os.path.isfile(srcdir+'/mkdeb.sh')): | ||
68 | # Script is probably installed. Check the cwd. | ||
69 | if os.path.isfile('./mkdeb.sh'): | ||
70 | srcdir=None | ||
71 | else: | ||
72 | print('Error: Could not find the firejail source tree. Exiting.') | ||
73 | sys.exit(1) | ||
74 | sys.exit(run(srcdir, args)) | ||