Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 17027 | Differences between
and this patch

Collapse All | Expand All

(-)file_not_specified_in_diff (-4 / +88 lines)
Line 19 Link Here
19
"regen", "rsync",  "search",   "sync", "system", "unmerge", "world"
19
"regen", "rsync",  "search",   "sync", "system", "unmerge", "world",
20
--
20
"diff" #Add diff to list of actions
Line 218 Link Here
218
if ("--pretend" in myopts) or (myaction=="search"):
219
if ("--pretend" in myopts) or (myaction in ["search", "diff"] ): #Do not require root to see diffs
219
--
Line 1652 Link Here
1653
#INSERTED
1654
#Prints a list of packages, showing differences in compile-time options to the settings that would be used if
1655
#recompiled now. If an argument is supplied, it only displays packages of which the argument is a substring.
1656
#The location of the vardbtree is hardcoded because it is in the vardbiapi.
1657
#TODO: allow regular expressions as search arguments.
1658
elif "diff"==myaction:
1659
	#If we were supplied with a search string
1660
	if ( myfiles ):
1661
		print "Scaning for packagenames including \"" + myfiles[0] + "\"."
1662
	else:
1663
		print "Scanning all packages." 
1664
	print
1665
	
1666
	#Set root for vardb
1667
	myRoot = portage.root + "var/db/pkg/"
1668
	#Get a list of the options currenty used to compile.
1669
	currCFlags = portage.settings["CFLAGS"].split( " " )
1670
		
1671
	#Scan through all categories
1672
	try:
1673
		categories = portage.listdir ( myRoot )
1674
	except OSError:
1675
		print "Error opening catalogue " + myRoot + "."
1676
		sys.exit(-1)
1677
	
1678
	categories.sort()
1679
	for y in categories:
1680
		#Scan through all packages, listing their flags
1681
		try:
1682
			pkgList = portage.listdir ( myRoot + y )
1683
		except OSError:
1684
			pkgList = [] #In case there is a file in the /var/db/pkg/
1685
		pkgList.sort()
1686
		for x in pkgList:
1687
			#Check if this file satisfies search criteria
1688
			#TODO: replace string.find by regular expression equiv. 
1689
			if ( not myfiles or string.find ( y + "/" + x, myfiles[0] ) >=0 ):
1690
				#Print name of package
1691
				print green("*") + y + "/" + x + ": "
1692
				#Get info about package
1693
				try:
1694
					myCFlagsFile = open ( myRoot + y + "/" + x + "/CFLAGS", "r" )
1695
				except (IOError,OSError): 
1696
					print red( "Error opening CFLAGS file" )
1697
					print
1698
					continue #Skip this package and go on to next one.
1699
					
1700
				#Read in file, stripping last char, which is a '\n'
1701
				myCFlagsData = string.rstrip ( myCFlagsFile.readline() ) 
1702
				#Split data into separate options
1703
				myCFlags = myCFlagsData.split( " " )
1704
				#Make a list of settings this package does not have
1705
				myCFlagsLacking = ""
1706
				for z in currCFlags:
1707
					if ( not z in myCFlags ):
1708
						myCFlagsLacking += ( z + " " )
1709
1710
				#Make a list of settings this package has in excess
1711
				myCFlagsExtra = ""
1712
				for z in myCFlags:
1713
					if ( not z in currCFlags ):
1714
						myCFlagsExtra += ( z + " " )					
1715
1716
				#If settings match
1717
				if ( not myCFlagsLacking and not myCFlagsExtra ):
1718
					print blue("Up to date")
1719
					
1720
				#If there are differences
1721
				else:
1722
					#Print options
1723
					print red("Lacks:  ") + myCFlagsLacking
1724
					print red("Excess: ") + myCFlagsExtra
1725
				#Done displaying this package
1726
				print 
1727
				#Close cflags file
1728
				myCFlagsFile.close()
1729
			#else:
1730
				#Package does not match criteria. Do not show.
1731
				#print y + "/" + x + " " + str( string.find( myfiles[0], y + "/" + x ) )
1732
			#End processing file. If no match then nothing done
1733
		#End scanning packages
1734
	#End scanning categories
1735
1736
#/INSERTED
1737

Return to bug 17027