17c17 < actions=["clean", "config", "help", "info", "prune", "rsync", "search", "sync", "system", "unmerge", "world", "inject", "regen", "depclean", "diff"] --- > actions=["clean", "config", "help", "info", "prune", "rsync", "search", "sync", "system", "unmerge", "world", "inject", "regen", "depclean"] 140,142c140 < #if ("--pretend" in myopts) or (myaction=="search"): #REMOVED < if ("--pretend" in myopts) or (myaction in ["search","diff"]): #INSERTED < --- > if ("--pretend" in myopts) or (myaction=="search"): 1443,1528d1440 < < #INSERTED < #Prints a list of packages, showing differences in compile-time options to the settings that would be used if < #recompiled now. If an argument is supplied, it only displays packages of which the argument is a substring. < #The location of the vardbtree is hardcoded because it is in the vardbiapi. < #TODO: allow regular expressions as search arguments. < elif "diff"==myaction: < #If we were supplied with a search string < if ( myfiles ): < print "Scaning for packagenames including \"" + myfiles[0] + "\"." < else: < print "Scanning all packages." < print < < #Set root for vardb < myRoot = portage.root + "var/db/pkg/" < #Get a list of the options currenty used to compile. < currCFlags = portage.settings["CFLAGS"].split( " " ) < < #Scan through all categories < try: < categories = portage.listdir ( myRoot ) < except OSError: < print "Error opening catalogue " + myRoot + "." < sys.exit(-1) < < categories.sort() < for y in categories: < #Scan through all packages, listing their flags < try: < pkgList = portage.listdir ( myRoot + y ) < except OSError: < pkgList = [] #In case there is a file in the /var/db/pkg/ < pkgList.sort() < for x in pkgList: < #Check if this file satisfies search criteria < #TODO: replace string.find by regular expression equiv. < if ( not myfiles or string.find ( y + "/" + x, myfiles[0] ) >=0 ): < #Print name of package < print green("*") + y + "/" + x + ": " < #Get info about package < try: < myCFlagsFile = open ( myRoot + y + "/" + x + "/CFLAGS", "r" ) < except (IOError,OSError): < print red( "Error opening CFLAGS file" ) < print < continue #Skip this package and go on to next one. < < #Read in file, stripping last char, which is a '\n' < myCFlagsData = string.rstrip ( myCFlagsFile.readline() ) < #Split data into separate options < myCFlags = myCFlagsData.split( " " ) < #Make a list of settings this package does not have < myCFlagsLacking = "" < for z in currCFlags: < if ( not z in myCFlags ): < myCFlagsLacking += ( z + " " ) < < #Make a list of settings this package has in excess < myCFlagsExtra = "" < for z in myCFlags: < if ( not z in currCFlags ): < myCFlagsExtra += ( z + " " ) < < #If settings match < if ( not myCFlagsLacking and not myCFlagsExtra ): < print blue("Up to date") < < #If there are differences < else: < #Print options < print red("Lacks: ") + myCFlagsLacking < print red("Excess: ") + myCFlagsExtra < #Done displaying this package < print < #Close cflags file < myCFlagsFile.close() < #else: < #Package does not match criteria. Do not show. < #print y + "/" + x + " " + str( string.find( myfiles[0], y + "/" + x ) ) < #End processing file. If no match then nothing done < #End scanning packages < #End scanning categories < < #/INSERTED <