Пример #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
 def sortdistrfunc(self,x,y):
     """Func of comparing two distributive"""
     ver1, ver2 = x[1].get('os_linux_ver',""), y[1].get('os_linux_ver',"")
     if ver1 and ver2 and ver1 != "0" and ver2 != "0" and ver1 != ver2:
         return cmpVersion(ver1,ver2)
     build1 = getTupleVersion(x[1].get('os_linux_build',""))
     build2 = getTupleVersion(y[1].get('os_linux_build',""))
     if  build1 != build2:
         return cmp(build1,build2)
     else:
         ext1 = x[1].get('ext',"")
         ext2 = y[1].get('ext',"")
         return self.extcomparator(ext1,ext2)
Пример #3
0
    def _getAvailableDistributives(self,dirs,system=None,shortname=None,
                                   march=None,version=None,build=None):
        """Get all distributives by filter"""
        def systemByName(name):
            return self.dictNameSystem.get(name.upper(),"")
        verCmp, version = self.opcompareByString(version)
        if version:
            version = getTupleVersion(version)
        buildCmp, build = self.opcompareByString(build)
        if build and build.isdigit():
            build = int(build)
        def distfilter(dist):
            d = self._getDistrInfo(dist)
            if not d:
                return False
            # check filter conditions
            if system and systemByName(d['os_linux_shortname']) != system:
                return False
            if not "os_linux_shortname" in d or not "os_linux_ver" in d:
                return False
            if shortname and \
                d['os_linux_shortname'].lower() != shortname.lower():
                return False
            if march and d['os_arch_machine'] != march:
                return False
            if version and \
                not verCmp(getTupleVersion(d['os_linux_ver']), version):
                return False
            if build and "os_linux_build" in d and \
                (not d['os_linux_build'].isdigit() or 
                 not buildCmp(int(d['os_linux_build']),build)):
                return False
            return True

        def listdistr(pathname):
            if path.exists(path.join(pathname,'etc/make.profile')) or \
               path.exists(path.join(pathname,'livecd')) or \
               pathname.startswith('/dev/'):
                return [pathname]
            else:
                # discard inner directories
                return filter(lambda x:not path.isdir( path.join(pathname,x)),
                              listDirectory(pathname))

        # get lists files in directories
        allFiles = map(lambda x: map(lambda y: path.join(x,y),
                                     listdistr(x)),
                   dirs)
        # filter distributives
        return filter(distfilter,
                      # join files lists to one list
                      reduce(lambda x,y: x + y,
                             allFiles, []))
Пример #4
0
 def get(self):
     widthVal = self.Get('os_x11_width')
     heightVal = self.Get('os_x11_height')
     if not widthVal or not heightVal:
         return ""
     width = int(widthVal)
     height = int(heightVal)
     gep = sqrt(height**2+width**2)
     k = float(width)/float(height)
     for themePkg in ['media-gfx/cldx-themes',
                      'media-gfx/cld-themes',
                      'media-gfx/cldg-themes']:
         installed = isPkgInstalled(themePkg,
                                    prefix=self.Get('cl_chroot_path'))
         if installed and \
             getTupleVersion(installed[0]['PV']) < getTupleVersion("12"):
             res = [(1024,600), (1024,768),
                    (1280,1024), (1280,800),
                    (1366,768), (1440,900),
                    (1600,1200), (1680,1050),
                    (1920,1200)] 
             break
     else:
         res = [(1024,576), (1024,600),
                (1024,768), (1200,800), (1280,1024),
                (1280,720), (1280,768), (1280,800),
                (1360,768), (1366,768), (1368,768),
                (1400,1050), (1440,900), (1600,1200),
                (1600,768), (1600,900), (1680,1050),
                (1680,945), (1920,1080), (1920,1200),
                (2048,1152), (2560,1440), (2560,1600),
                (640,480), (800,480) ]
     bestRes = min(res,
               key=lambda x:(abs(x[0]/float(x[1])-k),
                             abs(gep-sqrt(x[0]**2+x[1]**2))))
     return "%sx%s"%bestRes
Пример #5
0
 def get(self):
     bootdir = path.join(self.Get('cl_chroot_path'),'boot')
     modulesdir = path.join(self.Get('cl_chroot_path'),'lib/modules')
     validKernel = listDirectory(modulesdir)
     kernelFiles = self.getFilesByType(bootdir,"Linux kernel")
     installMarch = self.Get('os_install_arch_machine')
     kernelsWithVer = \
         map(lambda x:(x[0],(getTupleVersion("".join(x[1].groups()[0:3:2])),
                             path.getmtime(x[0]))),
         # convert version to tuple( versionTuple, mtime)
         # version detect, for this version lib contains moudules
         # kernel arch equal install arch
         ifilter(lambda x:x[1] and x[1].group() in validKernel and
                    installMarch in x[0].rpartition('/')[2],
         # (filename,version)
         imap(lambda x:(x[0],self.reFindVer.search(x[1])),
         kernelFiles)))
     if kernelsWithVer:
         return path.split(max(kernelsWithVer,key=itemgetter(1))[0])[-1]
     else:
         return "vmlinuz"
Пример #6
0
 def distfilter(dist):
     d = self._getDistrInfo(dist)
     if not d:
         return False
     # check filter conditions
     if system and systemByName(d['os_linux_shortname']) != system:
         return False
     if not "os_linux_shortname" in d or not "os_linux_ver" in d:
         return False
     if shortname and \
         d['os_linux_shortname'].lower() != shortname.lower():
         return False
     if march and d['os_arch_machine'] != march:
         return False
     if version and \
         not verCmp(getTupleVersion(d['os_linux_ver']), version):
         return False
     if build and "os_linux_build" in d and \
         (not d['os_linux_build'].isdigit() or 
          not buildCmp(int(d['os_linux_build']),build)):
         return False
     return True
Пример #7
0
 def get(self):
     pkg = isPkgInstalled("%s/%s" % (self.Get("cl_core_pkg_category"), self.Get("cl_core_pkg_name")))
     if pkg:
         return sorted(pkg, key=lambda x: getTupleVersion(x["PVR"]))[-1]["PVR"]
     return ""