Exemple #1
0
 def run(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, _("Editing casper and LSB configuration files"))
     logger.logV(self.tn, _("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.logW(self.tn, _("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.logV(self.tn, _("Editing lsb-release"))
     self.varEditor(tmpsys + "etc/lsb-release", {
                                 "DISTRIB_ID": configutils.getValue(configs[configutils.sysname]),
                                 "DISTRIB_RELEASE": configutils.getValue(configs[configutils.version]),
                                 "DISTRIB_CODENAME": configutils.getValue(configs[configutils.codename]),
                                 "DISTRIB_DESCRIPTION":
     configutils.getValue(configs[configutils.description])})
Exemple #2
0
 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()
Exemple #3
0
 def page(self, page_num):
     if page_num < len(self.pages):
         return self.pages[page_num]
     else:
         logger.logI(
             tn, logger.E,
             _("Page") + " " + str(page_num) + " " + _("does not exist"))
Exemple #4
0
 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"])
Exemple #5
0
 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 isCompatible(module):
    if module.relinuxmoduleapi != config.ModAPIVersion:
        logger.logI(tn, logger.W, _("Module") + " " + module.modulename + " " +
                    _("is incompatible with this relinux version") + " (" + _("relinux version:") + " " +
                    config.version + ", " + _("required version:") + " " + module.relinuxmoduleapi + ")")
        return False
    return True
Exemple #7
0
def getModules():
    returnme = []
    modules = os.listdir(config.ModFolder)
    for i in modules:
        dirs = os.path.join(config.ModFolder, i)
        if not os.path.isdir(dirs) or not "__init__.py" in os.listdir(dirs):
            continue
        file, pathname, desc = imp.find_module("__init__", [dirs])
        module = imp.load_module("__init__", file, pathname, desc)
        if not isModule(module):
            continue
        loadme = True
        if not isCompatible(module):
            loadme = False
        if loadme:
            returnme.append({
                "name": i,
                "file": file,
                "path": pathname,
                "desc": desc
            })
        else:
            logger.logI(
                tn, logger.W,
                _("Module") + " " + module.modulename + " " +
                _("will not be loaded"))
    return returnme
Exemple #8
0
 def run(self):
     logger.logI(self.tn, _("Generating the tree for the temporary filesystem"))
     fsutil.maketree([tmpsys + "etc", tmpsys + "dev",
                       tmpsys + "proc", tmpsys + "tmp",
                       tmpsys + "sys", tmpsys + "mnt",
                       tmpsys + "media/cdrom", tmpsys + "var", tmpsys + "home"], self.tn)
     fsutil.chmod(tmpsys + "tmp", "1777", self.tn)
Exemple #9
0
 def showMessage(tn, importance, msg):
     logger.logI(tn, importance, msg)
     QtCore.QMetaObject.invokeMethod(
         ui.msgbox, "setImportance", QtCore.Qt.QueuedConnection, QtCore.Q_ARG("QString", importance)
     )
     QtCore.QMetaObject.invokeMethod(
         ui.msgbox, "realSetText", QtCore.Qt.QueuedConnection, QtCore.Q_ARG("QString", msg)
     )
     QtCore.QMetaObject.invokeMethod(ui.msgbox, "exec", QtCore.Qt.QueuedConnection)
Exemple #10
0
 def runthread(self):
     logger.logI(self.tn, logger.I, _("Copying files to the temporary filesystem"))
     excludes = configutils.parseMultipleValues(configutils.getValue(configs[configutils.excludes]))
     varexcludes = excludes
     # Exclude all log files (*.log *.log.*), PID files (to show that no daemons are running),
     # backup and old files (for obvious reasons), and any .deb files that a person might have downloaded
     varexcludes.extend(["*.log", "*.log.*", "*.pid", "*/pid", "*.bak", "*.[0-9].gz", "*.deb"])
     fsutil.fscopy("/etc", tmpsys + "etc", excludes, self.tn)
     fsutil.fscopy("/var", tmpsys + "var", varexcludes, self.tn)
Exemple #11
0
 def runthread(self):
     logger.logI(self.tn, logger.I,
                 _("Generating the tree for the temporary filesystem"))
     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)
     fsutil.chmod(tmpsys + "tmp", 0o1777, self.tn)
Exemple #12
0
 def showMessage(tn, importance, msg):
     logger.logI(tn, importance, msg)
     QtCore.QMetaObject.invokeMethod(
         ui.msgbox, "setImportance", QtCore.Qt.QueuedConnection,
         QtCore.Q_ARG("QString", importance))
     QtCore.QMetaObject.invokeMethod(ui.msgbox, "realSetText",
                                     QtCore.Qt.QueuedConnection,
                                     QtCore.Q_ARG("QString", msg))
     QtCore.QMetaObject.invokeMethod(ui.msgbox, "exec",
                                     QtCore.Qt.QueuedConnection)
Exemple #13
0
def isCompatible(module):
    if module.relinuxmoduleapi != config.ModAPIVersion:
        logger.logI(
            tn, logger.W,
            _("Module") + " " + module.modulename + " " +
            _("is incompatible with this relinux version") + " (" +
            _("relinux version:") + " " + config.version + ", " +
            _("required version:") + " " + module.relinuxmoduleapi + ")")
        return False
    return True
Exemple #14
0
def doSFSChecks(files, isolvl):
    logger.logI(tn, logger.I, _("Checking the compressed filesystem"))
    size = fsutil.getSize(files)
    lvl2 = fsutil.sizeTrans({"G": 4})
    lvl3 = fsutil.sizeTrans({"T": 8})
    if size > lvl2 and isolvl < 3:
        dispiso9660(isolvl, lvl2, size)
    elif size > lvl3 and isolvl >= 3:
        # 8TB OS? That's a bit much xD
        dispiso9660(isolvl, lvl3, size)
Exemple #15
0
def doSFSChecks(files, isolvl):
    logger.logI(tn, logger.I, _("Checking the compressed filesystem"))
    size = fsutil.getSize(files)
    lvl2 = fsutil.sizeTrans({"G": 4})
    lvl3 = fsutil.sizeTrans({"T": 8})
    if size > lvl2 and isolvl < 3:
        dispiso9660(isolvl, lvl2, size)
    elif size > lvl3 and isolvl >= 3:
        # 8TB OS? That's a bit much xD
        dispiso9660(isolvl, lvl3, size)
Exemple #16
0
 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)
