Skip to content

Commit

Permalink
Merge pull request #5154 from kmk3/build-clean-up-dist
Browse files Browse the repository at this point in the history
mkdeb.sh.in: pass remaining arguments to ./configure
  • Loading branch information
netblue30 authored May 30, 2022
2 parents 61bb616 + 9a0fbbd commit 7ab6c49
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ build_apparmor:
script:
- apt-get update -qq
- DEBIAN_FRONTEND=noninteractive apt-get install -y -qq build-essential lintian libapparmor-dev pkg-config gawk
- ./configure --prefix=/usr --enable-apparmor && make deb-apparmor && dpkg -i firejail*.deb
- ./configure && make deb-apparmor && dpkg -i firejail*.deb
- command -V firejail && firejail --version
- firejail --version | grep -F 'AppArmor support is enabled'

Expand Down
2 changes: 1 addition & 1 deletion Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ deb: dist
./mkdeb.sh

deb-apparmor: dist
./mkdeb.sh -apparmor
./mkdeb.sh -apparmor --enable-apparmor

test-compile: dist
cd test/compile; ./compile.sh $(NAME)-$(VERSION)
Expand Down
38 changes: 16 additions & 22 deletions contrib/fj-mkdeb.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
# Copyright (C) 2014-2022 Firejail Authors
# License GPL v2

# This script automates the workaround for https://github.com/netblue30/firejail/issues/772
# This script automates the creation of a .deb package. It was originally
# created to work around https://github.com/netblue30/firejail/issues/772

import os, shlex, subprocess, sys
import os, subprocess, sys


def run(srcdir, args):
Expand All @@ -15,49 +16,42 @@ def run(srcdir, args):
print('Error: Not a firejail source tree? Exiting.')
return 1

dry_run = False
escaped_args = []
# We need to modify the list as we go. So be sure to copy the list to be iterated!
# Ignore unsupported arguments.
for a in args[:]:
if a.startswith('--prefix'):
# prefix should ALWAYS be /usr here. Discard user-set values
args.remove(a)
elif a == '--only-fix-mkdeb':
# for us, not configure
dry_run = True
args.remove(a)
else:
escaped_args.append(shlex.quote(a))

# Remove generated files.
distclean = subprocess.call(['make', 'distclean'])
if distclean != 0:
return distclean

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

# Fix up dynamically-generated mkdeb.sh to include custom configure options.
with open('mkdeb.sh', 'rb') as f:
sh = str(f.read(), 'utf_8')
with open('mkdeb.sh', 'wb') as f:
f.write(bytes(sh.replace('./configure $CONFIG_ARGS',
'./configure $CONFIG_ARGS ' + (' '.join(escaped_args))), 'utf_8'))

if dry_run: return 0
# Create the dist file used by mkdeb.sh.
make_dist = subprocess.call(['make', 'dist'])
if make_dist != 0:
return make_dist

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


if __name__ == '__main__':
if len(sys.argv) == 2 and sys.argv[1] == '--help':
print('''Build a .deb of firejail with custom configure options
usage:
{script} [--fj-src=SRCDIR] [--only-fix-mkdeb] [CONFIGURE_OPTIONS [...]]
{script} [--fj-src=SRCDIR] [CONFIGURE_OPTIONS [...]]
--fj-src=SRCDIR: manually specify the location of firejail source tree
as SRCDIR. If not specified, looks in the parent directory
of the directory where this script is located, and then the
current working directory, in that order.
--only-fix-mkdeb: don't run configure or make after modifying mkdeb.sh
CONFIGURE_OPTIONS: arguments for configure
'''.format(script=sys.argv[0]))
sys.exit(0)
Expand Down
14 changes: 2 additions & 12 deletions mkdeb.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,10 @@
set -e
NAME=@PACKAGE_NAME@
VERSION=@PACKAGE_VERSION@
PACKAGE_TARNAME=@PACKAGE_TARNAME@
HAVE_APPARMOR=@HAVE_APPARMOR@
HAVE_SELINUX=@HAVE_SELINUX@
EXTRA_VERSION=$1

CONFIG_ARGS="--prefix=/usr"
if [ -n "$HAVE_APPARMOR" ]; then
CONFIG_ARGS="$CONFIG_ARGS --enable-apparmor"
fi
if [ -n "$HAVE_SELINUX" ]; then
CONFIG_ARGS="$CONFIG_ARGS --enable-selinux"
fi
test "$#" -gt 0 && shift

TOP="$PWD"
CODE_ARCHIVE="$NAME-$VERSION.tar.xz"
CODE_DIR="$NAME-$VERSION"
INSTALL_DIR="${INSTALL_DIR}${CODE_DIR}/debian"
Expand All @@ -38,7 +28,7 @@ echo "*****************************************"
tar -xJvf "$CODE_ARCHIVE"
#mkdir -p "$INSTALL_DIR"
cd "$CODE_DIR"
./configure $CONFIG_ARGS
./configure --prefix=/usr "$@"
make -j2
mkdir debian
DESTDIR=debian make install-strip
Expand Down

0 comments on commit 7ab6c49

Please sign in to comment.