Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 60657
Collapse All | Expand All

(-)equery.old (+107 lines)
Lines 75-80 Link Here
75
		pass
75
		pass
76
76
77
	
77
	
78
class CmdDisplayChangedUSEs(Command):
79
	"""List all packages that have had their USE flags changed"""
80
	def __init__(self):
81
		self.default_opts = {
82
			"rawoutput": 0
83
			}
84
85
	def parseArgs(self, args):
86
		opts = self.default_opts
87
		need_help = 0		
88
		for i in args:
89
			if i in ["-r", "--rawoutput"]:
90
				opts["rawoutput"] = 1
91
			if i in ["-h", "--help"]:
92
				need_help = 1
93
		if need_help:
94
			print self.longHelp()
95
			sys.exit(-1)
96
		return opts
97
98
	def perform(self, args):
99
		opts = self.parseArgs(args)
100
		raw = opts["rawoutput"]
101
		output = []
102
		if not raw:
103
			print "Fetching list of installed packages ..."
104
		matches = gentoolkit.find_all_installed_packages()
105
		if not raw:
106
			print "Comparing USE flags ..."
107
			print
108
		num = len(matches)
109
		current = 0
110
		nrchars = 0
111
		for p in matches:
112
			bestver = "=" + p.get_cpv()
113
			# Don't continue if the package no longer exists in portage
114
			if not gentoolkit.find_packages(bestver):
115
				continue
116
			useflags = gentoolkit.settings["USE"].split()
117
			iuse = p.get_env_var("IUSE")
118
			if iuse:
119
				usevar = iuse.split()
120
			else:
121
				usevar = []
122
			used = p.get_use_vars().split()
123
			list = []
124
			for u in usevar:
125
				inuse = 0
126
				inused = 0
127
				if u in useflags:
128
					inuse = 1
129
				if u in used:
130
					inused = 1
131
				list.append((inuse, inused, u))
132
			doprint = 0
133
			uselist = []
134
			if list:
135
				for inuse, inused, u in list:
136
					if inuse != inused:
137
						# These USE flags shouldn't be set by users anyway.
138
						if u not in ["bootstrap", "build", "livecd", "selinux"]:
139
							doprint = 1
140
							if inuse:
141
								uselist.append(red("+" + u))
142
							else:
143
								uselist.append(blue("-" + u))
144
			current += 1
145
			if doprint:
146
				if raw:
147
					print bestver
148
				output.append((bestver, uselist))
149
			s = str(len(matches) - current) + " packages to go (" + str(len(output)) + " candidates found)"
150
			if not raw:
151
				sys.stdout.write(nrchars * "\b \b" + s)
152
				sys.stdout.flush()
153
			nrchars = len(s)
154
		if not raw:
155
			sys.stdout.write(nrchars * "\b \b")
156
			sys.stdout.flush()
157
			print "Done!"
158
			print
159
			if len(output):
160
				print "These are the packages with changed USE flags:"
161
				print
162
				for pkg, uselist in output:
163
					print "  " + darkgreen(pkg[1:]) + " ",
164
					for u in uselist:
165
						print u,
166
					print
167
			else:
168
				print "All packages are compiled with the current USE flags.  Exiting ..."
169
			print
170
171
	def shortHelp(self):
172
		return yellow("<local-opts>") + " - list packages that have had their USE flags changed"
173
174
	def longHelp(self):
175
		return "List all packages that have had their USE flags changed\n" + \
176
		     "\n" + \
177
		     "Syntax:\n" + \
178
				 "  " + green("changeduse") + yellow(" <local-opts>\n") + \
179
				 "\n" + \
180
				 yellow("<local-opts>") + " is either of:\n" + \
181
				 "  " + yellow("-r, --rawoutput") + " - output raw depend atoms\n"
182
183
78
class CmdListFiles(Command):
184
class CmdListFiles(Command):
79
	"""List files owned by a particular package"""
185
	"""List files owned by a particular package"""
80
	def __init__(self):
186
	def __init__(self):
Lines 850-855 Link Here
850
956
851
957
852
Known_commands = {
958
Known_commands = {
959
	"changeduse": CmdDisplayChangedUSEs(),
853
	"list": CmdListPackages(),
960
	"list": CmdListPackages(),
854
	"files": CmdListFiles(),
961
	"files": CmdListFiles(),
855
	"belongs": CmdListBelongs(),
962
	"belongs": CmdListBelongs(),

Return to bug 60657