summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2021-06-15 13:36:34 +0200
committerHelmut Grohne <helmut@subdivi.de>2021-06-15 13:36:34 +0200
commit511c49acc13803d851a4d0d2ef17647e3e2144b4 (patch)
tree66604f5addb56b2502106ed1c764598aeea53d33
parentd8b36aca8725b36411298961aa2494e995426417 (diff)
downloadmdbp-511c49acc13803d851a4d0d2ef17647e3e2144b4.tar.gz
allow passing custom options to pbuilder and sbuild
-rw-r--r--mdbp/common.py10
-rw-r--r--mdbp/pbuilder.py23
-rw-r--r--mdbp/sbuild.py22
3 files changed, 50 insertions, 5 deletions
diff --git a/mdbp/common.py b/mdbp/common.py
index 8b7f8c1..7a528bc 100644
--- a/mdbp/common.py
+++ b/mdbp/common.py
@@ -191,3 +191,13 @@ def clean_dir(directory: pathlib.Path, patterns: typing.List[str]) -> None:
if not any(fnmatch.fnmatchcase(entry.name, pattern)
for pattern in patterns):
entry.unlink()
+
+class AddSpaceSeparatedValues(argparse.Action):
+ """The action extends the destination array with the space-sparated parts
+ of the passed value."""
+ def __call__(self, parser: argparse.ArgumentParser,
+ namespace: argparse.Namespace,
+ values: typing.Union[str, typing.Sequence[typing.Any], None],
+ option_string: typing.Optional[str] = None) -> None:
+ assert isinstance(values, str)
+ getattr(namespace, self.dest).extend(values.split())
diff --git a/mdbp/pbuilder.py b/mdbp/pbuilder.py
index a3eb228..09b6b59 100644
--- a/mdbp/pbuilder.py
+++ b/mdbp/pbuilder.py
@@ -10,12 +10,29 @@ import subprocess
import sys
import tempfile
-from .common import buildjson, clean_dir, compute_env, get_dsc, make_option, \
- profile_option
+from .common import AddSpaceSeparatedValues, buildjson, clean_dir, \
+ compute_env, get_dsc, make_option, profile_option
def main() -> None:
"""Entry point for mdbp-pbuilder backend"""
parser = argparse.ArgumentParser()
+ parser.add_argument(
+ "--pbuilderopt",
+ dest="pbuilderopts",
+ action="append",
+ metavar="OPT",
+ default=[],
+ help="a custom option to be passed down to pbuilder, can be specified "
+ "multiple times and mixed with --pbuilderopts",
+ )
+ parser.add_argument(
+ "--pbuilderopts",
+ action=AddSpaceSeparatedValues,
+ metavar="OPTS",
+ default=[],
+ help="space-separated options to be passed down to pbuilder, can be "
+ "specified multiple times and mixed with --pbuilderopt",
+ )
parser.add_argument("buildjson", type=buildjson)
args = parser.parse_args()
build = args.buildjson
@@ -78,7 +95,7 @@ set -e
runuser -u pbuilder -- lintian %s "${BUILDDIR:-/tmp/buildd}"/*.changes
""" % (shlex.join(apt_get), shlex.join(build["lintian"].get("options", []))))
hook.chmod(0o755)
- cmd.extend(["--hookdir", hookdirn, str(dscpath)])
+ cmd.extend(["--hookdir", hookdirn, *args.pbuilderopts, str(dscpath)])
ret = subprocess.call(cmd, env=compute_env(build),
stdout=None if enablelog
else subprocess.DEVNULL,
diff --git a/mdbp/sbuild.py b/mdbp/sbuild.py
index ba42932..02aa6cf 100644
--- a/mdbp/sbuild.py
+++ b/mdbp/sbuild.py
@@ -10,7 +10,8 @@ import sys
import tempfile
import typing
-from .common import buildjson, clean_dir, compute_env, get_dsc
+from .common import AddSpaceSeparatedValues, buildjson, clean_dir, \
+ compute_env, get_dsc
PerlValue = typing.Union[None, str, typing.List[typing.Any],
typing.Dict[str, typing.Any]]
@@ -43,6 +44,23 @@ def perl_conf(conf: typing.Dict[str, PerlValue]) -> str:
def main() -> None:
"""Entry point for mdbp-sbuild backend"""
parser = argparse.ArgumentParser()
+ parser.add_argument(
+ "--sbuildopt",
+ dest="sbuildopts",
+ action="append",
+ metavar="OPT",
+ default=[],
+ help="a custom option to be passed down to sbuild, can be specified "
+ "multiple times and mixed with --sbuildopts",
+ )
+ parser.add_argument(
+ "--sbuildopts",
+ action=AddSpaceSeparatedValues,
+ metavar="OPTS",
+ default=[],
+ help="space-separated options to be passed down to sbuild, can be "
+ "specified multiple times and mixed with --sbuildopt",
+ )
parser.add_argument("buildjson", type=buildjson)
args = parser.parse_args()
build = args.buildjson
@@ -90,7 +108,7 @@ def main() -> None:
except KeyError:
thing = str(stack.enter_context(get_dsc(build)).absolute())
- ret = subprocess.call(["sbuild", thing],
+ ret = subprocess.call(["sbuild", *args.sbuildopts, thing],
env=dict(SBUILD_CONFIG=sbuildconf.name,
PATH="/usr/bin:/bin"),
cwd=build["output"]["directory"],