From 4e0dc37980fe730856b1ebd9c073d4b99f543482 Mon Sep 17 00:00:00 2001 From: Benjamin Drung Date: Sun, 6 Nov 2022 01:21:55 +0100 Subject: [PATCH] feat: Add support for mmdebstrap's --format option Bug: https://github.com/bdrung/bdebstrap/issues/4 Signed-off-by: Benjamin Drung --- bdebstrap | 10 ++++++++++ bdebstrap.1.md | 11 ++++++++++- tests/test_config.py | 4 ++++ tests/test_mmdebstrap.py | 2 ++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/bdebstrap b/bdebstrap index 1b55307..fd1dd75 100755 --- a/bdebstrap +++ b/bdebstrap @@ -50,6 +50,7 @@ MMDEBSTRAP_OPTS = { "customize-hooks": list, "dpkgopts": list, "essential-hooks": list, + "format": str, "hostname": str, "install-recommends": bool, "keyrings": list, @@ -88,6 +89,8 @@ class Mmdebstrap: cmd.append(f"--variant={mmdebstrap['variant']}") if "mode" in mmdebstrap: cmd.append(f"--mode={mmdebstrap['mode']}") + if "format" in mmdebstrap: + cmd.append(f"--format={mmdebstrap['format']}") if "aptopts" in mmdebstrap: cmd += [f"--aptopt={aptopt}" for aptopt in mmdebstrap["aptopts"]] if "keyrings" in mmdebstrap: @@ -301,6 +304,11 @@ def parse_args(args): # pylint: disable=too-many-statements "ownership information different from the current user." ), ) + parser.add_argument( + "--format", + choices=["auto", "directory", "dir", "tar", "squashfs", "sqfs", "ext2", "null"], + help="Choose the output format.", + ) parser.add_argument( "--aptopt", action="append", help="Pass arbitrary options or configuration files to apt." ) @@ -558,6 +566,8 @@ class Config(dict): self._set_mmdebstrap_option("variant", args.variant) if args.mode: self._set_mmdebstrap_option("mode", args.mode) + if args.format: + self._set_mmdebstrap_option("format", args.format) if args.aptopt: self._append_mmdebstrap_option("aptopts", args.aptopt) if args.keyring: diff --git a/bdebstrap.1.md b/bdebstrap.1.md index af5094e..83a0eba 100644 --- a/bdebstrap.1.md +++ b/bdebstrap.1.md @@ -1,5 +1,5 @@ --- -date: 2020-05-26 +date: 2022-11-06 footer: bdebstrap header: "bdebstrap's Manual" layout: page @@ -23,6 +23,7 @@ bdebstrap - YAML config based multi-mirror Debian chroot creation tool [**-f**|**\--force**] [**-t**|**\--tmpdir** *TMPDIR*] [**\--variant** {*extract*,*custom*,*essential*,*apt*,*required*,*minbase*,*buildd*,*important*,*debootstrap*,*-*,*standard*}] [**\--mode** {*auto*,*sudo*,*root*,*unshare*,*fakeroot*,*fakechroot*,*proot*,*chrootless*}] +[**\--format** {*auto*,*directory*,*dir*,*tar*,*squashfs*,*sqfs*,*ext2*,*null*}] [**\--aptopt** *APTOPT*] [**\--keyring** *KEYRING*] [**\--dpkgopt** *DPKGOPT*] [**\--hostname** *HOSTNAME*] [**\--install-recommends**] [**\--packages**|**\--include** *PACKAGES*] [**\--components** *COMPONENTS*] @@ -113,6 +114,9 @@ output directory as *config.yaml*. : Choose how to perform the chroot operation and create a filesystem with ownership information different from the current user. +[**\--format** {*auto*,*directory*,*dir*,*tar*,*squashfs*,*sqfs*,*ext2*,*null*} +: Choose the output format. + **\--aptopt** *APTOPT* : Pass arbitrary options or configuration files to apt. @@ -212,6 +216,11 @@ be specified: : list of arbitrary options or configuration files (string) to dpkg. Additional dpkg options can be specified with **\--dpkgopt**. +**format** +: Choose the output format. It needs to be one of *auto*, *directory*, *dir*, + *tar*, *squashfs*, *sqfs*, *ext2*, *null*. See mmdebstrap(1) for details. + Can be overridden by **\--format**. + **hostname** : String. If specified, write the given *hostname* into */etc/hostname* in the target chroot. This parameter does not exist in **mmdebstrap** and is diff --git a/tests/test_config.py b/tests/test_config.py index a2d8429..3e4f422 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -113,6 +113,7 @@ def test_no_args(self): "env": {}, "essential_hook": None, "force": False, + "format": None, "hostname": None, "install_recommends": False, "keyring": None, @@ -296,6 +297,8 @@ def test_config_and_arguments(self): "standard", "--mode", "root", + "--format", + "tar", "--aptopt", 'Apt::Install-Recommends "0"', "--keyring", @@ -326,6 +329,7 @@ def test_config_and_arguments(self): "architectures": ["i386"], "components": ["main", "non-free"], "dpkgopts": ["force-confdef", "force-confold"], + "format": "tar", "keyrings": [ "/usr/share/keyrings/debian-archive-keyring.gpg", "/usr/share/keyrings", diff --git a/tests/test_mmdebstrap.py b/tests/test_mmdebstrap.py index 41a750d..1463948 100644 --- a/tests/test_mmdebstrap.py +++ b/tests/test_mmdebstrap.py @@ -129,6 +129,7 @@ def test_extra_opts(self): "aptopts": ['Acquire::http { Proxy "http://proxy:3128/"; }'], "components": ["main", "non-free", "contrib"], "dpkgopts": ["force-confdef", "force-confold"], + "format": "tar", "packages": ["bash-completions", "vim"], "suite": "unstable", "target": "example.tar.xz", @@ -139,6 +140,7 @@ def test_extra_opts(self): mmdebstrap.construct_parameters("/output"), [ "mmdebstrap", + "--format=tar", '--aptopt=Acquire::http { Proxy "http://proxy:3128/"; }', "--dpkgopt=force-confdef", "--dpkgopt=force-confold",