示例#1
0
    defaultCategory = os.environ["EMERGE_DEFAULTCATEGORY"]
else:
    defaultCategory = "kde"

if updateAll:
    installedPackages = portage.PortageInstance.getInstallables()
    if portage.PortageInstance.isCategory( packageName ):
        utils.debug( "Updating installed packages from category " + packageName, 1 )
    else:
        utils.debug( "Updating all installed packages", 1 )
    packageList = []
    for mainCategory, mainPackage, mainVersion in installedPackages:
        if portage.PortageInstance.isCategory( packageName ) and ( mainCategory != packageName ):
            continue
        if portage.isInstalled( mainCategory, mainPackage, mainVersion, buildType ) \
                and portage.isPackageUpdateable( mainCategory, mainPackage, mainVersion ):
            categoryList.append( mainCategory )
            packageList.append( mainPackage )
    utils.debug( "Will update packages: " + str (packageList), 1 )
elif packageName:
    packageList, categoryList = portage.getPackagesCategories(packageName)

for entry in packageList:
    utils.debug( "%s" % entry, 1 )
utils.debug_line( 1 )

for mainCategory, entry in zip (categoryList, packageList):
    _deplist = portage.solveDependencies( mainCategory, entry, "", _deplist )

deplist = [p.ident() for p in _deplist]
示例#2
0
def handleSinglePackage( packageName, action, args ):
    deplist = [ ]
    packageList = [ ]
    originalPackageList = [ ]
    categoryList = [ ]
    targetDict = dict( )

    if action == "update-all":
        installedPackages = portage.PortageInstance.getInstallables( )
        if portage.PortageInstance.isCategory( packageName ):
            EmergeDebug.debug("Updating installed packages from category " + packageName, 1)
        else:
            EmergeDebug.debug("Updating all installed packages", 1)
        packageList = [ ]
        for mainCategory, mainPackage in installedPackages:
            if portage.PortageInstance.isCategory( packageName ) and ( mainCategory != packageName ):
                continue
            if InstallDB.installdb.isInstalled( mainCategory, mainPackage, args.buildType ) \
                    and portage.isPackageUpdateable( mainCategory, mainPackage ):
                categoryList.append( mainCategory )
                packageList.append( mainPackage )
        EmergeDebug.debug("Will update packages: " + str(packageList), 1)
    elif args.list_file:
        listFileObject = open( args.list_file, 'r' )
        for line in listFileObject:
            if line.strip( ).startswith( '#' ): continue
            try:
                cat, pac, tar, _ = line.split( ',' )
            except:
                continue
            categoryList.append( cat )
            packageList.append( pac )
            originalPackageList.append( pac )
            targetDict[ cat + "/" + pac ] = tar
    elif packageName:
        packageList, categoryList = portage.getPackagesCategories( packageName )

    for entry in packageList:
        EmergeDebug.debug("Checking dependencies for: %s" % entry, 1)

    for mainCategory, entry in zip( categoryList, packageList ):
        deplist = portage.solveDependencies( mainCategory, entry, deplist, args.dependencyType,
                                              maxDepth = args.dependencydepth )
    # no package found
    if len( deplist ) == 0:
        category = ""
        if not packageName.find( "/" ) == -1:
            (category, package) = packageName.split( "/" )
        portageSearch.printSearch( category, packageName )
        return False

    for item in deplist:
        item.enabled = args.ignoreAllInstalled

        if args.ignoreInstalled and item.category in categoryList and item.package in packageList or packageIsOutdated(
                item.category, item.package ):
            item.enabled = True

        if item.category + "/" + item.package in targetDict:
            item.target = targetDict[ item.category + "/" + item.package ]

        if args.target in list(
                portage.PortageInstance.getAllTargets( item.category, item.package ).keys( ) ):
            # if no target or a wrong one is defined, simply set the default target here
            item.target = args.target

        EmergeDebug.debug("dependency: %s" % item, 1)
    if not deplist:
        EmergeDebug.debug("<none>", 1)

    EmergeDebug.debug_line(1)

    #for item in deplist:
    #    cat = item[ 0 ]
    #    pac = item[ 1 ]
    #    ver = item[ 2 ]

    #    if portage.isInstalled( cat, pac, ver, buildType) and updateAll and not portage.isPackageUpdateable( cat, pac, ver ):
    #        print "remove:", cat, pac, ver
    #        deplist.remove( item )

    if action == "install-deps":
        # the first dependency is the package itself - ignore it
        # TODO: why are we our own dependency?
        del deplist[ 0 ]
    elif action == "update-direct-deps":
        for item in deplist:
            item.enabled = True

    deplist.reverse( )

    # package[0] -> category
    # package[1] -> package
    # package[2] -> version

    info = deplist[ -1 ]
    if not portage.PortageInstance.isVirtualPackage( info.category, info.package ) and \
        not action in [ "all", "install-deps" ,"generate-jenkins-job"] and\
        not args.list_file or\
        action in ["print-targets"]:#not all commands should be executed on the deps if we are a virtual packages
        # if a buildAction is given, then do not try to build dependencies
        # and do the action although the package might already be installed.
        # This is still a bit problematic since packageName might not be a valid
        # package
        # for list files, we also want to handle fetching & packaging per package

        if not handlePackage( info.category, info.package, action, args.doContinue, args.update_fast ):
            utils.notify( "Emerge %s failed" % action, "%s of %s/%s failed" % (
                action, info.category, info.package), action )
            return False
        utils.notify( "Emerge %s finished" % action,
                      "%s of %s/%s finished" % ( action, info.category, info.package),
                      action )

    else:
        if args.dumpDepsFile:
            dumpDepsFileObject = open( args.dumpDepsFile, 'w+' )
            dumpDepsFileObject.write( "# dependency dump of package %s\n" % ( packageName ) )
        for info in deplist:
            isVCSTarget = False

            if args.dumpDepsFile:
                dumpDepsFileObject.write( ",".join( [ info.category, info.package, info.target, "" ] ) + "\n" )

            isLastPackage = info == deplist[ -1 ]
            if args.outDateVCS or (args.outDatePackage and isLastPackage):
                isVCSTarget = portage.PortageInstance.getUpdatableVCSTargets( info.category, info.package ) != [ ]
            isInstalled = InstallDB.installdb.isInstalled( info.category, info.package )
            if args.list_file and action != "all":
                info.enabled = info.package in originalPackageList
            if ( isInstalled and not info.enabled ) and not (
                            isInstalled and (args.outDateVCS or (
                                    args.outDatePackage and isLastPackage) ) and isVCSTarget ):
                if EmergeDebug.verbose() > 1 and info.package == packageName:
                    EmergeDebug.warning("already installed %s/%s" % (info.category, info.package))
                elif EmergeDebug.verbose() > 2 and not info.package == packageName:
                    EmergeDebug.warning("already installed %s/%s" % (info.category, info.package))
            else:
                # in case we only want to see which packages are still to be build, simply return the package name
                if args.probe:
                    if EmergeDebug.verbose() > 0:
                        EmergeDebug.warning("pretending %s" % info)
                else:
                    if action in [ "install-deps", "update-direct-deps" ]:
                        action = "all"

                    if not handlePackage( info.category, info.package, action, args.doContinue, args.update_fast ):
                        EmergeDebug.error("fatal error: package %s/%s %s failed" % \
                                          ( info.category, info.package, action ))
                        utils.notify( "Emerge build failed",
                                      "Build of %s/%s failed" % ( info.category, info.package),
                                      action )
                        return False
                    utils.notify( "Emerge build finished",
                                  "Build of %s/%s finished" % ( info.category, info.package),
                                  action )

    EmergeDebug.new_line()
    return True