Exemple #17
0
 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)
Exemple #18
0
 def runthread(self):
     logger.logI(self.tn, logger.I,
                 _("Copying files to the temporary filesystem"))
     excludes = configutils.parseMultipleValues(
         configutils.getValue(configs[configutils.excludes]))
     varexcludes = excludes
     # Exclude all log files (*.log *.log.*), PID files (to show that no daemons are running),
     # backup and old files (for obvious reasons), and any .deb files that a person might have downloaded
     varexcludes.extend([
         "*.log", "*.log.*", "*.pid", "*/pid", "*.bak", "*.[0-9].gz",
         "*.deb"
     ])
     fsutil.fscopy("/etc", tmpsys + "etc", excludes, self.tn)
     fsutil.fscopy("/var", tmpsys + "var", varexcludes, self.tn)
Exemple #19
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()
Exemple #20
0
 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 (True or
             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("#!/bin/sh\n")
         aptsetup.write("exit\n")
         aptsetup.close()
Exemple #21
0
 def run(self):
     # If the user-setup-apply file does not exist, and there is an alternative, we'll copy it over
     logger.logI(self.tn, _("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 configutils.parseBoolean(configutils.getValue(configs[configutils.aptlistchange])) is True:
         fsutil.makedir(tmpsys + "usr/share/ubiquity/")
         aptsetup = open(tmpsys + "usr/share/ubiquity/apt-setup", "w")
         aptsetup.write("#!/bin/sh\n")
         aptsetup.write("exit\n")
         aptsetup.close()
     else:
         fsutil.makedir(tmpsys + "usr/lib/ubiquity/apt-setup/generators/")
         cdrom = open(tmpsys + "usr/lib/ubiquity/apt-setup/generators/40cdrom", "w")
         cdrom.write("#!/bin/sh\n")
         cdrom.write("exit\n")
         cdrom.close()
Exemple #22
0
 def run(self):
     logger.logI(self.tn, _("Making the ISO compatible with a USB burner"))
     logger.logVV(self.tn, _("Writing .disk/info"))
     files = open(isotreel + ".disk/info", "w")
     files.write(getDiskName())
     files.close()
     logger.logV(self.tn, _("Making symlink pointing to the ISO root dir"))
     os.symlink(isotreel + "ubuntu", isotreel)
     logger.logVV(self.tn, _("Writing release notes URL"))
     files = open(isotreel + ".disk/release_notes_url", "w")
     files.write(configutils.getValue(configs[configutils.url]) + "\n")
     files.close()
     logger.logVV(self.tn, _("Writing .disk/base_installable"))
     fsutil.touch(isotreel + ".disk/base_installable")
     logger.logVV(self.tn, _("Writing CD Type"))
     files = open(isotreel + ".disk/cd_type", "w")
     files.write("full_cd/single\n")
     files.close()
Exemple #23
0
 def runthread(self):
     logger.logI(self.tn, logger.I, _("Generating the tree for the temporary filesystem"))
     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,
     )
     fsutil.chmod(tmpsys + "tmp", 0o1777, self.tn)
Exemple #24
0
 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 (True or configutils.parseBoolean(
             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("#!/bin/sh\n")
         aptsetup.write("exit\n")
         aptsetup.close()
Exemple #25
0
def getModules():
    returnme = []
    modules = os.listdir(config.ModFolder)
    for i in modules:
        dirs = os.path.join(config.ModFolder, i)
        if not os.path.isdir(dirs) or not "__init__.py" in os.listdir(dirs):
            continue
        file, pathname, desc = imp.find_module("__init__", [dirs])
        module = imp.load_module("__init__", file, pathname, desc)
        if not isModule(module):
            continue
        loadme = True
        if not isCompatible(module):
            loadme = False
        if loadme:
            returnme.append({"name": i, "file": file, "path": pathname, "desc": desc})
        else:
            logger.logI(tn, logger.W, _("Module") + " " + module.modulename + " " + _("will not be loaded"))
    return returnme
Exemple #26
0
 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()
Exemple #27
0
 def runthread(self):
     self.event = threading.Event()
     self.ap = aptutil.AcquireProgress(lambda p: self.percentfunc(p / 2))
     self.ip = aptutil.InstallProgress(
         lambda p: self.percentfunc(50 + p / 2),
         lambda: self.finishfunc(self.event))
     logger.logI(self.tn, logger.I, _("Setting up distro dependencies"))
     logger.logV(self.tn, logger.I, _("Setting up Ubiquity"))
     if configutils.getValue(configs[configutils.instfront]).lower() == "kde":
         self.instPkg("ubiquity-frontend-kde", True)
         self.remPkg("ubiquity-frontend-gtk")
     else:
         self.instPkg("ubiquity-frontend-gtk", True)
         self.remPkg("ubiquity-frontend-kde")
     logger.logV(self.tn, logger.I, _("Setting up Popularity Contest"))
     if configutils.getValue(configs[configutils.popcon]):
         self.instPkg("popularity-contest")
     else:
         self.remPkg("popularity-contest")
     if configutils.getValue(configs[configutils.memtest]):
         logger.logV(self.tn, logger.I, _("Setting up memtest86+"))
         self.instPkg("memtest86+")
     logger.logV(
         self.tn, logger.I, _("Setting up other distro dependencies"))
     self.instPkg("ubuntu-minimal")
     self.instPkg("syslinux", True)
     self.instPkg("discover")
     self.instPkg("coreutils")
     self.instPkg("bash")
     self.instPkg("initramfs-tools")
     self.instPkg("casper")
     self.instPkg("laptop-detect")
     logger.logI(self.tn, logger.I, _(
         "Setting up relinux generation dependencies"))
     self.instPkg("squashfs-tools", True)
     self.instPkg("genisoimage", True)
     configutils.saveBuffer(config.Configuration)
     aptutil.commitChanges(self.aptcache, self.ap, self.ip)
     self.exec_()
Exemple #28
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()
Exemple #29
0
 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")
Exemple #30
0
 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])
         })
