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 (-92 / +2 lines)
Line 17 Link Here
17
actions=["clean", "config", "help", "info", "prune", "rsync", "search", "sync", "system", "unmerge", "world", "inject", "regen", "depclean", "diff"]
17
actions=["clean", "config", "help", "info", "prune", "rsync", "search", "sync", "system", "unmerge", "world", "inject", "regen", "depclean"]
18
--
Lines 140-142 Link Here
140
#if ("--pretend" in myopts) or (myaction=="search"): #REMOVED
140
if ("--pretend" in myopts) or (myaction=="search"):
141
if ("--pretend" in myopts) or (myaction in ["search","diff"]): #INSERTED
142
143
--
Lines 1443-1528 Link Here
1443
1444
#INSERTED
1445
#Prints a list of packages, showing differences in compile-time options to the settings that would be used if
1446
#recompiled now. If an argument is supplied, it only displays packages of which the argument is a substring.
1447
#The location of the vardbtree is hardcoded because it is in the vardbiapi.
1448
#TODO: allow regular expressions as search arguments.
1449
elif "diff"==myaction:
1450
	#If we were supplied with a search string
1451
	if ( myfiles ):
1452
		print "Scaning for packagenames including \"" + myfiles[0] + "\"."
1453
	else:
1454
		print "Scanning all packages." 
1455
	print
1456
	
1457
	#Set root for vardb
1458
	myRoot = portage.root + "var/db/pkg/"
1459
	#Get a list of the options currenty used to compile.
1460
	currCFlags = portage.settings["CFLAGS"].split( " " )
1461
		
1462
	#Scan through all categories
1463
	try:
1464
		categories = portage.listdir ( myRoot )
1465
	except OSError:
1466
		print "Error opening catalogue " + myRoot + "."
1467
		sys.exit(-1)
1468
	
1469
	categories.sort()
1470
	for y in categories:
1471
		#Scan through all packages, listing their flags
1472
		try:
1473
			pkgList = portage.listdir ( myRoot + y )
1474
		except OSError:
1475
			pkgList = [] #In case there is a file in the /var/db/pkg/
1476
		pkgList.sort()
1477
		for x in pkgList:
1478
			#Check if this file satisfies search criteria
1479
			#TODO: replace string.find by regular expression equiv. 
1480
			if ( not myfiles or string.find ( y + "/" + x, myfiles[0] ) >=0 ):
1481
				#Print name of package
1482
				print green("*") + y + "/" + x + ": "
1483
				#Get info about package
1484
				try:
1485
					myCFlagsFile = open ( myRoot + y + "/" + x + "/CFLAGS", "r" )
1486
				except (IOError,OSError): 
1487
					print red( "Error opening CFLAGS file" )
1488
					print
1489
					continue #Skip this package and go on to next one.
1490
					
1491
				#Read in file, stripping last char, which is a '\n'
1492
				myCFlagsData = string.rstrip ( myCFlagsFile.readline() ) 
1493
				#Split data into separate options
1494
				myCFlags = myCFlagsData.split( " " )
1495
				#Make a list of settings this package does not have
1496
				myCFlagsLacking = ""
1497
				for z in currCFlags:
1498
					if ( not z in myCFlags ):
1499
						myCFlagsLacking += ( z + " " )
1500
1501
				#Make a list of settings this package has in excess
1502
				myCFlagsExtra = ""
1503
				for z in myCFlags:
1504
					if ( not z in currCFlags ):
1505
						myCFlagsExtra += ( z + " " )					
1506
1507
				#If settings match
1508
				if ( not myCFlagsLacking and not myCFlagsExtra ):
1509
					print blue("Up to date")
1510
					
1511
				#If there are differences
1512
				else:
1513
					#Print options
1514
					print red("Lacks:  ") + myCFlagsLacking
1515
					print red("Excess: ") + myCFlagsExtra
1516
				#Done displaying this package
1517
				print 
1518
				#Close cflags file
1519
				myCFlagsFile.close()
1520
			#else:
1521
				#Package does not match criteria. Do not show.
1522
				#print y + "/" + x + " " + str( string.find( myfiles[0], y + "/" + x ) )
1523
			#End processing file. If no match then nothing done
1524
		#End scanning packages
1525
	#End scanning categories
1526
1527
#/INSERTED
1528

Return to bug 17027