Пример #1
0
    def add_root_transfer_to_doc(self):
        """ Adds the list of files of directories to be transferred
            to the DOC
        """
        if self.doc is None:
            self.doc = InstallEngine.get_instance().data_object_cache

        src_path = Dir("/")
        src = Source()
        src.insert_children(src_path)

        dst_path = Dir(INSTALL_TARGET_VAR)
        dst = Destination()
        dst.insert_children(dst_path)

        dot_node = CPIOSpec()
        dot_node.action = CPIOSpec.INSTALL
        dot_node.size = str(dir_size(os.path.join(self.ba_build, "")))
        dot_node.contents = ["."]

        usr_node = CPIOSpec()
        usr_node.action = CPIOSpec.INSTALL
        usr_node.size = str(dir_size(os.path.join(self.pkg_img_path, "usr")))
        usr_node.contents = ["usr"]

        dev_node = CPIOSpec()
        dev_node.action = CPIOSpec.INSTALL
        dev_node.size = str(dir_size(os.path.join(self.pkg_img_path, "dev")))
        dev_node.contents = ["dev"]

        software_node = Software(TRANSFER_ROOT, type="CPIO")
        software_node.insert_children([src, dst, dot_node, usr_node, dev_node])

        self.doc.persistent.insert_children(software_node)

        self.logger.debug(str(self.doc.persistent))
Пример #2
0
    def add_content_list_to_doc(self, content_list):
        src_path = Dir(MEDIA_DIR_VAR)
        src = Source()
        src.insert_children(src_path)

        dst_path = Dir(INSTALL_TARGET_VAR)
        dst = Destination()
        dst.insert_children(dst_path)

        media_install = CPIOSpec()
        media_install.action = CPIOSpec.INSTALL
        media_install.contents = content_list
        total_size_byte = 0
        for content in content_list:
            content_path = os.path.join(self.pkg_img_path, content)
            # only want to calculate the size of files, since directories
            # are traversed and it's files are included in the list.
            if not os.path.isdir(content_path):
                total_size_byte += file_size(content_path)
        media_install.size = str(total_size_byte)

        media_soft_node = Software(TRANSFER_MEDIA, type="CPIO")
        media_soft_node.insert_children([src, dst, media_install])

        # Add that into the software transfer list.
        self.doc.persistent.insert_children(media_soft_node)

        # call manifest writer to write out the content of
        # the transfer manifest
        manifest_out = os.path.join(self.pkg_img_path, TRANSFER_MANIFEST_NAME)
        xslt_name = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                 "xslt", "doc2_media_transfer.xslt")
        manifest_writer = ManifestWriter("manifest-writer",
                                         manifest_out,
                                         xslt_file=xslt_name)
        manifest_writer.write(self.doc)
Пример #3
0
    def create_misc_archive(self):
        """ class method to create the /mnt/misc file system archive
        """
        os.chdir(self.pkg_img_path)

        self.logger.info("Generating /mnt/misc file system archive")

        os.mkdir("miscdirs")
        shutil.move("opt", "miscdirs")
        shutil.move("etc", "miscdirs")
        shutil.move("var", "miscdirs")

        # add Software node to install items from /mnt/misc

        src_path = Dir("/mnt/misc")
        src = Source()
        src.insert_children(src_path)

        dst_path = Dir(INSTALL_TARGET_VAR)
        dst = Destination()
        dst.insert_children(dst_path)

        tr_install_misc = CPIOSpec()
        tr_install_misc.action = CPIOSpec.INSTALL
        tr_install_misc.contents = ["."]
        tr_install_misc.size = str(
            dir_size(os.path.join(self.pkg_img_path, "miscdirs")))

        misc_software_node = Software(TRANSFER_MISC, type="CPIO")
        misc_software_node.insert_children([src, dst, tr_install_misc])
        self.doc.persistent.insert_children(misc_software_node)

        cmd = [
            cli.MKISOFS, "-o", "solarismisc.zlib", "-N", "-l", "-R", "-U",
            "-allow-multidot", "-no-iso-translate", "-quiet", "-cache-inodes",
            "-d", "-D", "-V", "\"compress\"", "miscdirs"
        ]
        run(cmd)

        self.logger.info("Compressing /mnt/misc file system archive " +
                         "using: " + self.compression_type)

        cmd = [
            cli.LOFIADM, "-C", self.compression_type,
            os.path.join(self.pkg_img_path, "solarismisc.zlib")
        ]
        p = run(cmd, check_result=Popen.ANY)
        if p.returncode != 0:
            if "invalid algorithm name" in p.stderr:
                raise RuntimeError("Invalid compression algorithm " +
                                   "specified for /mnt/misc archive: " +
                                   self.compression_type)
            else:
                raise RuntimeError("Compression of /mnt/misc file system " +
                                   "failed:  " + os.strerror(p.returncode))

        # the removal of /usr must be deferred to until solarismisc.zlib has
        # been created because the contents of solarismisc.zlib actually come
        # from /usr
        shutil.rmtree(os.path.join(self.pkg_img_path, "miscdirs"),
                      ignore_errors=True)
        shutil.rmtree(os.path.join(self.pkg_img_path, "usr"),
                      ignore_errors=True)