Exemplo n.º 1
0
 def getNightlyVersionsFromUrl(url, pattern, timeout = 10) -> [str]:
     """
     Returns a list of possible version number matching the regular expression in pattern.
     :param url: The url to look for the nightly builds.
     :param pattern: A regular expression to match the version.
     :param timeout:
     :return: A list of matching strings or [None]
     """
     if emergeSettings.getboolean("General", "WorkOffline"):
         EmergeDebug.info("Nightly builds unavailable for %s in offline mode." % url)
         return [None]
     if url in UtilsCache._NIGTHLY_URLS:
         return UtilsCache._NIGTHLY_URLS[url]
     else:
         try:
             with urllib.request.urlopen(url, timeout = timeout) as fh:
                 data = str(fh.read(), "UTF-8")
                 vers = re.findall( pattern , data)
                 if not vers:
                     print(data)
                     raise Exception("Pattern %s does not match." % pattern)
                 UtilsCache._NIGTHLY_URLS[url] = vers
                 return vers
         except Exception as e:
             EmergeDebug.warning("Nightly builds unavailable for %s: %s" % (url, e))
             return [None]
Exemplo n.º 2
0
def doExec(package, action, continueFlag=False):
    with EmergeTimer.Timer("%s for %s" % (action, package), 1):
        EmergeDebug.info("Action: %s for %s" % (action, package))
        ret = package.execute(action)
        if not ret:
            EmergeDebug.warning("Action: %s for %s FAILED" % (action, package))
        return ret or continueFlag
Exemplo n.º 3
0
def notify(title,message,alertClass = None):
    EmergeDebug.info("%s: %s" % (title, message))
    backends = emergeSettings.get( "General","EMERGE_USE_NOTIFY", "")
    if backends == "":
        return
    backends = Notifier.NotificationLoader.load(backends.split(";"))
    for backend in backends.values():
        backend.notify(title,message,alertClass)
Exemplo n.º 4
0
def handlePackage( category, packageName, buildAction, continueFlag, skipUpToDateVcs ):
    EmergeDebug.debug_line()
    EmergeDebug.info("Handling package: %s, action: %s" % (packageName, buildAction))

    success = True
    package = portage.getPackageInstance( category, packageName )
    if package is None:
        raise portage.PortageException( "Package not found", category, packageName )

    if buildAction in [ "all", "full-package", "update", "update-all" ]:
        success = success and doExec( package, "fetch", continueFlag )
        if success and skipUpToDateVcs and package.subinfo.hasSvnTarget( ):
            revision = package.sourceVersion( )
            for p in InstallDB.installdb.getInstalledPackages( category, packageName ):
                if p.getRevision( ) == revision:
                    EmergeDebug.info("Skipping further actions, package is up-to-date")
                    return True

        success = success and doExec( package, "unpack", continueFlag )
        success = success and doExec( package, "compile" )
        success = success and doExec( package, "cleanimage" )
        success = success and doExec( package, "install" )
        if buildAction in [ "all", "update", "update-all" ]:
            success = success and doExec( package, "qmerge" )
        if buildAction == "full-package":
            success = success and doExec( package, "package" )
        success = success or continueFlag
    elif buildAction in [ "fetch", "unpack", "configure", "compile", "make", "checkdigest",
                          "dumpdeps", "test",
                          "package", "unmerge", "cleanimage", "cleanbuild", "createpatch",
                          "geturls",
                          "print-revision",
                          "print-files"
                        ]:
        success = doExec( package, buildAction, continueFlag )
    elif buildAction == "install":
        success = doExec( package, "cleanimage" )
        success = success and doExec( package, "install", continueFlag )
    elif buildAction == "qmerge":
        #success = doExec( package, "cleanimage" )
        #success = success and doExec( package, "install")
        success = success and doExec( package, "qmerge" )
    elif buildAction == "generate-jenkins-job":
        success = jenkins.generateJob(package)
    elif buildAction == "print-source-version":
        print( "%s-%s" % ( packageName, package.sourceVersion( ) ) )
        success = True
    elif buildAction == "print-package-version":
        print( "%s-%s-%s" % ( packageName, compiler.getCompilerName( ), package.sourceVersion( ) ) )
        success = True
    elif buildAction == "print-targets":
        portage.printTargets( category, packageName )
        success = True
    else:
        success = EmergeDebug.error("could not understand this buildAction: %s" % buildAction)

    return success
Exemplo n.º 5
0
    def changePackager(self, packager=None):
        if not packager == None and ("Packager",
                                     "PackageType") in emergeSettings:
            EmergeDebug.info(
                "Packager setting %s overriten by with %s" %
                (packager, emergeSettings.get("Packager", "PackageType")))
            packager = eval(emergeSettings.get("Packager", "PackageType"))

        if packager == None:
            return

        self.__packager = packager
