예제 #1
0
 def updateConfig(self, dv):
     if not os.path.exists("/etc/calculate/calculate.env") and not (
         dv.Get("cl_core_pkg_name") in ("calculate-utilities", "calculate-install")
         and getTupleVersion(dv.Get("cl_core_pkg_version")) >= getTupleVersion("3.1.0_alpha4")
     ):
         self.printWARNING(_("Configuration skipping until calculate-utilities are updated"))
         return True
     self.initVars(dv)
     clVars = DataVars()
     clVars.importData()
     clVars.flIniFile()
     slot = dv.Get("cl_core_pkg_slot")
     version = dv.Get("cl_core_pkg_version")
     category = dv.Get("cl_core_pkg_category")
     nameProgram = dv.Get("cl_core_pkg_name")
     # define that category/nameProgram installed
     if dv.Get("cl_ebuild_phase") in ("prerm", "postrm"):
         version = ""
     dictVer = {slot: version}
     cl_template.templateFunction.installProg.update(
         {"%s/%s" % (category, nameProgram): dictVer, "%s" % (nameProgram): dictVer}
     )
     try:
         if os.environ.get("EBUILD_PHASE", ""):
             clVars.raiseVariableNotFound = lambda name, *args, **kwargs: StubVariable(*args, **kwargs)
             clVars.raiseModuleError = lambda name, *args, **kwargs: False
         if dv.Get("cl_core_pkg_system_set") == "on":
             self.updateSystemConfig(dv, clVars)
         if dv.Get("cl_core_pkg_desktop_set") == "on" and not dv.Get("cl_ebuild_phase") in ("preinst", "prerm"):
             self.updateDesktopConfig(dv, clVars)
     finally:
         if clVars:
             clVars.close()
     return True
예제 #2
0
class PackageUpdater(updateSystemConfigs, updateUserConfigs):
    def __init__(self):
        self.clVars = None
        self.clTempl = None

    def initVars(self, datavars=None):
        """Primary variables initialization"""
        if not datavars:
            self.clVars = DataVars()
            self.clVars.importData()
            self.clVars.flIniFile()
        else:
            self.clVars = datavars

    def closeClTemplate(self):
        if self.clTempl:
            if self.clTempl.cltObj:
                self.clTempl.cltObj.closeFiles()
            self.clTempl.closeFiles()
            self.clTempl = None

    def postAction(self, error):
        """
        Post action for umount user res and write status_sync=error
        """
        self.closeClTemplate()
        return True

    @safetyWrapper(
        native_errors=(cl_template.TemplatesError,), man_int=__("Manually interrupted"), post_action=postAction
    )
    def patchPackage(self, dv):
        self.initVars(dv)
        configPath = dv.Get("cl_core_pkg_path")
        dv.Set("cl_root_path", configPath, True)
        clTempl = ChainProgressTemplate(
            self.startTask,
            self.endTask,
            self.setProgress,
            self.clVars,
            cltObj=False,
            printSUCCESS=self.printSUCCESS,
            printERROR=self.printERROR,
            askConfirm=self.askConfirm,
            printWARNING=self.printWARNING,
            printWarning=False,
        )
        nameProgram = self.clVars.Get("cl_core_pkg_name")
        clTempl.onFirstValue = lambda *args: self.startTask(
            _("Using patches for the {nameProgram} package by " "Calculate Utilities").format(nameProgram=nameProgram),
            progress=True,
        )
        dirsFiles = clTempl.applyTemplates()
        return True

    @safetyWrapper(
        native_errors=(cl_template.TemplatesError,), man_int=__("Manually interrupted"), post_action=postAction
    )
    def updateConfig(self, dv):
        if not os.path.exists("/etc/calculate/calculate.env") and not (
            dv.Get("cl_core_pkg_name") in ("calculate-utilities", "calculate-install")
            and getTupleVersion(dv.Get("cl_core_pkg_version")) >= getTupleVersion("3.1.0_alpha4")
        ):
            self.printWARNING(_("Configuration skipping until calculate-utilities are updated"))
            return True
        self.initVars(dv)
        clVars = DataVars()
        clVars.importData()
        clVars.flIniFile()
        slot = dv.Get("cl_core_pkg_slot")
        version = dv.Get("cl_core_pkg_version")
        category = dv.Get("cl_core_pkg_category")
        nameProgram = dv.Get("cl_core_pkg_name")
        # define that category/nameProgram installed
        if dv.Get("cl_ebuild_phase") in ("prerm", "postrm"):
            version = ""
        dictVer = {slot: version}
        cl_template.templateFunction.installProg.update(
            {"%s/%s" % (category, nameProgram): dictVer, "%s" % (nameProgram): dictVer}
        )
        try:
            if os.environ.get("EBUILD_PHASE", ""):
                clVars.raiseVariableNotFound = lambda name, *args, **kwargs: StubVariable(*args, **kwargs)
                clVars.raiseModuleError = lambda name, *args, **kwargs: False
            if dv.Get("cl_core_pkg_system_set") == "on":
                self.updateSystemConfig(dv, clVars)
            if dv.Get("cl_core_pkg_desktop_set") == "on" and not dv.Get("cl_ebuild_phase") in ("preinst", "prerm"):
                self.updateDesktopConfig(dv, clVars)
        finally:
            if clVars:
                clVars.close()
        return True