Exemple #31
0
 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]),
         },
     )
Exemple #32
0
 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()
Exemple #33
0
 def runthread(self):
     # Setup the password and group stuff
     logger.logI(self.tn, logger.I, _("Removing conflicting users"))
     passwdf = tmpsys + "etc/passwd"
     #passwdfile = open(passwdf, "r")
     #passwdstat = fsutil.getStat(passwdf)
     #passwdbuffer = configutils.getBuffer(passwdfile)
     #passwdfile.close()
     #passwdfile = open(passwdf, "w")
     buffers = fsutil.ife_getbuffers(passwdf)
     pe = pwdmanip.parsePasswdEntries(buffers[3])
     buffers[3] = pe
     # Users to "delete" on the live system
     logger.logV(self.tn, logger.I, _("Gathering users to remove"))
     nobody = ""
     for x in pe:
         if x["user"] == "nobody":
             nobody = x
     max_uid = 1999
     sysrange = 500
     if not isinstance(nobody, dict):
         logger.logV(
             self.tn, logger.E, _("User 'nobody' could not be found!"))
     else:
         nuid = int(nobody["uid"])
         if nuid <= 100:
             # nobody has been assigned to the conventional system UID range
             max_uid = 1999
             sysrange = 100
         elif nuid < 500:
             # nobody has been assigned to the RHEL system UID range
             max_uid = 1999
             sysrange = 500
         elif nuid >= 65530 and nuid <= 65535:
             # nobody has been assigned to the highest possible unsigned short integer (16 bit) range
             max_uid = nuid - 1
             sysrange = 555
         elif nuid >= 32766:
             # nobody has been assigned to the highest possible signed short integer (16 bit) range
             max_uid = nuid - 1
             sysrange = 500
         else:
             max_uid = 1999
             sysrange = 555
     usrs = pwdmanip.getPPByUID(
         numrange.gen_num_range(sysrange, max_uid), pe)
     if config.VVStatus is False:
         logger.logV(self.tn, logger.I, _("Removing them"))
     logger.logVV(self.tn, logger.I, _("Removing users in /etc/passwd"))
     fsutil.ife(buffers, lambda line: [True, pwdmanip.PPtoEntry(
         line)] if not line in usrs else [False, ""])
     # Rewrite the password file
     #for i in ppe:
     #    if not i in usrs:
     #        passwdfile.write(pwdmanip.PPtoEntry(i))
     #fsutil.copystat(passwdstat, passwdf)
     #passwdfile.close()
     # Now for the group file
     logger.logVV(self.tn, logger.I, _("Removing users in /etc/group"))
     groupf = tmpsys + "etc/group"
     buffers = fsutil.ife_getbuffers(groupf)
     pe = pwdmanip.parseGroupEntries(buffers[3])
     buffers[3] = pe
     fsutil.ife(buffers, lambda line: self._parseGroup(line, usrs))
     # Work on both shadow files
     shadowf = tmpsys + "etc/shadow"
     gshadowf = tmpsys + "etc/gshadow"
     buffers = fsutil.ife_getbuffers(shadowf)
     gbuffers = fsutil.ife_getbuffers(gshadowf)
     pe = pwdmanip.parseShadowEntries(buffers[3])
     buffers[3] = pe
     # If you look carefully (or just do a quick google search :P), you will notice that gshadow files
     # are very similar to group files, so we can just parse them as if they were group files
     pe = pwdmanip.parseGroupEntries(gbuffers[3])
     gbuffers[3] = pe
     logger.logVV(self.tn, logger.I, _("Removing users in /etc/shadow"))
     fsutil.ife(buffers, lambda line: self._parseShadow(line, usrs))
     logger.logVV(self.tn, logger.I, _("Removing users in /etc/gshadow"))
     fsutil.ife(gbuffers, lambda line: self._parseGroup(line, usrs))
     logger.logV(self.tn, logger.I, _("Creating backups"))
     shutil.copy2(tmpsys + "etc/passwd", tmpsys + "etc/passwd-")
     shutil.copy2(tmpsys + "etc/group", tmpsys + "etc/group-")
     shutil.copy2(tmpsys + "etc/shadow", tmpsys + "etc/shadow-")
     shutil.copy2(tmpsys + "etc/gshadow", tmpsys + "etc/gshadow-")
