aboutsummaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorLibravatar laniakea64 <laniakea64@users.noreply.github.com>2017-04-09 10:19:17 -0400
committerLibravatar laniakea64 <laniakea64@users.noreply.github.com>2017-04-09 10:19:17 -0400
commitaf4f18f178774aa75a7185285857b0ac09d0ab09 (patch)
tree9ff1335db74ba727d76ebdb8100f546169d7765d /contrib
parentDoc update after merging #1198 (diff)
downloadfirejail-af4f18f178774aa75a7185285857b0ac09d0ab09.tar.gz
firejail-af4f18f178774aa75a7185285857b0ac09d0ab09.tar.zst
firejail-af4f18f178774aa75a7185285857b0ac09d0ab09.zip
Add a script to build a .deb with custom configure options
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/fj-mkdeb.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/contrib/fj-mkdeb.py b/contrib/fj-mkdeb.py
new file mode 100755
index 000000000..8027daa5b
--- /dev/null
+++ b/contrib/fj-mkdeb.py
@@ -0,0 +1,51 @@
1#!/usr/bin/env python3
2
3# This script is automate the workaround for https://github.com/netblue30/firejail/issues/772
4
5import os, re, shlex, subprocess, sys
6
7def run(srcdir, args):
8 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
40if __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
44usage: {script} [--only-fix-mkdeb] [CONFIGURE_OPTIONS [...]]
45
46 --only-fix-mkdeb: don't run configure or make after modifying mkdeb.sh
47 CONFIGURE_OPTIONS: arguments for configure
48'''.format(script=sys.argv[0]))
49 sys.exit(0)
50 else:
51 sys.exit(run(os.path.dirname(os.path.abspath(sys.argv[0]+'/..')), sys.argv[1:]))