示例#3
0
def handleSinglePackage(packageName, action, args):
    deplist = []
    packageList = []
    originalPackageList = []
    categoryList = []
    targetDict = dict()

    if action == "update-all":
        installedPackages = portage.PortageInstance.getInstallables()
        if portage.PortageInstance.isCategory(packageName):
            EmergeDebug.debug(
                "Updating installed packages from category " + packageName, 1)
        else:
            EmergeDebug.debug("Updating all installed packages", 1)
        packageList = []
        for mainCategory, mainPackage in installedPackages:
            if portage.PortageInstance.isCategory(packageName) and (
                    mainCategory != packageName):
                continue
            if InstallDB.installdb.isInstalled( mainCategory, mainPackage, args.buildType ) \
                    and portage.isPackageUpdateable( mainCategory, mainPackage ):
                categoryList.append(mainCategory)
                packageList.append(mainPackage)
        EmergeDebug.debug("Will update packages: " + str(packageList), 1)
    elif args.list_file:
        listFileObject = open(args.list_file, 'r')
        for line in listFileObject:
            if line.strip().startswith('#'): continue
            try:
                cat, pac, tar, _ = line.split(',')
            except:
                continue
            categoryList.append(cat)
            packageList.append(pac)
            originalPackageList.append(pac)
            targetDict[cat + "/" + pac] = tar
    elif packageName:
        packageList, categoryList = portage.getPackagesCategories(packageName)

    for entry in packageList:
        EmergeDebug.debug("Checking dependencies for: %s" % entry, 1)

    for mainCategory, entry in zip(categoryList, packageList):
        deplist = portage.solveDependencies(mainCategory,
                                            entry,
                                            deplist,
                                            args.dependencyType,
                                            maxDepth=args.dependencydepth)
    # no package found
    if len(deplist) == 0:
        category = ""
        if not packageName.find("/") == -1:
            (category, package) = packageName.split("/")
        portageSearch.printSearch(category, packageName)
        return False

    for item in deplist:
        item.enabled = args.ignoreAllInstalled

        if args.ignoreInstalled and item.category in categoryList and item.package in packageList or packageIsOutdated(
                item.category, item.package):
            item.enabled = True

        if item.category + "/" + item.package in targetDict:
            item.target = targetDict[item.category + "/" + item.package]

        if args.target in list(
                portage.PortageInstance.getAllTargets(item.category,
                                                      item.package).keys()):
            # if no target or a wrong one is defined, simply set the default target here
            item.target = args.target

        EmergeDebug.debug("dependency: %s" % item, 1)
    if not deplist:
        EmergeDebug.debug("<none>", 1)

    EmergeDebug.debug_line(1)

    #for item in deplist:
    #    cat = item[ 0 ]
    #    pac = item[ 1 ]
    #    ver = item[ 2 ]

    #    if portage.isInstalled( cat, pac, ver, buildType) and updateAll and not portage.isPackageUpdateable( cat, pac, ver ):
    #        print "remove:", cat, pac, ver
    #        deplist.remove( item )

    if action == "install-deps":
        # the first dependency is the package itself - ignore it
        # TODO: why are we our own dependency?
        del deplist[0]
    elif action == "update-direct-deps":
        for item in deplist:
            item.enabled = True

    deplist.reverse()

    # package[0] -> category
    # package[1] -> package
    # package[2] -> version

    info = deplist[-1]
    if not portage.PortageInstance.isVirtualPackage( info.category, info.package ) and \
        not action in [ "all", "install-deps"] and\
        not args.list_file or\
        action in ["print-targets"]:#not all commands should be executed on the deps if we are a virtual packages
        # if a buildAction is given, then do not try to build dependencies
        # and do the action although the package might already be installed.
        # This is still a bit problematic since packageName might not be a valid
        # package
        # for list files, we also want to handle fetching & packaging per package
        if not handlePackage(info.category, info.package, action,
                             args.doContinue, args.update_fast):
            return False

    else:
        if args.dumpDepsFile:
            dumpDepsFileObject = open(args.dumpDepsFile, 'w+')
            dumpDepsFileObject.write("# dependency dump of package %s\n" %
                                     (packageName))
        for info in deplist:
            isVCSTarget = False

            if args.dumpDepsFile:
                dumpDepsFileObject.write(
                    ",".join([info.category, info.package, info.target, ""]) +
                    "\n")

            isLastPackage = info == deplist[-1]
            if args.outDateVCS or (args.outDatePackage and isLastPackage):
                isVCSTarget = portage.PortageInstance.getUpdatableVCSTargets(
                    info.category, info.package) != []
            isInstalled = InstallDB.installdb.isInstalled(
                info.category, info.package)
            if args.list_file and action != "all":
                info.enabled = info.package in originalPackageList
            if (isInstalled and not info.enabled) and not (
                    isInstalled and
                (args.outDateVCS or
                 (args.outDatePackage and isLastPackage)) and isVCSTarget):
                if EmergeDebug.verbose() > 1 and info.package == packageName:
                    EmergeDebug.warning("already installed %s/%s" %
                                        (info.category, info.package))
                elif EmergeDebug.verbose(
                ) > 2 and not info.package == packageName:
                    EmergeDebug.warning("already installed %s/%s" %
                                        (info.category, info.package))
            else:
                # in case we only want to see which packages are still to be build, simply return the package name
                if args.probe:
                    EmergeDebug.warning("pretending %s" % info)
                else:
                    if action in ["install-deps", "update-direct-deps"]:
                        action = "all"

                    if not handlePackage(info.category, info.package, action,
                                         args.doContinue, args.update_fast):
                        EmergeDebug.error("fatal error: package %s/%s %s failed" % \
                                          ( info.category, info.package, action ))
                        return False

    EmergeDebug.new_line()
    return True
示例#4
0
    defaultCategory = os.environ["EMERGE_DEFAULTCATEGORY"]
else:
    defaultCategory = "kde"

if updateAll:
    installedPackages = portage.PortageInstance.getInstallables()
    if portage.PortageInstance.isCategory(packageName):
        utils.debug("Updating installed packages from category " + packageName, 1)
    else:
        utils.debug("Updating all installed packages", 1)
    packageList = []
    for mainCategory, mainPackage, mainVersion in installedPackages:
        if portage.PortageInstance.isCategory(packageName) and (mainCategory != packageName):
            continue
        if portage.isInstalled(mainCategory, mainPackage, mainVersion, buildType) and portage.isPackageUpdateable(
            mainCategory, mainPackage, mainVersion
        ):
            categoryList.append(mainCategory)
            packageList.append(mainPackage)
    utils.debug("Will update packages: " + str(packageList), 1)
elif packageName:
    packageList, categoryList = portage.getPackagesCategories(packageName)

for entry in packageList:
    utils.debug("%s" % entry, 1)
utils.debug_line(1)

for mainCategory, entry in zip(categoryList, packageList):
    _deplist = portage.solveDependencies(mainCategory, entry, "", _deplist)

deplist = [p.ident() for p in _deplist]