def runthread(self): logger.logI(self.tn, logger.I, _("Generating ISO Tree")) # Clean the tree, if it exists fsutil.rm(isotreel) # Make the tree fsutil.maketree([isotreel + "casper", isotreel + "preseed", isotreel + "isolinux", isotreel + ".disk"])
def runthread(self): logger.logI(self.tn, logger.I, _( "Making the ISO compatible with a USB burner")) logger.logVV(self.tn, logger.I, _("Writing .disk/info")) files = open(isotreel + ".disk/info", "w") files.write(getDiskName() + "\n") files.close() self.setProgress(self.tn, 20) logger.logV(self.tn, logger.I, _( "Making symlink pointing to the ISO root dir")) if os.path.lexists(isotreel + "ubuntu"): fsutil.rm(isotreel + "ubuntu", False, self.tn) os.symlink(isotreel, isotreel + "ubuntu") self.setProgress(self.tn, 40) logger.logVV(self.tn, logger.I, _("Writing release notes URL")) files = open(isotreel + ".disk/release_notes_url", "w") files.write(configutils.getValue(configs[configutils.url]) + "\n") files.close() self.setProgress(self.tn, 60) logger.logVV(self.tn, logger.I, _("Writing .disk/base_installable")) fsutil.touch(isotreel + ".disk/base_installable") self.setProgress(self.tn, 80) logger.logVV(self.tn, logger.I, _("Writing CD Type")) files = open(isotreel + ".disk/cd_type", "w") files.write("full_cd/single\n") files.close()
def runthread(self): # If the user-setup-apply file does not exist, and there is an alternative, we'll copy it over logger.logI(self.tn, logger.I, _("Setting up the installer")) if (os.path.isfile( "/usr/lib/ubiquity/user-setup/user-setup-apply.orig") and not os.path.isfile( "/usr/lib/ubiquity/user-setup/user-setup-apply")): shutil.copy2("/usr/lib/ubiquity/user-setup/user-setup-apply.orig", "/usr/lib/ubiquity/user-setup/user-setup-apply") # If the user requested to make sure that the installer does _not_ change the apt sources, # make sure that relinux obeys this. # However, if the user changed his/her mind, we want to make sure that relinux # work with that too if not configutils.getValue(configs[configutils.aptlistchange]): if not os.path.exists( "/usr/share/ubiquity/apt-setup.relinux-backup"): os.rename("/usr/share/ubiquity/apt-setup", "/usr/share/ubiquity/apt-setup.relinux-backup") aptsetup = open("/usr/share/ubiquity/apt-setup", "w") aptsetup.write("\n") aptsetup.close() fsutil.chmod("/usr/share/ubiquity/apt-setup", 0o755, self.tn) elif os.path.exists("/usr/share/ubiquity/apt-setup.relinux-backup"): # TODO: Fix the 40cdrom bug? fsutil.rm("/usr/share/ubiquity/apt-setup", False, self.tn) os.rename("/usr/share/ubiquity/apt-setup.relinux-backup", "/usr/share/ubiquity/apt-setup")
def runthread(self): logger.logI(self.tn, logger.I, _("Generating the tree for the temporary filesystem")) # Clean the TMPSYS tree, if it exists fsutil.rm(tmpsys) self.progressfunc(20) # Generate the tree fsutil.maketree([ tmpsys + "etc", tmpsys + "dev", tmpsys + "proc", [tmpsys + "tmp", 0o1777], tmpsys + "sys", tmpsys + "mnt", tmpsys + "media/cdrom", tmpsys + "var", tmpsys + "home", tmpsys + "run" ], self.tn, lambda p: self.progressfunc(20 + p / (5 / 3))) fsutil.chmod(tmpsys + "tmp", 0o1777, self.tn)
def runthread(self): logger.logI(self.tn, logger.I, _( "Generating the tree for the temporary filesystem")) # Clean the TMPSYS tree, if it exists fsutil.rm(tmpsys) self.progressfunc(20) # Generate the tree fsutil.maketree([tmpsys + "etc", tmpsys + "dev", tmpsys + "proc", [tmpsys + "tmp", 0o1777], tmpsys + "sys", tmpsys + "mnt", tmpsys + "media/cdrom", tmpsys + "var", tmpsys + "home", tmpsys + "run"], self.tn, lambda p: self.progressfunc(20 + p / (5 / 3))) fsutil.chmod(tmpsys + "tmp", 0o1777, self.tn)
def runthread(self): # If the user-setup-apply file does not exist, and there is an alternative, we'll copy it over logger.logI(self.tn, logger.I, _("Setting up the installer")) if (os.path.isfile("/usr/lib/ubiquity/user-setup/user-setup-apply.orig") and not os.path.isfile("/usr/lib/ubiquity/user-setup/user-setup-apply")): shutil.copy2("/usr/lib/ubiquity/user-setup/user-setup-apply.orig", "/usr/lib/ubiquity/user-setup/user-setup-apply") # If the user requested to make sure that the installer does _not_ change the apt sources, # make sure that relinux obeys this. # However, if the user changed his/her mind, we want to make sure that relinux # work with that too if not configutils.getValue(configs[configutils.aptlistchange]): if not os.path.exists("/usr/share/ubiquity/apt-setup.relinux-backup"): os.rename("/usr/share/ubiquity/apt-setup", "/usr/share/ubiquity/apt-setup.relinux-backup") aptsetup = open("/usr/share/ubiquity/apt-setup", "w") aptsetup.write("\n") aptsetup.close() fsutil.chmod("/usr/share/ubiquity/apt-setup", 0o755, self.tn) elif os.path.exists("/usr/share/ubiquity/apt-setup.relinux-backup"): # TODO: Fix the 40cdrom bug? fsutil.rm("/usr/share/ubiquity/apt-setup", False, self.tn) os.rename("/usr/share/ubiquity/apt-setup.relinux-backup", "/usr/share/ubiquity/apt-setup")
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, tn=self.tn): 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 is not 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])) fsutil.rm(location) 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 is not 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() self.setProgress(self.tn, 100) msg = "Relinux generated the ISO at " + configutils.getValue( config.Configuration["OSWeaver"][configutils.isolocation]) msg += "." self.showMessage(self.tn, logger.I, msg)
def runthread(self): logger.logI(tn, logger.I, _("Generating compressed filesystem")) # Generate the SquashFS file # Options: # -b 1M Use a 1M blocksize (maximum) # -no-recovery No recovery files # -always-use-fragments Fragment blocks for files larger than the blocksize (1M) # -comp Compression type logger.logVV(tn, logger.I, _("Generating options")) opts = "-b 1M -no-recovery -no-duplicates -always-use-fragments" opts = opts + " -comp " + configutils.getValue(configs[ configutils.sfscomp]) opts = opts + " " + configutils.getValue(configs[configutils.sfsopts]) sfsex = "dev etc home media mnt proc sys var run usr/lib/ubiquity/apt-setup/generators/40cdrom tmp" sfspath = isotreel + "casper/filesystem.squashfs" if os.path.exists(sfspath): fsutil.rm(sfspath) # This line would match the pattern below: [==========/ ] 70/300 20% patt = re.compile("^ *\[=*. *\] *[0-9]*/[0-9]* *([0-9]*)% *$") appnd = "32" if sys.maxsize > 2 ** 32: appnd = "64" # Hack to make sure all output is given os.environ["LD_PRELOAD"] = os.path.split( os.path.realpath(__file__))[0] + "/isatty" + appnd + ".so" logger.logI(tn, logger.I, _( "Adding the edited /etc and /var to the filesystem")) logger.logI(tn, logger.I, logger.MTab + _( "This might take a couple of minutes")) sfscmd = subprocess.Popen( shlex.split("mksquashfs " + tmpsys + " " + sfspath + " " + opts), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True) oldprogress = 0 while sfscmd.poll() is None: output = sfscmd.stdout.readline() match = patt.match(output) if match is not None: sys.stdout.write("\r" + match.group(0)) sys.stdout.flush() progress = int(match.group(1)) if progress > oldprogress: self.setProgress( tn, int(utilities.floatDivision(progress, 2))) oldprogress = progress elif len(output.strip()) > 0: logger.logI(tn, logger.I, output.rstrip(), noterm=True, nogui=True) sys.stdout.write("\n") logger.logI(tn, logger.I, _( "Adding the rest of the system (this can take a while)")) sfscmd = subprocess.Popen( shlex.split( "mksquashfs / " + sfspath + " " + opts + " -e " + sfsex), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True) oldprogress = 0 while sfscmd.poll() is None: output = sfscmd.stdout.readline() match = patt.match(output) if match is not None: sys.stdout.write("\r" + match.group(0)) sys.stdout.flush() progress = int(match.group(1)) if progress > oldprogress: self.setProgress( tn, 50 + int(utilities.floatDivision(progress, 2))) oldprogress = progress elif len(output.strip()) > 0: logger.logI(tn, logger.I, output.rstrip(), noterm=True, nogui=True) sys.stdout.write("\n") os.environ["LD_PRELOAD"] = "" # Make sure the SquashFS file is OK doSFSChecks( sfspath, int(configutils.getValue(configs[configutils.isolevel]))) # Find the size after it is uncompressed logger.logV(tn, logger.I, _("Writing the size")) files = open(isotreel + "casper/filesystem.size", "w") files.write(str(fsutil.getSFSInstSize(sfspath)) + "\n") files.close()
def runthread(self): logger.logI(tn, logger.I, _("Generating compressed filesystem")) # Generate the SquashFS file # Options: # -b 1M Use a 1M blocksize (maximum) # -no-recovery No recovery files # -always-use-fragments Fragment blocks for files larger than the blocksize (1M) # -comp Compression type logger.logVV(tn, logger.I, _("Generating options")) opts = "-b 1M -no-recovery -no-duplicates -always-use-fragments" opts = opts + " -comp " + configutils.getValue( configs[configutils.sfscomp]) opts = opts + " " + configutils.getValue(configs[configutils.sfsopts]) sfsex = "dev etc home media mnt proc sys var run usr/lib/ubiquity/apt-setup/generators/40cdrom tmp" sfspath = isotreel + "casper/filesystem.squashfs" if os.path.exists(sfspath): fsutil.rm(sfspath) # This line would match the pattern below: [==========/ ] 70/300 20% patt = re.compile("^ *\[=*. *\] *[0-9]*/[0-9]* *([0-9]*)% *$") appnd = "32" if sys.maxsize > 2**32: appnd = "64" # Hack to make sure all output is given os.environ["LD_PRELOAD"] = os.path.split( os.path.realpath(__file__))[0] + "/isatty" + appnd + ".so" logger.logI(tn, logger.I, _("Adding the edited /etc and /var to the filesystem")) logger.logI(tn, logger.I, logger.MTab + _("This might take a couple of minutes")) sfscmd = subprocess.Popen(shlex.split("mksquashfs " + tmpsys + " " + sfspath + " " + opts), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True) oldprogress = 0 while sfscmd.poll() is None: output = sfscmd.stdout.readline() match = patt.match(output) if match is not None: sys.stdout.write("\r" + match.group(0)) sys.stdout.flush() progress = int(match.group(1)) if progress > oldprogress: self.setProgress(tn, int(utilities.floatDivision(progress, 2))) oldprogress = progress elif len(output.strip()) > 0: logger.logI(tn, logger.I, output.rstrip(), noterm=True, nogui=True) sys.stdout.write("\n") logger.logI(tn, logger.I, _("Adding the rest of the system (this can take a while)")) sfscmd = subprocess.Popen(shlex.split("mksquashfs / " + sfspath + " " + opts + " -e " + sfsex), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True) oldprogress = 0 while sfscmd.poll() is None: output = sfscmd.stdout.readline() match = patt.match(output) if match is not None: sys.stdout.write("\r" + match.group(0)) sys.stdout.flush() progress = int(match.group(1)) if progress > oldprogress: self.setProgress( tn, 50 + int(utilities.floatDivision(progress, 2))) oldprogress = progress elif len(output.strip()) > 0: logger.logI(tn, logger.I, output.rstrip(), noterm=True, nogui=True) sys.stdout.write("\n") os.environ["LD_PRELOAD"] = "" # Make sure the SquashFS file is OK doSFSChecks(sfspath, int(configutils.getValue(configs[configutils.isolevel]))) # Find the size after it is uncompressed logger.logV(tn, logger.I, _("Writing the size")) files = open(isotreel + "casper/filesystem.size", "w") files.write(str(fsutil.getSFSInstSize(sfspath)) + "\n") files.close()