def runthread(self): logger.logV( self.tn, logger.I, _("Copying preseed files to the ISO tree")) for i in fsutil.listdir(configutils.getValue(configs[configutils.preseed])): logger.logVV(self.tn, logger.I, _("Copying") + " " + i + " " + _("to the ISO tree")) copyFile(i, isotreel + "preseed/", self.tn)
def runthread(self): # Edit the casper.conf # Strangely enough, casper uses the "quiet" flag if the build system is either Debian or Ubuntu if config.VStatus is False: logger.logI(self.tn, logger.I, _("Editing casper and LSB configuration files")) logger.logV(self.tn, logger.I, _("Editing casper.conf")) buildsys = "Ubuntu" if configutils.parseBoolean( configutils.getValue( configs[configutils.casperquiet])) is False: buildsys = "" unionfs = configutils.getValue(configs[configutils.unionfs]) if unionfs == "overlayfs" and aptutil.compVersions( aptutil.getPkgVersion(aptutil.getPkg("casper", aptcache)), "1.272", aptutil.lt): logger.logI(self.tn, logger.W, _("Using DEFAULT instead of overlayfs")) unionfs = "DEFAULT" self.varEditor( tmpsys + "etc/casper.conf", { "USERNAME": configutils.getValue(configs[configutils.username]), "USERFULLNAME": configutils.getValue(configs[configutils.userfullname]), "HOST": configutils.getValue(configs[configutils.host]), "BUILD_SYSTEM": buildsys, "FLAVOUR": configutils.getValue(configs[configutils.flavour]), "UNIONFS": unionfs }) logger.logI(self.tn, logger.I, _("Applying permissions to casper scripts")) # Make sure the casper scripts work cbs = "/usr/share/initramfs-tools/scripts/casper-bottom/" for i in fsutil.listdir(cbs): fsutil.chmod(i, 0o755, self.tn) logger.logV(self.tn, logger.I, _("Editing lsb-release")) self.varEditor( tmpsys + "etc/lsb-release", { "DISTRIB_ID": configutils.getValue(configs[configutils.sysname]), "DISTRIB_RELEASE": configutils.getValue(configs[configutils.sysversion]), "DISTRIB_CODENAME": configutils.getValue(configs[configutils.codename]), "DISTRIB_DESCRIPTION": configutils.getValue(configs[configutils.description]) })
def runthread(self): logger.logI(self.tn, logger.I, _("Starting generation of the ISO image")) # Make a last verification on the SquashFS squashfs.doSFSChecks(isotreel + "casper/filesystem.squashfs", configutils.getValue(configs[configutils.isolevel])) self.setProgress(self.tn, 5) # Generate MD5 checksums logger.logV(self.tn, logger.I, _("Generating MD5 sums")) files = open(isotreel + "md5sum.txt", "w") for x in fsutil.listdir(isotreel, {"recurse": True}): i = re.sub(r"^ *" + isotreel + "/*", "./", x) if not "isolinux" in i and not "md5sum" in i: logger.logVV(self.tn, logger.I, _("Writing MD5 sum of") + " " + i) fmd5 = fsutil.genFinalMD5(i, x) if fmd5 != "" and fmd5 != None: files.write(fmd5) files.close() self.setProgress(self.tn, 15) logger.logI(self.tn, logger.I, _("Generating the ISO")) location = (configutils.getValue(configs[configutils.isodir]) + "/" + configutils.getValue(configs[configutils.isolocation])) patt = re.compile("^ *([0-9]+)\.?[0-9]*%.*$") appnd = "32" if sys.maxsize > 2 ** 32: appnd = "64" os.environ["LD_PRELOAD"] = os.path.split(os.path.realpath(__file__))[0] + "/isatty" + appnd + ".so" isocmd = subprocess.Popen(shlex.split(configutils.getValue(configs[configutils.isogenerator]) + " -o " + location + " " + isogenopts + " -V \"" + configutils.getValue(configs[configutils.label]) + "\" " + isotreel), stderr=subprocess.PIPE, universal_newlines=True) oldprogress = 0 while isocmd.poll() is None: output = isocmd.stderr.readline() match = patt.match(output) if match != None: progress = int(match.group(1)) if progress > oldprogress: # 1.4285714285714286 is just 100 / 70 self.setProgress(self.tn, 15 + int(utilities.floatDivision(progress, 1.4285714285714286))) oldprogress = progress sys.stdout.write(output) sys.stdout.flush() os.environ["LD_PRELOAD"] = "" self.setProgress(self.tn, 85) # Generate the MD5 sum logger.logV(self.tn, logger.I, _("Generating MD5 sum for the ISO")) files = open(location + ".md5", "w") files.write(fsutil.genFinalMD5("./" + configutils.getValue(configs[configutils.isolocation]), location)) files.close()
def runthread(self): # Edit the casper.conf # Strangely enough, casper uses the "quiet" flag if the build system is either Debian or Ubuntu if config.VStatus is False: logger.logI(self.tn, logger.I, _("Editing casper and LSB configuration files")) logger.logV(self.tn, logger.I, _("Editing casper.conf")) buildsys = "Ubuntu" if configutils.parseBoolean(configutils.getValue(configs[configutils.casperquiet])) is False: buildsys = "" unionfs = configutils.getValue(configs[configutils.unionfs]) if unionfs == "overlayfs" and aptutil.compVersions( aptutil.getPkgVersion(aptutil.getPkg("casper", aptcache)), "1.272", aptutil.lt ): logger.logI(self.tn, logger.W, _("Using DEFAULT instead of overlayfs")) unionfs = "DEFAULT" self.varEditor( tmpsys + "etc/casper.conf", { "USERNAME": configutils.getValue(configs[configutils.username]), "USERFULLNAME": configutils.getValue(configs[configutils.userfullname]), "HOST": configutils.getValue(configs[configutils.host]), "BUILD_SYSTEM": buildsys, "FLAVOUR": configutils.getValue(configs[configutils.flavour]), "UNIONFS": unionfs, }, ) logger.logI(self.tn, logger.I, _("Applying permissions to casper scripts")) # Make sure the casper scripts work cbs = "/usr/share/initramfs-tools/scripts/casper-bottom/" for i in fsutil.listdir(cbs): fsutil.chmod(i, 0o755, self.tn) logger.logV(self.tn, logger.I, _("Editing lsb-release")) self.varEditor( tmpsys + "etc/lsb-release", { "DISTRIB_ID": configutils.getValue(configs[configutils.sysname]), "DISTRIB_RELEASE": configutils.getValue(configs[configutils.sysversion]), "DISTRIB_CODENAME": configutils.getValue(configs[configutils.codename]), "DISTRIB_DESCRIPTION": configutils.getValue(configs[configutils.description]), }, )
def run(self): logger.logI(self.tn, _("Starting generation of the ISO image")) # Make a last verification on the SquashFS squashfs.doSFSChecks(isotreel + "casper/filesystem.squashfs", configutils.getValue(configs[configutils.isolevel])) # Generate MD5 checksums logger.logV(self.tn, _("Generating MD5 sums")) files = open(isotreel + "md5sum.txt") for x in fsutil.listdir(isotreel, {"recurse": True}): i = re.sub(r"^ *" + isotreel + ".*", ".", x) if i.find("isotree") == -1 and i.find("md5sum") == -1: logger.logVV(self.tn, _("Writing MD5 sum of") + " " + i) files.write(fsutil.genFinalMD5(i)) files.close() logger.logI(self.tn, _("Generating the ISO")) os.system(configutils.getValue(configs[configutils.isogenerator]) + " " + isogenopts + " -V " + configutils.getValue(configs[configutils.label]) + " -o " + configutils.getValue(configs[configutils.isolocation])) # Generate the MD5 sum logger.logV(self.tn, _("Generating MD5 sum for the ISO")) files = open(configs[configutils.isolocation] + ".md5", "w") files.write(fsutil.genFinalMD5(i)) files.close()