def run(self): logger.logI(tn, _("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, _("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 usr/lib/ubiquity/apt-setup/generators/40cdrom" sfspath = isotreel + "casper/filesystem.squashfs" logger.logI(tn, _("Adding the edited /etc and /var to the filesystem")) os.system("mksquashfs " + tmpsys + " " + sfspath + " " + opts) logger.logI(tn, _("Adding the rest of the system")) os.system("mksquashfs / " + sfspath + " " + opts + " -e " + sfsex) # 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, _("Writing the size")) files = open(isotreel + "casper/filesystem.size", "w") files.write(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()
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()