Exemple #34
0
 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()
Exemple #35
0
 def run(self):
     logger.logI(self.tn, _("Removing unneeded files"))
     '''cbs = "/usr/share/initramfs-tools/scripts/casper-bottom/"
Exemple #36
0
 def run(self):
     logger.logI(self.tn, _("Copying files to the temporary filesystem"))
     excludes = configutils.getValue(configs[configutils.excludes])
     fsutil.fscopy("etc", tmpsys + "etc", excludes, self.tn)
     fsutil.fscopy("var", tmpsys + "var", excludes, self.tn)
Exemple #37
0
 def runthread(self):
     logger.logI(self.tn, logger.I, _("Copying the kernel to the ISO tree"))
     copyFile(
         "/boot/vmlinuz-" + configutils.getKernel(
             configutils.getValue(configs[configutils.kernel])),
         isotreel + "casper/vmlinuz", self.tn)
Exemple #38
0
def main():
    def parsePyHex(string1):
        string = "%x" % string1
        count = 0
        result = ""
        for char in string:
            if count == 0 or count == 2 or count == 4:
                result += char
                if count != 4:
                    result += "."
            elif count == 5:
                if char.lower() == "f":
                    break
                else:
                    result += char.lower()
            elif count == 6:
                result += char
            count += 1
        return result
    if not config.python_ok:
        print(_("Relinux only supports python ") + parsePyHex(config.min_python_version) + "-" +
              parsePyHex(config.max_python_version) + ", " + _("but python ") +
              parsePyHex(sys.hexversion) + " " + _("was used."))
        exitprog(1)
    from argparse import ArgumentParser
    '''tkname = "Tkinter"
    if config.python3:
        tkname = "tkinter"
    Tkinter = __import__(tkname)'''
    #import time
    from relinux import gui, configutils, logger, aptutil, modloader, utilities, fsutil
    config.Arch = fsutil.getArch()
    logger.veryverbose()
    config.GUIStream = utilities.eventStringIO()
    tn = logger.genTN("Main")
    parser = ArgumentParser(prog="relinux", usage="%(prog)s [options]")
    parser.add_argument("-V", "--version", action="store_true",
                        dest="showversion",
                        help="show version information")
    parser.add_argument("-q", "--quiet",
                        action="store_true", dest="quiet", default=False,
                        help="log as little as possible to stdout")
    parser.add_argument("-v", "--verbose",
                        action="store_true", dest="verbose", default=False,
                        help="log more to stdout")
    parser.add_argument("-vv", "--veryverbose",
                        action="store_true", dest="veryverbose", default=False,
                        help="log even more to stdout")
    parser.add_argument(
        "--no-stylesheet", action="store_true", dest="nostylesheet", default=False,
        help="don't use any stylesheets")
    args = parser.parse_args()
    config.EFiles.extend([config.GUIStream, sys.stdout])
    if args.showversion:
        version()
    if not args.quiet:
        config.IFiles.extend([config.GUIStream, sys.stdout])
    if args.verbose:
        config.VFiles.extend([config.GUIStream, sys.stdout])
    if args.veryverbose:
        config.VVFiles.extend([config.GUIStream, sys.stdout])
    #modules = []
    #aptcache = []
    #cbuffer = {}
    '''root = Tkinter.Tk()
    App = None
    def startProg(splash):
        global modules, aptcache, cbuffer, App
        spprogn = 6
        spprog = 0
        def calcPercent(def2 = (spprog, spprogn)):
            return utilities.calcPercent(*def2)
        splash.setProgress(
            calcPercent((spprog, spprogn)), "Loading modules...")
        modules = []
        modulemetas = modloader.getModules()
        for i in modulemetas:
            modules.append(modloader.loadModule(i))
        spprog += 1
        splash.setProgress(
            calcPercent((spprog, spprogn)), "Parsing configuration...")
        #buffer1 = utilities.getBuffer(open(relinuxdir + "/relinux.conf"))
        #buffer2 = configutils.compress(buffer1)
        #cbuffer = configutils.parseCompressedBuffer(buffer2, relinuxdir + "/relinux.conf")
        configfiles = [relinuxdir + "/relinux.conf"]
        for i in range(len(modulemetas)):
            for x in modules[i].moduleconfig:
                configfiles.append(
                    os.path.join(os.path.dirname(modulemetas[i]["path"]), x))
        cbuffer = configutils.parseFiles(configfiles)
        config.Configuration = cbuffer
        configutils.saveBuffer(config.Configuration)
        \'''for i in configutils.beautify(buffer1):
            print(i)\'''
        spprog += 1
        splash.setProgress(
            calcPercent((spprog, spprogn)), "Reading APT Cache...")
        def aptupdate(op, percent):
            global minis
            if percent != None:
                minis += utilities.floatDivision(percent, 100)
            splash.setProgress(
                calcPercent((utilities.floatDivision(
                    minis + captop, aptops) + spprog, spprogn)),
                               "Reading APT Cache... (" + op + ")")
        def aptdone(op):
            global minis, captop
            minis = 0.0
            captop += 1
        aptcache = aptutil.getCache(aptutil.OpProgress(aptupdate, aptdone))
        config.AptCache = aptcache
        spprog += 1
        splash.setProgress(
            calcPercent((spprog, spprogn)), "Loading the GUI...")
        App = gui.GUI(root)
        spprog += 1
        splash.setProgress(
            calcPercent((spprog, spprogn)), "Filling in configuration...")
        App.fillConfiguration(cbuffer)
        spprog += 1
        splash.setProgress(
            calcPercent((spprog, spprogn)), "Running modules...")
        for i in modules:
            modloader.runModule(i,
                                {"gui": App, "config": cbuffer, "aptcache": aptcache})
        spprog += 1
        splash.setProgress(calcPercent((spprog, spprogn)), "Launching relinux")
    splash = gui.Splash(root, startProg)
    #root.overrideredirect(Tkinter.TRUE) # Coming soon!
    root.mainloop()'''
    App = QtGui.QApplication(sys.argv)
    splash = QtGui.QSplashScreen(
        QtGui.QPixmap(relinuxdir + "/splash_light.png"))
    splash.show()
    App.processEvents()
    def showMessage(str_):
        splash.showMessage(
            str_ + "...", QtCore.Qt.AlignLeft | QtCore.Qt.AlignBottom)
        App.processEvents()
    showMessage(_("Loading modules"))
    modules = []
    modulemetas = modloader.getModules()
    for i in modulemetas:
        modules.append(modloader.loadModule(i))
    showMessage(_("Loading configuration files"))
    configfiles = [relinuxdir + "/relinux.conf"]
    for i in range(len(modulemetas)):
        for x in modules[i].moduleconfig:
            if "RELINUXCONFDIR" in os.environ:
                configfiles.append(os.path.join(relinuxdir, x))
            else:
                configfiles.append(
                    os.path.join(os.path.dirname(modulemetas[i]["path"]), x))
    cbuffer = configutils.parseFiles(configfiles)
    config.Configuration = cbuffer
    configutils.saveBuffer(config.Configuration)
    logfilename = configutils.getValue(cbuffer["Relinux"]["LOGFILE"])
    logfile = open(logfilename, "a")
    config.EFiles.append(logfile)
    config.IFiles.append(logfile)
    config.VFiles.append(logfile)
    config.VVFiles.append(logfile)
    logger.logI(tn, logger.I, "===========================")
    logger.logI(tn, logger.I, "=== Started new session ===")
    logger.logI(tn, logger.I, "===========================")
    showMessage(_("Loading APT cache 0%"))
    def aptupdate(op, percent):
        global minis
        if percent:
            minis = int(percent)
        showMessage(
            _("Loading APT cache") + " (" + op + ") " + str(minis) + "%")
    aptcache = aptutil.getCache(aptutil.OpProgress(aptupdate, None))
    config.AptCache = aptcache
    if not args.nostylesheet:
        showMessage(_("Loading stylesheet"))
        App.setStyleSheet(open(mainsrcdir + "/stylesheet.css", "r").read())
    showMessage(_("Loading GUI"))
    gui_ = gui.GUI(App)
    config.Gui = gui_
    showMessage(_("Running modules"))
    for i in modules:
            modloader.runModule(i, {})
    gui_.show()
    splash.finish(gui_)
    exitcode = App.exec_()
    config.ThreadStop = True
    logfile.close()
    sys.exit(exitcode)
