Esempio n. 1
0
 def test_debian_example(self):
     """Test Mmdebstrap with Debian unstable config."""
     mmdebstrap = Mmdebstrap(
         Config(
             mmdebstrap={
                 "architectures": ["i386"],
                 "install-recommends": True,
                 "keyrings": ["/usr/share/keyrings/debian-archive-keyring.gpg"],
                 "mode": "unshare",
                 "suite": "unstable",
                 "target": "example.tar.xz",
                 "variant": "minbase",
             }
         )
     )
     self.assertEqual(
         mmdebstrap.construct_parameters("/output"),
         [
             "mmdebstrap",
             "--variant=minbase",
             "--mode=unshare",
             "--keyring=/usr/share/keyrings/debian-archive-keyring.gpg",
             "--architectures=i386",
             '--essential-hook=mkdir -p "$1/tmp/bdebstrap-output"',
             '--aptopt=Apt::Install-Recommends "true"',
             "--customize-hook=chroot \"$1\" dpkg-query -f='${Package}\\t${Version}\\n' -W "
             '> "$1/tmp/bdebstrap-output/manifest"',
             '--customize-hook=sync-out "/tmp/bdebstrap-output" "/output"',
             '--customize-hook=rm -rf "$1/tmp/bdebstrap-output"',
             "unstable",
             "example.tar.xz",
         ],
     )
Esempio n. 2
0
 def test_hooks(self):
     """Test Mmdebstrap with custom hooks."""
     mmdebstrap = Mmdebstrap(
         Config(
             mmdebstrap={
                 "cleanup-hooks": ['rm -f "$0/etc/udev/rules.d/70-persistent-net.rules"'],
                 "customize-hooks": [
                     'chroot "$0" update-alternatives --set editor /usr/bin/vim.basic'
                 ],
                 "essential-hooks": ["copy-in /etc/bash.bashrc /etc"],
                 "hostname": "example",
                 "setup-hooks": [],
                 "suite": "buster",
                 "target": "buster.tar.xz",
             }
         )
     )
     self.assertEqual(
         mmdebstrap.construct_parameters("/output"),
         [
             "mmdebstrap",
             '--essential-hook=mkdir -p "$1/tmp/bdebstrap-output"',
             "--essential-hook=copy-in /etc/bash.bashrc /etc",
             '--customize-hook=chroot "$0" update-alternatives --set editor /usr/bin/vim.basic',
             '--customize-hook=rm -f "$0/etc/udev/rules.d/70-persistent-net.rules"',
             '--customize-hook=echo "example" > "$1/etc/hostname"',
             "--customize-hook=chroot \"$1\" dpkg-query -f='${Package}\\t${Version}\\n' -W "
             '> "$1/tmp/bdebstrap-output/manifest"',
             '--customize-hook=sync-out "/tmp/bdebstrap-output" "/output"',
             '--customize-hook=rm -rf "$1/tmp/bdebstrap-output"',
             "buster",
             "buster.tar.xz",
         ],
     )
Esempio n. 3
0
 def test_log_level_debug(self):
     """Test Mmdebstrap with log level debug."""
     logging.getLogger(__script_name__).setLevel(logging.DEBUG)
     mmdebstrap = Mmdebstrap(Config())
     self.assertEqual(
         mmdebstrap.construct_parameters("/output")[0:2], ["mmdebstrap", "--debug"]
     )
Esempio n. 4
0
 def test_extra_opts(self):
     """Test Mmdebstrap with extra options."""
     mmdebstrap = Mmdebstrap(
         Config(
             mmdebstrap={
                 "aptopts": ['Acquire::http { Proxy "http://proxy:3128/"; }'],
                 "components": ["main", "non-free", "contrib"],
                 "dpkgopts": ["force-confdef", "force-confold"],
                 "packages": ["bash-completions", "vim"],
                 "suite": "unstable",
                 "target": "example.tar.xz",
             },
         )
     )
     self.assertEqual(
         mmdebstrap.construct_parameters("/output"),
         [
             "mmdebstrap",
             '--aptopt=Acquire::http { Proxy "http://proxy:3128/"; }',
             "--dpkgopt=force-confdef",
             "--dpkgopt=force-confold",
             "--include=bash-completions,vim",
             "--components=main,non-free,contrib",
             '--essential-hook=mkdir -p "$1/tmp/bdebstrap-output"',
             "--customize-hook=chroot \"$1\" dpkg-query -f='${Package}\\t${Version}\\n' -W "
             '> "$1/tmp/bdebstrap-output/manifest"',
             '--customize-hook=sync-out "/tmp/bdebstrap-output" "/output"',
             '--customize-hook=rm -rf "$1/tmp/bdebstrap-output"',
             "unstable",
             "example.tar.xz",
         ],
     )
Esempio n. 5
0
 def test_log_level_warning(self):
     """Test Mmdebstrap with log level warning."""
     logging.getLogger(__script_name__).setLevel(logging.WARNING)
     mmdebstrap = Mmdebstrap(Config())
     self.assertEqual(
         mmdebstrap.construct_parameters("/output")[0:2],
         ["mmdebstrap", '--essential-hook=mkdir -p "$1/tmp/bdebstrap-output"'],
     )
Esempio n. 6
0
 def test_dry_run(self):
     """Test Mmdebstrap with dry run set."""
     mmdebstrap = Mmdebstrap(
         Config(mmdebstrap={"suite": "unstable", "target": "example.tar.xz"})
     )
     self.assertEqual(
         mmdebstrap.construct_parameters("/output", True),
         [
             "mmdebstrap",
             "--simulate",
             '--essential-hook=mkdir -p "$1/tmp/bdebstrap-output"',
             "--customize-hook=chroot \"$1\" dpkg-query -f='${Package}\\t${Version}\\n' -W "
             '> "$1/tmp/bdebstrap-output/manifest"',
             '--customize-hook=sync-out "/tmp/bdebstrap-output" "/output"',
             '--customize-hook=rm -rf "$1/tmp/bdebstrap-output"',
             "unstable",
             "example.tar.xz",
         ],
     )
Esempio n. 7
0
 def test_log_level_error(self):
     """Test Mmdebstrap with log level error."""
     logging.getLogger(__script_name__).setLevel(logging.ERROR)
     mmdebstrap = Mmdebstrap(Config())
     self.assertEqual(mmdebstrap.construct_parameters("/output")[0:2], ["mmdebstrap", "-q"])