Skip to content

Commit

Permalink
feat: Add support for mmdebstrap's --format option
Browse files Browse the repository at this point in the history
Bug: #4
Signed-off-by: Benjamin Drung <[email protected]>
  • Loading branch information
bdrung committed Nov 6, 2022
1 parent 0c337c5 commit 4e0dc37
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
10 changes: 10 additions & 0 deletions bdebstrap
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ MMDEBSTRAP_OPTS = {
"customize-hooks": list,
"dpkgopts": list,
"essential-hooks": list,
"format": str,
"hostname": str,
"install-recommends": bool,
"keyrings": list,
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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."
)
Expand Down Expand Up @@ -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:
Expand Down
11 changes: 10 additions & 1 deletion bdebstrap.1.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
date: 2020-05-26
date: 2022-11-06
footer: bdebstrap
header: "bdebstrap's Manual"
layout: page
Expand All @@ -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*]
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def test_no_args(self):
"env": {},
"essential_hook": None,
"force": False,
"format": None,
"hostname": None,
"install_recommends": False,
"keyring": None,
Expand Down Expand Up @@ -296,6 +297,8 @@ def test_config_and_arguments(self):
"standard",
"--mode",
"root",
"--format",
"tar",
"--aptopt",
'Apt::Install-Recommends "0"',
"--keyring",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions tests/test_mmdebstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit 4e0dc37

Please sign in to comment.