def test_prepare_squashfs_base(self):
        self.config["CDIMAGE_SQUASHFS_BASE"] = "1"
        _, image_top, live, data = _check_installable_dirs(self.config)
        squashfs_dir = os.path.join(self.temp_dir, "squashfs")
        status_path = os.path.join(
            squashfs_dir, "var", "lib", "dpkg", "status")
        fake_packages = dedent("""\
            Package: base-files
            Status: install ok installed
            Version: 6.5

            Package: libc6
            Status: install ok installed
            Version: 2.15-1
            Provides: glibc

            """)
        os.makedirs(os.path.dirname(status_path))
        with open(status_path, "w") as status:
            print(fake_packages, end="", file=status)
        os.makedirs(live)
        with open("/dev/null", "w") as devnull:
            subprocess.check_call(
                ["mksquashfs", squashfs_dir,
                 os.path.join(live, "i386.squashfs")],
                stdout=devnull)
        self.capture_logging()
        _prepare_check_installable(self.config)
        self.assertLogEqual([])
        self.assertEqual(
            ["Packages_i386", "Sources"], sorted(os.listdir(data)))
        with open(os.path.join(data, "Packages_i386")) as packages_file:
            self.assertEqual(fake_packages, packages_file.read())
 def test_prepare_no_packages(self):
     _, _, _, data = _check_installable_dirs(self.config)
     self.capture_logging()
     _prepare_check_installable(self.config)
     self.assertLogEqual(["No Packages.gz for warty/i386; not checking"])
     self.assertEqual(["Sources"], os.listdir(data))
     self.assertEqual(0, os.stat(os.path.join(data, "Sources")).st_size)
Beispiel #3
0
    def test_prepare_squashfs_base(self):
        self.config["CDIMAGE_SQUASHFS_BASE"] = "1"
        _, image_top, live, data = _check_installable_dirs(self.config)
        squashfs_dir = os.path.join(self.temp_dir, "squashfs")
        status_path = os.path.join(squashfs_dir, "var", "lib", "dpkg",
                                   "status")
        fake_packages = dedent("""\
            Package: base-files
            Status: install ok installed
            Version: 6.5

            Package: libc6
            Status: install ok installed
            Version: 2.15-1
            Provides: glibc

            """)
        with mkfile(status_path) as status:
            print(fake_packages, end="", file=status)
        os.makedirs(live)
        with open("/dev/null", "w") as devnull:
            subprocess.check_call([
                "mksquashfs", squashfs_dir,
                os.path.join(live, "i386.squashfs")
            ],
                                  stdout=devnull)
        self.capture_logging()
        _prepare_check_installable(self.config)
        self.assertLogEqual([])
        self.assertCountEqual(["Packages_i386", "Sources"], os.listdir(data))
        with open(os.path.join(data, "Packages_i386")) as packages_file:
            self.assertEqual(fake_packages, packages_file.read())
Beispiel #4
0
 def test_prepare_no_packages(self):
     _, _, _, data = _check_installable_dirs(self.config)
     self.capture_logging()
     _prepare_check_installable(self.config)
     self.assertLogEqual(["No Packages.gz for warty/i386; not checking"])
     self.assertEqual(["Sources"], os.listdir(data))
     self.assertEqual(0, os.stat(os.path.join(data, "Sources")).st_size)
Beispiel #5
0
 def test_prepare_with_packages(self):
     _, image_top, _, data = _check_installable_dirs(self.config)
     packages_gz = os.path.join(image_top, "warty-i386", "CD1", "dists",
                                "warty", "main", "binary-i386",
                                "Packages.gz")
     os.makedirs(os.path.dirname(packages_gz))
     packages_gz_file = gzip.open(packages_gz, "wb")
     try:
         packages_gz_file.write(b"Package: foo\n\n")
     finally:
         packages_gz_file.close()
     self.capture_logging()
     _prepare_check_installable(self.config)
     self.assertLogEqual([])
     self.assertCountEqual(["Packages_i386", "Sources"], os.listdir(data))
     with open(os.path.join(data, "Packages_i386")) as packages_file:
         self.assertEqual("Package: foo\n\n", packages_file.read())
 def test_prepare_with_packages(self):
     _, image_top, _, data = _check_installable_dirs(self.config)
     packages_gz = os.path.join(
         image_top, "warty-i386", "CD1", "dists", "warty", "main",
         "binary-i386", "Packages.gz")
     os.makedirs(os.path.dirname(packages_gz))
     packages_gz_file = gzip.open(packages_gz, "wb")
     try:
         packages_gz_file.write("Package: foo\n\n")
     finally:
         packages_gz_file.close()
     self.capture_logging()
     _prepare_check_installable(self.config)
     self.assertLogEqual([])
     self.assertEqual(
         ["Packages_i386", "Sources"], sorted(os.listdir(data)))
     with open(os.path.join(data, "Packages_i386")) as packages_file:
         self.assertEqual("Package: foo\n\n", packages_file.read())