Skip to content

Commit 9a0fbbd

Browse files
committed
mkdeb.sh.in: pass remaining arguments to ./configure
Currently, mkdeb.sh (which is used to make a .deb package) runs ./configure with hardcoded options (some of which are automatically detected based on configure-time variables). To work around the hardcoding, contrib/fj-mkdeb.py is used to add additional options by rewriting the actual call to ./configure on mkdeb.sh. For example, the following invocation adds --disable-firetunnel to mkdeb.sh: $ ./configure && ./contrib/fj-mkdeb.py --disable-firetunnel To avoid depending on another script and to avoid re-generating mkdeb.sh, just let the latter pass the remaining arguments (the first one is an optional package filename suffix) to ./configure directly. Example: $ make distclean && ./configure && make dist && ./mkdeb.sh "" --disable-firetunnel Additionally, change contrib/fj-mkdeb.py to do roughly the same as the above example, by simply forwarding the arguments that it receives to ./mkdeb.sh (which then forwards them to ./configure). Also, remove the --only-fix-mkdeb option, since the script does not change mkdeb.sh anymore. With these changes, the script's usage (other than when using --only-fix-mkdeb) should remain the same. Note: To clean the generated files and then make a .deb package using the default configuration, the invocation is still the same: $ make distclean && ./configure && make deb Note2: Running ./configure in the above examples is only needed for generating Makefile/mkdeb.sh from Makefile.in/mkdeb.sh.in after running distclean, so that running `make` / `./mkdeb.sh` afterwards works. Should fully fix #772. Relates to #1205 #3414 #5148.
1 parent b4d0b24 commit 9a0fbbd

File tree

4 files changed

+18
-38
lines changed

4 files changed

+18
-38
lines changed

.gitlab-ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ build_apparmor:
5454
script:
5555
- apt-get update -qq
5656
- DEBIAN_FRONTEND=noninteractive apt-get install -y -qq build-essential lintian libapparmor-dev pkg-config gawk
57-
- ./configure --prefix=/usr --enable-apparmor && make deb-apparmor && dpkg -i firejail*.deb
57+
- ./configure && make deb-apparmor && dpkg -i firejail*.deb
5858
- command -V firejail && firejail --version
5959
- firejail --version | grep -F 'AppArmor support is enabled'
6060

Makefile.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ deb: dist
222222
./mkdeb.sh
223223

224224
deb-apparmor: dist
225-
./mkdeb.sh -apparmor
225+
./mkdeb.sh -apparmor --enable-apparmor
226226

227227
test-compile: dist
228228
cd test/compile; ./compile.sh $(NAME)-$(VERSION)

contrib/fj-mkdeb.py

+14-26
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
# Copyright (C) 2014-2022 Firejail Authors
44
# License GPL v2
55

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
78

8-
import os, shlex, subprocess, sys
9+
import os, subprocess, sys
910

1011

1112
def run(srcdir, args):
@@ -15,55 +16,42 @@ def run(srcdir, args):
1516
print('Error: Not a firejail source tree? Exiting.')
1617
return 1
1718

18-
dry_run = False
19-
escaped_args = []
20-
# We need to modify the list as we go. So be sure to copy the list to be iterated!
19+
# Ignore unsupported arguments.
2120
for a in args[:]:
2221
if a.startswith('--prefix'):
2322
# prefix should ALWAYS be /usr here. Discard user-set values
2423
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))
3124

3225
# Remove generated files.
33-
if not dry_run:
34-
distclean = subprocess.call(['make', 'distclean'])
35-
if distclean != 0:
36-
return distclean
26+
distclean = subprocess.call(['make', 'distclean'])
27+
if distclean != 0:
28+
return distclean
3729

3830
# Run configure to generate mkdeb.sh.
3931
first_config = subprocess.call(['./configure', '--prefix=/usr'] + args)
4032
if first_config != 0:
4133
return first_config
4234

43-
# Fix up dynamically-generated mkdeb.sh to include custom configure options.
44-
with open('mkdeb.sh', 'rb') as f:
45-
sh = str(f.read(), 'utf_8')
46-
with open('mkdeb.sh', 'wb') as f:
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
35+
# Create the dist file used by mkdeb.sh.
36+
make_dist = subprocess.call(['make', 'dist'])
37+
if make_dist != 0:
38+
return make_dist
5139

52-
return subprocess.call(['make', 'deb'])
40+
# Run mkdeb.sh with the custom configure options.
41+
return subprocess.call(['./mkdeb.sh'] + args)
5342

5443

5544
if __name__ == '__main__':
5645
if len(sys.argv) == 2 and sys.argv[1] == '--help':
5746
print('''Build a .deb of firejail with custom configure options
5847
5948
usage:
60-
{script} [--fj-src=SRCDIR] [--only-fix-mkdeb] [CONFIGURE_OPTIONS [...]]
49+
{script} [--fj-src=SRCDIR] [CONFIGURE_OPTIONS [...]]
6150
6251
--fj-src=SRCDIR: manually specify the location of firejail source tree
6352
as SRCDIR. If not specified, looks in the parent directory
6453
of the directory where this script is located, and then the
6554
current working directory, in that order.
66-
--only-fix-mkdeb: don't run configure or make after modifying mkdeb.sh
6755
CONFIGURE_OPTIONS: arguments for configure
6856
'''.format(script=sys.argv[0]))
6957
sys.exit(0)

mkdeb.sh.in

+2-10
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,9 @@
99
set -e
1010
NAME=@PACKAGE_NAME@
1111
VERSION=@PACKAGE_VERSION@
12-
HAVE_APPARMOR=@HAVE_APPARMOR@
13-
HAVE_SELINUX=@HAVE_SELINUX@
1412
EXTRA_VERSION=$1
1513

16-
CONFIG_ARGS="--prefix=/usr"
17-
if [ -n "$HAVE_APPARMOR" ]; then
18-
CONFIG_ARGS="$CONFIG_ARGS --enable-apparmor"
19-
fi
20-
if [ -n "$HAVE_SELINUX" ]; then
21-
CONFIG_ARGS="$CONFIG_ARGS --enable-selinux"
22-
fi
14+
test "$#" -gt 0 && shift
2315

2416
CODE_ARCHIVE="$NAME-$VERSION.tar.xz"
2517
CODE_DIR="$NAME-$VERSION"
@@ -36,7 +28,7 @@ echo "*****************************************"
3628
tar -xJvf "$CODE_ARCHIVE"
3729
#mkdir -p "$INSTALL_DIR"
3830
cd "$CODE_DIR"
39-
./configure $CONFIG_ARGS
31+
./configure --prefix=/usr "$@"
4032
make -j2
4133
mkdir debian
4234
DESTDIR=debian make install-strip

0 commit comments

Comments
 (0)