Exemplo n.º 6
0
def handlePackage(category, packageName, buildAction, continueFlag,
                  skipUpToDateVcs):
    with EmergeTimer.Timer("HandlePackage %s/%s" % (category, packageName),
                           3) as timer:
        EmergeDebug.debug_line()
        EmergeDebug.info("Handling package: %s, action: %s" %
                         (packageName, buildAction))

        success = True
        package = portage.getPackageInstance(category, packageName)
        if package is None:
            raise portage.PortageException("Package not found", category,
                                           packageName)

        if buildAction in ["all", "full-package", "update", "update-all"]:
            success = success and doExec(package, "fetch", continueFlag)
            skip = False
            if success and skipUpToDateVcs and package.subinfo.hasSvnTarget():
                revision = package.sourceVersion()
                for p in InstallDB.installdb.getInstalledPackages(
                        category, packageName):
                    if p.getRevision() == revision:
                        EmergeDebug.info(
                            "Skipping further actions, package is up-to-date")
                        skip = True
            if not skip:
                success = success and doExec(package, "unpack", continueFlag)
                success = success and doExec(package, "compile")
                success = success and doExec(package, "cleanimage")
                success = success and doExec(package, "install")
                if buildAction in ["all", "update", "update-all"]:
                    success = success and doExec(package, "qmerge")
                if buildAction == "full-package":
                    success = success and doExec(package, "package")
                success = success or continueFlag
        elif buildAction in [
                "fetch", "unpack", "configure", "compile", "make",
                "checkdigest", "dumpdeps", "test", "package", "unmerge",
                "cleanimage", "cleanbuild", "createpatch", "geturls",
                "print-revision", "print-files"
        ]:
            success = doExec(package, buildAction, continueFlag)
        elif buildAction == "install":
            success = doExec(package, "cleanimage")
            success = success and doExec(package, "install", continueFlag)
        elif buildAction == "qmerge":
            #success = doExec( package, "cleanimage" )
            #success = success and doExec( package, "install")
            success = success and doExec(package, "qmerge")
        elif buildAction == "print-source-version":
            print("%s-%s" % (packageName, package.sourceVersion()))
            success = True
        elif buildAction == "print-package-version":
            print("%s-%s-%s" % (packageName, compiler.getCompilerName(),
                                package.sourceVersion()))
            success = True
        elif buildAction == "print-targets":
            portage.printTargets(category, packageName)
            success = True
        else:
            success = EmergeDebug.error(
                "could not understand this buildAction: %s" % buildAction)

        timer.stop()
        utils.notify(
            "Emerge %s %s" %
            (buildAction, "succeeded" if success else "failed"),
            "%s of %s/%s %s after %s" %
            (buildAction, category, packageName,
             "succeeded" if success else "failed", timer), buildAction)
        return success
Exemplo n.º 7
0
 def __exit__(self, exc_type, exc_val, exc_tb):
     self.stop()
     if EmergeConfig.emergeSettings.getboolean( "EmergeDebug", "MeasureTime", False ):
         EmergeDebug.info( "Task: %s stopped after: %s" % (self.name , self))
Exemplo n.º 8
0
def doExec( package, action, continueFlag = False ):
    utils.startTimer( "%s for %s" % ( action, package ), 1 )
    EmergeDebug.info("Action: %s for %s" % (action, package))
    ret = package.execute( action )
    utils.stopTimer( "%s for %s" % ( action, package ) )
    return ret or continueFlag
Exemplo n.º 9
0
 def execute(self, path, cmd, args="", out=sys.stdout, err=sys.stderr):
     command = "%s --login -c \"export %s && cd %s && %s %s\"" % \
               ( self._sh, self._environmentSetup(), self.toNativePath( path ), self.toNativePath( cmd ), args )
     EmergeDebug.info("msys execute: %s" % command)
     return utils.system( command, stdout=out, stderr=err )
Exemplo n.º 10
0
 def __exit__(self, exc_type, exc_val, exc_tb):
     self.stop()
     if EmergeConfig.emergeSettings.getboolean("EmergeDebug", "MeasureTime",
                                               False):
         EmergeDebug.info("Task: %s stopped after: %s" % (self.name, self))
Exemplo n.º 11
0
 def execute(self, path, cmd, args="", out=sys.stdout, err=sys.stderr):
     command = "%s --login -c \"cd %s && %s %s\"" % \
               ( self._sh, self.toNativePath( path ), self.toNativePath( cmd ), args )
     EmergeDebug.info("msys execute: %s" % command)
     EmergeDebug.debug("msys environment: %s" % self.environment)
     return utils.system( command, stdout=out, stderr=err , env=self.environment)