aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar laniakea64 <laniakea64@users.noreply.github.com>2020-09-03 11:48:03 -0400
committerLibravatar laniakea64 <laniakea64@users.noreply.github.com>2020-09-03 11:48:03 -0400
commitce3d68c0d19a3b10d44cae43e8e98fe5f37ff811 (patch)
treecd98669d7721ad987da29dbd371e7434230eebbd
parentvarious (diff)
downloadfirejail-ce3d68c0d19a3b10d44cae43e8e98fe5f37ff811.tar.gz
firejail-ce3d68c0d19a3b10d44cae43e8e98fe5f37ff811.tar.zst
firejail-ce3d68c0d19a3b10d44cae43e8e98fe5f37ff811.zip
Update fj-mkdeb.py
-rwxr-xr-xcontrib/fj-mkdeb.py30
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
8import os, re, shlex, subprocess, sys 8import os, shlex, subprocess, sys
9 9
10 10
11def run(srcdir, args): 11def 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
47if __name__ == '__main__': 49if __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(