def test_get_archive_suffixes(self): """Test get archive suffixes""" archive_suffixes = archive.get_archive_suffixes() archive_suffixes.sort() self.assertEqual(archive_suffixes, ['.tar', '.tar.bz', '.tar.bz2', '.tar.gz', '.tar.lzo', '.taz', '.tbz', '.tbz2', '.tgz', '.tzo', '.zip'])
def __init__(self, createopts = None, pkgmgr = None): """Initialize an ImageCreator instance. ks -- a pykickstart.KickstartParser instance; this instance will be used to drive the install by e.g. providing the list of packages to be installed, the system configuration and %post scripts name -- a name for the image; used for e.g. image filenames or filesystem labels """ self.pkgmgr = pkgmgr self.distro_name = "" self.__builddir = None self.__bindmounts = [] self.ks = None self.name = "target" self.tmpdir = "/var/tmp/mic" self.cachedir = "/var/tmp/mic/cache" self.workdir = "/var/tmp/mic/build" self.destdir = "." self.installerfw_prefix = "INSTALLERFW_" self.target_arch = "noarch" self.strict_mode = False self._local_pkgs_path = None self.pack_to = None self.repourl = {} self.multiple_partitions = False # If the kernel is save to the destdir when copy_kernel cmd is called. self._need_copy_kernel = False # setup tmpfs tmpdir when enabletmpfs is True self.enabletmpfs = False if createopts: # Mapping table for variables that have different names. optmap = {"pkgmgr" : "pkgmgr_name", "arch" : "target_arch", "local_pkgs_path" : "_local_pkgs_path", "copy_kernel" : "_need_copy_kernel", "strict_mode" : "strict_mode", } # update setting from createopts for key in createopts.keys(): if key in optmap: option = optmap[key] else: option = key setattr(self, option, createopts[key]) self.destdir = os.path.abspath(os.path.expanduser(self.destdir)) if self.pack_to: if '@NAME@' in self.pack_to: self.pack_to = self.pack_to.replace('@NAME@', self.name) (tar, ext) = os.path.splitext(self.pack_to) if ext in (".gz", ".bz2", ".lzo", ".bz") and tar.endswith(".tar"): ext = ".tar" + ext if ext not in get_archive_suffixes(): self.pack_to += ".tar" self._dep_checks = ["ls", "bash", "cp", "echo", "modprobe"] # Output image file names self.outimage = [] # Output info related with manifest self.image_files = {} # A flag to generate checksum self._genchecksum = False self._alt_initrd_name = None self._recording_pkgs = [] # available size in root fs, init to 0 self._root_fs_avail = 0 # Name of the disk image file that is created. self._img_name = None self.image_format = None # Save qemu emulator file name in order to clean up it finally self.qemu_emulator = None # No ks provided when called by convertor, so skip the dependency check if self.ks: # If we have btrfs partition we need to check necessary tools for part in self.ks.handler.partition.partitions: if part.fstype and part.fstype == "btrfs": self._dep_checks.append("mkfs.btrfs") break if len(self.ks.handler.partition.partitions) > 1: self.multiple_partitions = True if self.target_arch and self.target_arch.startswith("arm"): for dep in self._dep_checks: if dep == "extlinux": self._dep_checks.remove(dep) if not os.path.exists("/usr/bin/qemu-arm") or \ not misc.is_statically_linked("/usr/bin/qemu-arm"): self._dep_checks.append("qemu-arm-static") if os.path.exists("/proc/sys/vm/vdso_enabled"): vdso_fh = open("/proc/sys/vm/vdso_enabled","r") vdso_value = vdso_fh.read().strip() vdso_fh.close() if (int)(vdso_value) == 1: msger.warning("vdso is enabled on your host, which might " "cause problems with arm emulations.\n" "\tYou can disable vdso with following command before " "starting image build:\n" "\techo 0 | sudo tee /proc/sys/vm/vdso_enabled") # make sure the specified tmpdir and cachedir exist if not os.path.exists(self.tmpdir): os.makedirs(self.tmpdir) if not os.path.exists(self.cachedir): os.makedirs(self.cachedir)