Exemplo n.º 1
0
 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()
Exemplo n.º 2
0
 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()