예제 #1
0
def buildiso(mount, winnt_sif, iso_out, bootstrap, tmp_dir=None):
    """Builds an ISO file containing all our modifications."""
    tempdir = tempfile.mkdtemp(dir=tmp_dir)

    # Copy all files to our temporary directory as mounted iso files are
    # read-only and we need lowercase (aka case-insensitive) filepaths.
    copytreelower(mount, tempdir)

    # Copy the boot image.
    shutil.copy(os.path.join(VMCLOAK_ROOT, 'data', 'boot.img'), tempdir)

    dst_winnt = os.path.join(tempdir, 'i386', 'winnt.sif')

    # Merge the existing winnt.sif with our changes.
    mode, winnt = ini_read(dst_winnt)
    ini_merge(winnt, winnt_sif, overwrite=True)

    # There are a couple of optional values that should be set if they have
    # not already been set.
    winnt_opt_sif = os.path.join(VMCLOAK_ROOT, 'data', 'winnt-opt.sif')
    ini_merge(winnt, winnt_opt_sif, overwrite=False)

    ini_write(dst_winnt, mode, winnt)

    osdir = os.path.join(tempdir, '$oem$', '$1')
    os.makedirs(os.path.join(osdir, 'vmcloak'))

    data_bootstrap = os.path.join(VMCLOAK_ROOT, 'data', 'bootstrap')
    for fname in os.listdir(data_bootstrap):
        shutil.copy(os.path.join(data_bootstrap, fname),
                    os.path.join(osdir, 'vmcloak', fname))

    copytreeinto(bootstrap, osdir)

    isocreate = get_path('genisoimage')
    if not isocreate:
        log.error('Either genisoimage or mkisofs is required!')
        shutil.rmtree(tempdir)
        return False

    try:
        args = [
            isocreate, '-quiet', '-b', 'boot.img', '-no-emul-boot',
            '-boot-load-seg', '1984', '-boot-load-size', '4',
            '-iso-level', '2', '-J', '-l', '-D', '-N', '-joliet-long',
            '-relaxed-filenames', '-o', iso_out, tempdir
        ]

        subprocess.check_call(args)
    except subprocess.CalledProcessError as e:
        log.error('Error creating ISO file: %s', e)
        shutil.rmtree(tempdir)
        return False

    shutil.rmtree(tempdir)
    return True
예제 #2
0
파일: winxp.py 프로젝트: CaineQT/vmcloak
    def isofiles(self, outdir, tmp_dir=None):
        dst_winnt = os.path.join(outdir, 'i386', 'winnt.sif')

        winnt_sif = self._winnt_sif()

        # Merge the existing winnt.sif with our changes.
        mode, winnt = ini_read(dst_winnt)
        ini_merge(winnt, winnt_sif, overwrite=True)

        os.remove(winnt_sif)

        # There are a couple of optional values that should be set if they have
        # not already been set.
        winnt_opt_sif = os.path.join(self.path, 'winnt-opt.sif')
        ini_merge(winnt, winnt_opt_sif, overwrite=False)

        ini_write(dst_winnt, mode, winnt)
예제 #3
0
파일: winxp.py 프로젝트: xee5ch/vmcloak
    def isofiles(self, outdir, tmp_dir=None):
        dst_winnt = os.path.join(outdir, "i386", "winnt.sif")

        winnt_sif = self._winnt_sif()

        # Merge the existing winnt.sif with our changes.
        mode, winnt = ini_read(dst_winnt)
        ini_merge(winnt, winnt_sif, overwrite=True)

        os.remove(winnt_sif)

        # There are a couple of optional values that should be set if they have
        # not already been set.
        winnt_opt_sif = os.path.join(self.path, "winnt-opt.sif")
        ini_merge(winnt, winnt_opt_sif, overwrite=False)

        ini_write(dst_winnt, mode, winnt)
예제 #4
0
파일: abstract.py 프로젝트: HarryR/vmcloak
    def isofiles(self, outdir, tmp_dir=None):
        products = []

        product_ini = os.path.join(outdir, "sources", "product.ini")
        mode, conf = ini_read(product_ini)

        for line in conf.get("BuildInfo", []):
            if "=" not in line:
                continue

            key, value = line.split("=", 1)
            if key != "staged":
                continue

            for product in value.split(","):
                products.append(product.lower())

            break

        for preference in self.preference:
            if preference in products:
                product = preference
                break
        else:
            if products:
                product = products[0]
            else:
                product = self.preference[0]

        if self.product and self.product.lower() not in self.preference:
            log.error(
                "The product version of %s that was specified on the "
                "command-line is not known by us, ignoring it.", self.name
            )
            self.product = None

        with open(os.path.join(outdir, "autounattend.xml"), "wb") as f:
            f.write(self._autounattend_xml(self.product or product))
예제 #5
0
    def isofiles(self, outdir, tmp_dir=None):
        products = []

        product_ini = os.path.join(outdir, "sources", "product.ini")
        mode, conf = ini_read(product_ini)

        for line in conf.get("BuildInfo", []):
            if "=" not in line:
                continue

            key, value = line.split("=", 1)
            if key != "staged":
                continue

            for product in value.split(","):
                products.append(product.lower())

            break

        for preference in self.preference:
            if preference in products:
                product = preference
                break
        else:
            if products:
                product = products[0]
            else:
                product = self.preference[0]

        if self.product and self.product.lower() not in self.preference:
            log.error(
                "The product version of %s that was specified on the "
                "command-line is not known by us, ignoring it.", self.name
            )
            self.product = None

        with open(os.path.join(outdir, "autounattend.xml"), "wb") as f:
            f.write(self._autounattend_xml(self.product or product))