Exemple #39
0
 def run(self):
     logger.logI(self.tn, _("Generating ISO Tree"))
     # Make the tree
     fsutil.maketree([isotreel + "casper", isotreel + "preseed",
                       isotreel + "isolinux", isotreel + ".disk"])
Exemple #40
0
def main():
    def parsePyHex(string1):
        string = "%x" % string1
        count = 0
        result = ""
        for char in string:
            if count == 0 or count == 2 or count == 4:
                result += char
                if count != 4:
                    result += "."
            elif count == 5:
                if char.lower() == "f":
                    break
                else:
                    result += char.lower()
            elif count == 6:
                result += char
            count += 1
        return result

    if not config.python_ok:
        print(
            _("Relinux only supports python ") +
            parsePyHex(config.min_python_version) + "-" +
            parsePyHex(config.max_python_version) + ", " + _("but python ") +
            parsePyHex(sys.hexversion) + " " + _("was used."))
        exitprog(1)
    from argparse import ArgumentParser
    '''tkname = "Tkinter"
    if config.python3:
        tkname = "tkinter"
    Tkinter = __import__(tkname)'''
    #import time
    from relinux import gui, configutils, logger, aptutil, modloader, utilities, fsutil
    config.Arch = fsutil.getArch()
    logger.veryverbose()
    config.GUIStream = utilities.eventStringIO()
    tn = logger.genTN("Main")
    parser = ArgumentParser(prog="relinux", usage="%(prog)s [options]")
    parser.add_argument("-V",
                        "--version",
                        action="store_true",
                        dest="showversion",
                        help="show version information")
    parser.add_argument("-q",
                        "--quiet",
                        action="store_true",
                        dest="quiet",
                        default=False,
                        help="log as little as possible to stdout")
    parser.add_argument("-v",
                        "--verbose",
                        action="store_true",
                        dest="verbose",
                        default=False,
                        help="log more to stdout")
    parser.add_argument("-vv",
                        "--veryverbose",
                        action="store_true",
                        dest="veryverbose",
                        default=False,
                        help="log even more to stdout")
    parser.add_argument("--no-stylesheet",
                        action="store_true",
                        dest="nostylesheet",
                        default=False,
                        help="don't use any stylesheets")
    args = parser.parse_args()
    config.EFiles.extend([config.GUIStream, sys.stdout])
    if args.showversion:
        version()
    if not args.quiet:
        config.IFiles.extend([config.GUIStream, sys.stdout])
    if args.verbose:
        config.VFiles.extend([config.GUIStream, sys.stdout])
    if args.veryverbose:
        config.VVFiles.extend([config.GUIStream, sys.stdout])
    #modules = []
    #aptcache = []
    #cbuffer = {}
    '''root = Tkinter.Tk()
    App = None
    def startProg(splash):
        global modules, aptcache, cbuffer, App
        spprogn = 6
        spprog = 0
        def calcPercent(def2 = (spprog, spprogn)):
            return utilities.calcPercent(*def2)
        splash.setProgress(
            calcPercent((spprog, spprogn)), "Loading modules...")
        modules = []
        modulemetas = modloader.getModules()
        for i in modulemetas:
            modules.append(modloader.loadModule(i))
        spprog += 1
        splash.setProgress(
            calcPercent((spprog, spprogn)), "Parsing configuration...")
        #buffer1 = utilities.getBuffer(open(relinuxdir + "/relinux.conf"))
        #buffer2 = configutils.compress(buffer1)
        #cbuffer = configutils.parseCompressedBuffer(buffer2, relinuxdir + "/relinux.conf")
        configfiles = [relinuxdir + "/relinux.conf"]
        for i in range(len(modulemetas)):
            for x in modules[i].moduleconfig:
                configfiles.append(
                    os.path.join(os.path.dirname(modulemetas[i]["path"]), x))
        cbuffer = configutils.parseFiles(configfiles)
        config.Configuration = cbuffer
        configutils.saveBuffer(config.Configuration)
        \'''for i in configutils.beautify(buffer1):
            print(i)\'''
        spprog += 1
        splash.setProgress(
            calcPercent((spprog, spprogn)), "Reading APT Cache...")
        def aptupdate(op, percent):
            global minis
            if percent != None:
                minis += utilities.floatDivision(percent, 100)
            splash.setProgress(
                calcPercent((utilities.floatDivision(
                    minis + captop, aptops) + spprog, spprogn)),
                               "Reading APT Cache... (" + op + ")")
        def aptdone(op):
            global minis, captop
            minis = 0.0
            captop += 1
        aptcache = aptutil.getCache(aptutil.OpProgress(aptupdate, aptdone))
        config.AptCache = aptcache
        spprog += 1
        splash.setProgress(
            calcPercent((spprog, spprogn)), "Loading the GUI...")
        App = gui.GUI(root)
        spprog += 1
        splash.setProgress(
            calcPercent((spprog, spprogn)), "Filling in configuration...")
        App.fillConfiguration(cbuffer)
        spprog += 1
        splash.setProgress(
            calcPercent((spprog, spprogn)), "Running modules...")
        for i in modules:
            modloader.runModule(i,
                                {"gui": App, "config": cbuffer, "aptcache": aptcache})
        spprog += 1
        splash.setProgress(calcPercent((spprog, spprogn)), "Launching relinux")
    splash = gui.Splash(root, startProg)
    #root.overrideredirect(Tkinter.TRUE) # Coming soon!
    root.mainloop()'''
    App = QtGui.QApplication(sys.argv)
    splash = QtGui.QSplashScreen(
        QtGui.QPixmap(relinuxdir + "/splash_light.png"))
    splash.show()
    App.processEvents()

    def showMessage(str_):
        splash.showMessage(str_ + "...",
                           QtCore.Qt.AlignLeft | QtCore.Qt.AlignBottom)
        App.processEvents()

    showMessage(_("Loading modules"))
    modules = []
    modulemetas = modloader.getModules()
    for i in modulemetas:
        modules.append(modloader.loadModule(i))
    showMessage(_("Loading configuration files"))
    configfiles = [relinuxdir + "/relinux.conf"]
    for i in range(len(modulemetas)):
        for x in modules[i].moduleconfig:
            if "RELINUXCONFDIR" in os.environ:
                configfiles.append(os.path.join(relinuxdir, x))
            else:
                configfiles.append(
                    os.path.join(os.path.dirname(modulemetas[i]["path"]), x))
    cbuffer = configutils.parseFiles(configfiles)
    config.Configuration = cbuffer
    configutils.saveBuffer(config.Configuration)
    logfilename = configutils.getValue(cbuffer["Relinux"]["LOGFILE"])
    logfile = open(logfilename, "a")
    config.EFiles.append(logfile)
    config.IFiles.append(logfile)
    config.VFiles.append(logfile)
    config.VVFiles.append(logfile)
    logger.logI(tn, logger.I, "===========================")
    logger.logI(tn, logger.I, "=== Started new session ===")
    logger.logI(tn, logger.I, "===========================")
    showMessage(_("Loading APT cache 0%"))

    def aptupdate(op, percent):
        global minis
        if percent:
            minis = int(percent)
        showMessage(
            _("Loading APT cache") + " (" + op + ") " + str(minis) + "%")

    aptcache = aptutil.getCache(aptutil.OpProgress(aptupdate, None))
    config.AptCache = aptcache
    if not args.nostylesheet:
        showMessage(_("Loading stylesheet"))
        App.setStyleSheet(open(mainsrcdir + "/stylesheet.css", "r").read())
    showMessage(_("Loading GUI"))
    gui_ = gui.GUI(App)
    config.Gui = gui_
    showMessage(_("Running modules"))
    for i in modules:
        modloader.runModule(i, {})
    gui_.show()
    splash.finish(gui_)
    exitcode = App.exec_()
    config.ThreadStop = True
    logfile.close()
    sys.exit(exitcode)
