Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 74513 Details for
Bug 115203
equery patch to query for which version of gcc has been used to compile an installed ebuild
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
equery gcc patch
gcc-query.patch (text/plain), 7.43 KB, created by
Stefano Varesi
on 2005-12-11 10:18:06 UTC
(
hide
)
Description:
equery gcc patch
Filename:
MIME Type:
Creator:
Stefano Varesi
Created:
2005-12-11 10:18:06 UTC
Size:
7.43 KB
patch
obsolete
>--- src/equery/equery.orig 2005-12-07 19:44:11.000000000 +0100 >+++ src/equery/equery 2005-12-11 19:08:40.000000000 +0100 >@@ -19,6 +19,7 @@ > import time > import string > import types >+import bz2 > > # portage (output module) and gentoolkit need special path modifications > sys.path.insert(0, "/usr/lib/portage/pym") >@@ -1478,6 +1479,182 @@ > " " + pp.localoption("-p, --portage-tree") + " - also search in portage tree (" + gentoolkit.settings["PORTDIR"] + ")\n" + \ > " " + pp.localoption("-o, --overlay-tree") + " - also search in overlay tree (" + gentoolkit.settings["PORTDIR_OVERLAY"] + ")\n" > >+class CmdDisplayGccInfo(Command): >+ """Display info about compiler and flags used to compile a package.""" >+ >+ def __init__(self): >+ self.default_opts = { >+ "allInstalledPackages": 0, >+ } >+ >+ def shortHelp(self): >+ return pp.localoption("<local-opts>") + " - display the gcc version used to compile a package" >+ >+ def longHelp(self): >+ return "Display th gcc version used to compile a particular a package\n" + \ >+ "\n" + \ >+ "Syntax:\n" + \ >+ " " + pp.command("gcc") + pp.localoption(" <local-opts> ") + "\n" + \ >+ " " + pp.command("gcc") + pp.pkgquery(" pkgspec") + "\n" + \ >+ pp.localoption("<local-opts>") + " is either of: \n" + \ >+ " " + pp.localoption("-A, --all") + " - scan all installed packages\n" >+ >+ def parseArgs(self, args): >+ >+ query = "" >+ need_help = 0 >+ opts = self.default_opts >+ skip = 0 >+ >+ if len(args)==0: >+ need_help=1 >+ >+ for i in xrange(len(args)): >+ >+ if skip: >+ skip -= 1 >+ continue >+ x = args[i] >+ >+ if x in ["-h","--help"]: >+ need_help = 1 >+ break >+ elif x in ["-A", "--all"]: >+ opts["allInstalledPackages"] = 1 >+ #elif len(args)==0: >+ >+ else: >+ query = x >+ >+ if need_help: >+ print_info(0, self.longHelp()) >+ sys.exit(-1) >+ >+ return (query, opts) >+ >+ def perform(self, args): >+ (query, opts)=self.parseArgs(args) >+ if opts["allInstalledPackages"]: >+ print_info(0,"[ Searching for gcc used for "+pp.pkgquery("all packages")+"... ]") >+ all=self._scanDb() >+ print_info(0," Last installed gcc slot: "+pp.number(all[0])) >+ print_info(0," Packages installed: "+pp.number(all[1])) >+ print_info(0," Packages compiled with a gcc of an old slot: "+portage.output.yellow(all[3])) >+ if len(all[4])!=0: >+ print_info(0,string.rjust("[SLOT]",13)+string.rjust("[VERSION]",13)) >+ for p in all[4]: >+ print_info(0,string.rjust("["+pp.number((p[0]))+"]",32)+string.rjust("["+pp.number((p[1]))+"]",32)+' '+pp.cpv(p[2])) >+ >+ else: >+ print_info(0,"[ Searching for packages matching "+pp.pkgquery(query+" ")+"... ]") >+ retval=self._getGccInfo(query) >+ for pkg in retval: >+ print_info(0,pp.section("*")+" gcc version used for "+pp.cpv(pkg["CPV"])) >+ print_info(0,string.rjust("host: ",16)+pp.number(pkg["CHOST"])) >+ print_info(0,string.rjust("C compiler: ",16)+pp.number(pkg["CC"])) >+ print_info(0,string.rjust("C++ compiler: ",16)+pp.number(pkg["CXX"])) >+ print_info(0,string.rjust("version: ",16)+pp.number(pkg["COMPILER"]["VERSION"])) >+ print_info(0,string.rjust("slot: ",16)+pp.number(pkg["COMPILER"]["SLOT"])) >+ print_info(0,string.rjust("C flags: ",16)+pp.number(pkg["CFLAGS"])) >+ print_info(0,string.rjust("C++ flags: ",16)+pp.number(pkg["CXXFLAGS"])) >+ >+ def _gccInstalledSlots(self): >+ slots=[] >+ expr=re.compile("^gcc-[0-9]") >+ for n in os.listdir(portage.root+portage.VDB_PATH+os.sep+"sys-devel"): >+ if expr.match(n): >+ slots.append(n) >+ slots.sort() >+ for n in slots: >+ slots[slots.index(n)]=open(portage.root+portage.VDB_PATH+os.sep+"sys-devel"+os.sep+n+os.sep+"SLOT", "r").read()[:-1] >+ return slots >+ >+ def _getGccInfo(self,pkg): >+ pkg_split=gentoolkit.split_package_name(pkg) >+ if pkg_split[2]!="": # if a specific version is given >+ if pkg_split[0]!="": # if the category of the package is given >+ if pkg_split[0][0]!="=": # if the category is not preceded by an "=" >+ found=gentoolkit.find_installed_packages("="+pkg) # add the "=" >+ else: >+ found=gentoolkit.find_installed_packages(pkg) >+ else: # the category is not given, so we check for the "=" on the package name >+ if pkg_split[1][0]!="=": # if the name is not preceded by an "=" >+ found=gentoolkit.find_installed_packages("="+pkg) # add the "=" >+ else: >+ found=gentoolkit.find_installed_packages(pkg) >+ else: # search for all version for the given package >+ found=gentoolkit.find_installed_packages(pkg) >+ if len(found)==0: >+ print_error("Package not found") >+ sys.exit(1) >+ else: >+ retval=[] >+ for i in gentoolkit.sort_package_list(found): >+ compiler={"VERSION":portage.output.red("!!! ")+"unknown", "SLOT":portage.output.red("!!! ")+"unknown"} >+ env=bz2.BZ2File(portage.root+portage.VDB_PATH+os.sep+i.get_category()+os.sep+i.get_name()+'-'+i.get_version()+os.sep+"environment.bz2") >+ expr=re.compile("^PATH=") >+ for l in env.readlines(): >+ if expr.match(l)!=None: >+ break >+ l=string.split(string.split(l, "=")[1], ":") >+ expr=re.compile(i.get_env_var("CHOST")) >+ for v in l: >+ m=expr.search(v) >+ if m!=None: >+ break >+ if m==None: >+ return {"CPV":i.get_cpv(),"COMPILER":compiler} >+ else: >+ v=string.split(v, os.sep) >+ v=v[len(v)-1] >+ if v[-1]=='\n': >+ compiler["VERSION"]=v[:-1] >+ else: >+ compiler["VERSION"]=v >+ for s in self._gccInstalledSlots(): >+ expr=re.compile(s) >+ if expr.match(v): >+ break >+ compiler["SLOT"]=s >+ f=open(portage.root+portage.VDB_PATH+os.sep+i.get_category()+os.sep+i.get_name()+'-'+i.get_version()+os.sep+"CHOST") >+ chost=f.readline()[:-1] >+ f=open(portage.root+portage.VDB_PATH+os.sep+i.get_category()+os.sep+i.get_name()+'-'+i.get_version()+os.sep+"CFLAGS") >+ cflags=f.readline()[:-1] >+ f=open(portage.root+portage.VDB_PATH+os.sep+i.get_category()+os.sep+i.get_name()+'-'+i.get_version()+os.sep+"CXXFLAGS") >+ cxxflags=f.readline()[:-1] >+ f=open(portage.root+portage.VDB_PATH+os.sep+i.get_category()+os.sep+i.get_name()+'-'+i.get_version()+os.sep+"CC") >+ cc=f.readline()[:-1] >+ f=open(portage.root+portage.VDB_PATH+os.sep+i.get_category()+os.sep+i.get_name()+'-'+i.get_version()+os.sep+"CXX") >+ cxx=f.readline()[:-1] >+ retval.append({"CPV":i.get_cpv(),"COMPILER":compiler,"CHOST":chost,"CFLAGS":cflags,"CXXFLAGS":cxxflags,"CC":cc,"CXX":cxx}) >+ return retval >+ >+ def _scanDb(self): >+ slots=self._gccInstalledSlots() >+ last_slot=slots[-1] >+ num_pkg=0 >+ num_last=0 >+ old=[] >+ l1=os.listdir(portage.root+portage.VDB_PATH) >+ l1.sort() >+ for i in l1: >+ l2=os.listdir(portage.root+portage.VDB_PATH+os.sep+i) >+ l2.sort() >+ for j in l2: >+ pkg=i+os.sep+j >+ pkg_gcc=self._getGccInfo(pkg) >+ num_pkg+=1 >+ if pkg_gcc["COMPILER"]["SLOT"]==last_slot: >+ num_last+=1 >+ else: >+ old.append(pkg) >+ l=[] >+ for p in old: >+ v=self._getGccInfo(p) >+ l.append([v["COMPILER"]["SLOT"],v["COMPILER"]["VERSION"],p]) >+ return [str(last_slot),str(num_pkg),str(num_last),str(num_pkg-num_last),l] >+ >+ > # > # Command line tokens to commands mapping > # >@@ -1495,7 +1671,8 @@ > "check" : CmdCheckIntegrity(), > "stats" : CmdDisplayStatistics(), > "glsa" : CmdListGLSAs(), >- "which": CmdWhich() >+ "which": CmdWhich(), >+ "gcc" : CmdDisplayGccInfo() > } > > # Short command line tokens >@@ -1513,7 +1690,8 @@ > "s" : "size", > "t" : "stats", > "u" : "uses", >- "w" : "which" >+ "w" : "which", >+ "o" : "gcc" > } > > from gentoolkit import Config
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 115203
:
74507
|
74513
|
75204
|
110530