Exemple #41
0
 def runthread(self):
     logger.logI(self.tn, logger.I, _("Generating ISO Tree"))
     # Make the tree
     print(isotreel)
     fsutil.maketree([isotreel + "casper", isotreel + "preseed",
                       isotreel + "isolinux", isotreel + ".disk"])
Exemple #42
0
 def page(self, page_num):
     if page_num < len(self.pages):
         return self.pages[page_num]
     else:
         logger.logI(tn, logger.E, _("Page") + " " + str(page_num) + " " + _("does not exist"))
Exemple #43
0
 def runthread(self):
     # Setup the password and group stuff
     logger.logI(self.tn, logger.I, _("Removing conflicting users"))
     passwdf = tmpsys + "etc/passwd"
     #passwdfile = open(passwdf, "r")
     #passwdstat = fsutil.getStat(passwdf)
     #passwdbuffer = configutils.getBuffer(passwdfile)
     #passwdfile.close()
     #passwdfile = open(passwdf, "w")
     buffers = fsutil.ife_getbuffers(passwdf)
     pe = pwdmanip.parsePasswdEntries(buffers[3])
     buffers[3] = pe
     # Users to "delete" on the live system
     logger.logV(self.tn, logger.I, _("Gathering users to remove"))
     nobody = ""
     for x in pe:
         if x["user"] == "nobody":
             nobody = x
     max_uid = 1999
     sysrange = 500
     if not isinstance(nobody, dict):
         logger.logV(self.tn, logger.E,
                     _("User 'nobody' could not be found!"))
     else:
         nuid = int(nobody["uid"])
         if nuid <= 100:
             # nobody has been assigned to the conventional system UID range
             max_uid = 1999
             sysrange = 100
         elif nuid < 500:
             # nobody has been assigned to the RHEL system UID range
             max_uid = 1999
             sysrange = 500
         elif nuid >= 65530 and nuid <= 65535:
             # nobody has been assigned to the highest possible unsigned short integer (16 bit) range
             max_uid = nuid - 1
             sysrange = 555
         elif nuid >= 32766:
             # nobody has been assigned to the highest possible signed short integer (16 bit) range
             max_uid = nuid - 1
             sysrange = 500
         else:
             max_uid = 1999
             sysrange = 555
     usrs = pwdmanip.getPPByUID(numrange.gen_num_range(sysrange, max_uid),
                                pe)
     print(usrs)
     if config.VVStatus is False:
         logger.logV(self.tn, logger.I, _("Removing them"))
     logger.logVV(self.tn, logger.I, _("Removing users in /etc/passwd"))
     fsutil.ife(
         buffers, lambda line: [True, pwdmanip.PPtoEntry(line)]
         if not line in usrs else [False, ""])
     # Rewrite the password file
     #for i in ppe:
     #    if not i in usrs:
     #        passwdfile.write(pwdmanip.PPtoEntry(i))
     #fsutil.copystat(passwdstat, passwdf)
     #passwdfile.close()
     # Now for the group file
     logger.logVV(self.tn, logger.I, _("Removing users in /etc/group"))
     groupf = tmpsys + "etc/group"
     buffers = fsutil.ife_getbuffers(groupf)
     pe = pwdmanip.parseGroupEntries(buffers[3])
     buffers[3] = pe
     fsutil.ife(buffers, lambda line: self._parseGroup(line, usrs))
     # Work on both shadow files
     shadowf = tmpsys + "etc/shadow"
     gshadowf = tmpsys + "etc/gshadow"
     buffers = fsutil.ife_getbuffers(shadowf)
     gbuffers = fsutil.ife_getbuffers(gshadowf)
     pe = pwdmanip.parseShadowEntries(buffers[3])
     buffers[3] = pe
     # If you look carefully (or just do a quick google search :P), you will notice that gshadow files
     # are very similar to group files, so we can just parse them as if they were group files
     pe = pwdmanip.parseGroupEntries(gbuffers[3])
     gbuffers[3] = pe
     logger.logVV(self.tn, logger.I, _("Removing users in /etc/shadow"))
     fsutil.ife(buffers, lambda line: self._parseShadow(line, usrs))
     logger.logVV(self.tn, logger.I, _("Removing users in /etc/gshadow"))
     fsutil.ife(gbuffers, lambda line: self._parseGroup(line, usrs))
     logger.logV(self.tn, logger.I, _("Creating backups"))
     shutil.copy2(tmpsys + "etc/passwd", tmpsys + "etc/passwd-")
     shutil.copy2(tmpsys + "etc/group", tmpsys + "etc/group-")
     shutil.copy2(tmpsys + "etc/shadow", tmpsys + "etc/shadow-")
     shutil.copy2(tmpsys + "etc/gshadow", tmpsys + "etc/gshadow-")