public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/qa-scripts:master commit in: package.mask/
@ 2011-03-29 18:10 Christian Ruppert
  0 siblings, 0 replies; 6+ messages in thread
From: Christian Ruppert @ 2011-03-29 18:10 UTC (permalink / raw
  To: gentoo-commits

commit:     135ac4fa58ecae468339885b34317545b46f8b8c
Author:     Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Tue Mar 29 18:10:25 2011 +0000
Commit:     Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Tue Mar 29 18:10:25 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/qa-scripts.git;a=commit;h=135ac4fa

Add mask_check.py

---
 package.mask/README        |    1 +
 package.mask/mask_check.py |  354 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 355 insertions(+), 0 deletions(-)

diff --git a/package.mask/README b/package.mask/README
new file mode 100644
index 0000000..73fdcbb
--- /dev/null
+++ b/package.mask/README
@@ -0,0 +1 @@
+5 0 * * * python ~/gentoo/mask_check.py $(find /usr/portage/profiles -type f -name '*.mask') > ~/public_html/gentoo/invalid-mask.txt

diff --git a/package.mask/mask_check.py b/package.mask/mask_check.py
new file mode 100644
index 0000000..78e5511
--- /dev/null
+++ b/package.mask/mask_check.py
@@ -0,0 +1,354 @@
+#!/usr/bin/env python
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+# python mask_check.py $(find /usr/portage/profiles -type f -name '*.mask' -not -regex '.*/prefix/.*')
+
+import re
+
+from lxml import etree
+from os.path import join, isfile, isdir, basename
+from os import listdir
+from sys import stderr, argv
+from time import strftime, gmtime
+
+from portage import settings
+from portage.versions import pkgsplit, vercmp
+
+OPERATORS = (">", "=", "<", "~")
+
+def strip_atoms(pkg):
+	while pkg.startswith( OPERATORS ) and len(pkg) > 1:
+		pkg = pkg[1:]
+	while pkg.endswith( ("*", ".") ):
+		pkg = pkg[0:-1]
+
+	# strip slots
+	if pkg.find(":") != -1:
+		pkg = pkg[0:pkg.find(":")]
+	return pkg
+
+# Deprecated
+def strip_atoms2(pkg):
+	while pkg.startswith( OPERATORS ) and len(pkg) > 1:
+		pkg = pkg[1:]
+	while pkg.endswith( "*" ):
+		pkg = pkg[0:-1]
+
+	return pkg
+
+def pkgcmp_atom(pkgdir, pkg):
+	ebuilds = []
+
+	for ent in listdir(pkgdir):
+		if ent.endswith(".ebuild"):
+			ebuilds.append(ent)
+
+	ppkg = basename(strip_atoms(pkg))
+
+	# test
+	ppkg2 = basename(strip_atoms2(pkg))
+	if ppkg != ppkg2:
+		print >> stderr, "PPKG: %s" % ppkg
+		print >> stderr, "PPKG2: %s" % ppkg2
+
+	revre = re.compile( ("^" + re.escape(ppkg) + "(-r\d+)?.ebuild$") )
+
+#	print "DBG: checking for %s" % pkg
+#	print "DBG: Got %i ebuilds:" % len(ebuilds)
+#	print ebuilds
+
+	for ebuild in ebuilds:
+		# workaround? for - prefix
+		if pkg.startswith( "-" ):
+			pkg = pkg[1:]
+
+		if pkg.startswith( ("=", "~") ):
+			if pkg.startswith("~"):
+				if revre.match(ebuild):
+#					print "DBG: revmatch '%s' '%s'" % (pkg, ebuild)
+					return 1
+				else:
+#					print "DBG: revmatch continue"
+					continue
+			if pkg.endswith("*"):
+				if ebuild.startswith(ppkg):
+#					print "DBG: startswith '%s' '%s'" % (pkg, ebuild)
+					return 1
+				else:
+#					print "DBG: startswith continue"
+					continue
+			else:
+				if ebuild == (ppkg + ".ebuild"):
+#					print "DBG: '%s' == '%s'" % (ppkg, ppkg)
+					return 1
+				else:
+#					print "DBG: == continue"
+					continue
+
+		if pkg.startswith( (">=", ">", "<=", "<") ):
+			plain = strip_atoms(pkg)
+
+			mypkg = pkgsplit(plain)
+			ourpkg = pkgsplit(ebuild.rstrip(".ebuild"))
+
+			mypkgv = mypkg[1]
+			if mypkg[2] != "r0":
+				mypkgv = mypkgv + "-" + mypkg[2]
+
+			ourpkgv = ourpkg[1]
+			if ourpkg[2] != "r0":
+				ourpkgv = ourpkgv + "-" + ourpkg[2]
+
+#			print "MYPKGV:", mypkgv, "OURPKGV:", ourpkgv, "RESULT 'vercmp('%s', '%s'): %i" % (mypkgv, ourpkgv, vercmp(mypkgv, ourpkgv))
+
+			if pkg.startswith(">="):
+				if vercmp(mypkgv, ourpkgv) <= 0:
+#					print "HIT: '%s' >= '%s'" % (ourpkg, mypkg)
+					return 1
+				else:
+#					print ">= continue"
+					continue
+			if pkg.startswith(">") and not pkg.startswith(">="):
+				if vercmp(mypkgv, ourpkgv) < 0:
+#					print "HIT: '%s' > '%s'" % (ourpkg, mypkg)
+					return 1
+				else:
+#					print "> continue"
+					continue
+			if pkg.startswith("<="):
+				if vercmp(mypkgv, ourpkgv) >= 0:
+#					print "HIT: '%s' <= '%s'" % (ourpkg, mypkg)
+					return 1
+				else:
+#					print "<= continue"
+					continue
+			if pkg.startswith("<") and not pkg.startswith("<="):
+				if vercmp(mypkgv, ourpkgv) > 0:
+#					print "HIT: '%s' < '%s'" % (ourpkg, mypkg)
+					return 1
+				else:
+#					print "< continue"
+					continue
+
+#	print "Nothing found... '%s' is invalid" % pkg
+	return 0
+
+def check_locuse(portdir, pkg, invalid):
+	locuse = []
+
+	ppkg = pkgsplit(strip_atoms(pkg))
+
+	if ppkg:
+		ppkg = ppkg[0]
+	else:
+		ppkg = strip_atoms(pkg)
+
+	metadata = join(portdir, ppkg, "metadata.xml")
+
+	tree = etree.parse(metadata)
+	root = tree.getroot()
+	for elem in root:
+		if elem.tag == "use":
+			for use in elem:
+				locuse.append(use.get("name"))
+
+	# create a _NEW_ list
+	oldinvalid = [foo for foo in invalid]
+	for iuse in oldinvalid:
+		if iuse in locuse:
+			invalid.remove(iuse)
+
+	return invalid
+
+def check_use(portdir, line):
+	# use.desc
+	# <flag> - <description>
+	usedescs = [join(portdir, "profiles/use.desc")]
+	globuse = []
+	invalid = []
+	useflags = []
+
+	for useflag in line.split(" ")[1:]:
+		# get a rid of malformed stuff e.g.:
+		# app-text/enchant        zemberek
+		if len(useflag) > 0:
+			if useflag.startswith("-"):
+				useflag = useflag[1:]
+			useflags.append(useflag)
+
+	pkg = line.split(" ")[0]
+
+	# Add other description file
+	for entry in listdir(join(portdir, "profiles/desc")):
+		entry = join(portdir, "profiles/desc", entry)
+		if isfile(entry) and entry.endswith(".desc"):
+			usedescs.append(entry)
+
+	for usedesc_f in usedescs:
+		usedesc_fd = open(usedesc_f, "r")
+
+		for line in usedesc_fd:
+			line = line.rstrip()
+			line = line.replace("\t", " ")
+
+			if len(line) == 0:
+				continue
+
+			while line[0].isspace():
+				if len(line) > 1:
+					line = line[1:]
+				else:
+					break
+
+			if line.startswith("#"):
+				continue
+			_flag = line.split(" - ")[0]
+
+			if usedesc_f == join(portdir, "profiles/use.desc"):
+				globuse.append(line.split(" - ")[0])
+			else:
+				_flag = "%s_%s" % (basename(usedesc_f).replace(".desc", ""), _flag)
+				globuse.append(_flag)
+#				print "GLOB: ", _flag
+
+		usedesc_fd.close()
+
+#	print globuse
+#	exit(1)
+
+	for flag in useflags:
+		if not flag in globuse:
+			# nothing found
+			invalid.append(flag)
+#			print "Add useflag %s" %flag
+
+	# check metadata.xml
+	if invalid:
+		invalid = check_locuse(portdir, pkg, invalid)
+
+
+#	print portdir, pkg, useflags
+#	print globuse
+
+	if invalid:
+		return (pkg, invalid)
+	else:
+		return None
+
+# <cat>/<pkg> <use> ...
+def check_pkg(portdir, line):
+#	print "PKGM1:", line
+	pkgm = line.split(" ")[0]
+#	print "PKGM2:", pkgm
+#	print "DBG:", line.split(" ")
+
+	if pkgm.startswith("-"):
+		pkgm = pkgm[1:]
+
+	if pkgm.startswith(OPERATORS):
+		pkg = []
+#		print "DBG1: %s" % pkgm
+		plain_pkg = strip_atoms(pkgm)
+#		print "DBG2: %s" % plain_pkg
+
+		pkg = pkgsplit(plain_pkg)
+		if not pkg:
+			print >> stderr, "Error encountered during pkgsplit(), please contact idl0r@gentoo.org including the whole output!"
+			print >> stderr, "1: %s; 2: %s" % (pkgm, plain_pkg)
+			return 0
+
+		plain_pkg = strip_atoms(pkg[0])
+
+		if not isdir(join(portdir, plain_pkg)):
+			return 0
+
+		if not pkgcmp_atom(join(portdir, plain_pkg), pkgm):
+			return 0
+
+		return 1
+	else:
+		if pkgm.find(":") != -1:
+			pkgm = strip_atoms(pkgm)
+		if isdir(join(portdir, pkgm)):
+			return 1
+		else:
+			return 0
+
+	return 0
+
+def get_timestamp():
+	timestamp_f = join(settings["PORTDIR"],	"metadata/timestamp.chk")
+	timestamp = open(timestamp_f).readline().rstrip()
+	if len(timestamp) < 1:
+		return "Unknown"
+
+	return timestamp
+
+def obsolete_pmask(portdir = None, package_mask=None):
+	invalid_entries = []
+
+	if not portdir:
+		portdir = settings["PORTDIR"]
+
+	if not package_mask:
+		package_mask = join(portdir, "profiles/package.mask")
+
+	pmask = open(package_mask, "r")
+
+	for line in pmask:
+		line = line.rstrip()
+
+		if len(line) == 0:
+			continue
+
+		while line[0].isspace():
+			if len(line) > 1:
+				line = line[1:]
+			else:
+				break
+
+		if line.startswith("#"):
+			continue
+
+		# Skip sys-freebsd
+		if line.find("sys-freebsd") != -1:
+			continue
+
+		line = line.replace("\t", " ")
+
+		# don't check useflags with check_pkg
+		if line.find("/") != -1 and not check_pkg(portdir, line):
+#			print "Add whole entry: '%s'" % line
+			invalid_entries.append(line)
+		else:
+			invalid_use = check_use(portdir, line)
+			if invalid_use:
+#				print "Add useflags: '%s %s'" % (invalid_use[0], invalid_use[1])
+				invalid_entries.append(invalid_use)
+
+	pmask.close()
+
+	if invalid_entries:
+		print "Found %i invalid/obsolete entries in %s:" % (len(invalid_entries), package_mask)
+		for invalid in invalid_entries:
+			if isinstance(invalid, tuple):
+				print invalid[0], invalid[1]
+			else:
+				print invalid
+		print ""
+
+if __name__ == "__main__":
+	print "A list of invalid/obsolete package.mask entries in gentoo-x86, see bug 105016"
+	print "Generated on: %s (autogenerated at: 0 0 * * *)" % strftime( "%a %b %d %H:%M:%S %Z %Y", gmtime() )
+	print "Timestamp of tree: %s" % get_timestamp()
+	print "NOTE: if a package is listed as <category>/<package> <flag> ..."
+	print "	or <category>/<package> then the whole entry is invalid/obsolete."
+	print "NOTE: if a package is listed as <category>/<package> [ <flag>, ... ] then the listed useflags are invalid."
+	print ""
+
+	if len(argv) > 1:
+		for _pmask in argv[1:]:
+			obsolete_pmask(package_mask=_pmask)
+	else:
+		obsolete_pmask()



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [gentoo-commits] proj/qa-scripts:master commit in: package.mask/
@ 2011-03-29 18:11 Christian Ruppert
  0 siblings, 0 replies; 6+ messages in thread
From: Christian Ruppert @ 2011-03-29 18:11 UTC (permalink / raw
  To: gentoo-commits

commit:     1041a5ede5e9c5d892f7f21887df382ada409e3b
Author:     Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Tue Mar 29 18:11:23 2011 +0000
Commit:     Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Tue Mar 29 18:11:23 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/qa-scripts.git;a=commit;h=1041a5ed

Fix perms

---
 0 files changed, 0 insertions(+), 0 deletions(-)

diff --git a/package.mask/mask_check.py b/package.mask/mask_check.py
old mode 100644
new mode 100755



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [gentoo-commits] proj/qa-scripts:master commit in: package.mask/
@ 2011-04-15 20:28 Jeremy Olexa
  0 siblings, 0 replies; 6+ messages in thread
From: Jeremy Olexa @ 2011-04-15 20:28 UTC (permalink / raw
  To: gentoo-commits

commit:     36df2f631d8311dff0ba793d5b7993798e62380e
Author:     Jeremy Olexa <darkside <AT> gentoo <DOT> org>
AuthorDate: Mon Apr  4 20:11:44 2011 +0000
Commit:     Jeremy Olexa <darkside <AT> gentoo <DOT> org>
CommitDate: Mon Apr  4 20:11:44 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/qa-scripts.git;a=commit;h=36df2f63

remove autogenerated note

---
 package.mask/mask_check.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/package.mask/mask_check.py b/package.mask/mask_check.py
index 78e5511..95eb1c9 100755
--- a/package.mask/mask_check.py
+++ b/package.mask/mask_check.py
@@ -340,7 +340,7 @@ def obsolete_pmask(portdir = None, package_mask=None):
 
 if __name__ == "__main__":
 	print "A list of invalid/obsolete package.mask entries in gentoo-x86, see bug 105016"
-	print "Generated on: %s (autogenerated at: 0 0 * * *)" % strftime( "%a %b %d %H:%M:%S %Z %Y", gmtime() )
+	print "Generated on: %s" % strftime( "%a %b %d %H:%M:%S %Z %Y", gmtime() )
 	print "Timestamp of tree: %s" % get_timestamp()
 	print "NOTE: if a package is listed as <category>/<package> <flag> ..."
 	print "	or <category>/<package> then the whole entry is invalid/obsolete."



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [gentoo-commits] proj/qa-scripts:master commit in: package.mask/
@ 2012-04-01 22:28 Christian Ruppert
  0 siblings, 0 replies; 6+ messages in thread
From: Christian Ruppert @ 2012-04-01 22:28 UTC (permalink / raw
  To: gentoo-commits

commit:     cf9a6b53689958e0f74ec6b20fe62f4cba89e4e9
Author:     Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Sun Apr  1 22:27:52 2012 +0000
Commit:     Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Sun Apr  1 22:27:52 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/qa-scripts.git;a=commit;h=cf9a6b53

Fix pkgsplit error when using slots and globs

---
 package.mask/mask_check.py |   16 +---------------
 1 files changed, 1 insertions(+), 15 deletions(-)

diff --git a/package.mask/mask_check.py b/package.mask/mask_check.py
index 95eb1c9..92af0c6 100755
--- a/package.mask/mask_check.py
+++ b/package.mask/mask_check.py
@@ -18,21 +18,13 @@ from portage.versions import pkgsplit, vercmp
 OPERATORS = (">", "=", "<", "~")
 
 def strip_atoms(pkg):
-	while pkg.startswith( OPERATORS ) and len(pkg) > 1:
-		pkg = pkg[1:]
-	while pkg.endswith( ("*", ".") ):
-		pkg = pkg[0:-1]
-
 	# strip slots
 	if pkg.find(":") != -1:
 		pkg = pkg[0:pkg.find(":")]
-	return pkg
 
-# Deprecated
-def strip_atoms2(pkg):
 	while pkg.startswith( OPERATORS ) and len(pkg) > 1:
 		pkg = pkg[1:]
-	while pkg.endswith( "*" ):
+	while pkg.endswith( ("*", ".") ):
 		pkg = pkg[0:-1]
 
 	return pkg
@@ -46,12 +38,6 @@ def pkgcmp_atom(pkgdir, pkg):
 
 	ppkg = basename(strip_atoms(pkg))
 
-	# test
-	ppkg2 = basename(strip_atoms2(pkg))
-	if ppkg != ppkg2:
-		print >> stderr, "PPKG: %s" % ppkg
-		print >> stderr, "PPKG2: %s" % ppkg2
-
 	revre = re.compile( ("^" + re.escape(ppkg) + "(-r\d+)?.ebuild$") )
 
 #	print "DBG: checking for %s" % pkg



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [gentoo-commits] proj/qa-scripts:master commit in: package.mask/
@ 2018-07-17 13:17 Brian Evans
  0 siblings, 0 replies; 6+ messages in thread
From: Brian Evans @ 2018-07-17 13:17 UTC (permalink / raw
  To: gentoo-commits

commit:     d63caae3c70d6c6a4c908dde07e0d16b451ab4e0
Author:     Brian Evans <grknight <AT> gentoo <DOT> org>
AuthorDate: Tue Jul 17 13:15:14 2018 +0000
Commit:     Brian Evans <grknight <AT> gentoo <DOT> org>
CommitDate: Tue Jul 17 13:15:14 2018 +0000
URL:        https://gitweb.gentoo.org/proj/qa-scripts.git/commit/?id=d63caae3

mask_check.py: Catch open exceptions for timestamp

Git checkouts won't have this file and the timestamp is only used
in output logging.  It would be wonderful to extend further,
but if the file is empty anyway it doesn't seem to care.

 package.mask/mask_check.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/package.mask/mask_check.py b/package.mask/mask_check.py
index 77b493a..30508f1 100755
--- a/package.mask/mask_check.py
+++ b/package.mask/mask_check.py
@@ -265,7 +265,10 @@ def check_pkg(portdir, line):
 
 def get_timestamp():
 	timestamp_f = join(settings["PORTDIR"],	"metadata/timestamp.chk")
-	timestamp = open(timestamp_f).readline().rstrip()
+	try:
+		timestamp = open(timestamp_f).readline().rstrip()
+	except:
+		return "Unknown"
 	if len(timestamp) < 1:
 		return "Unknown"
 


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [gentoo-commits] proj/qa-scripts:master commit in: package.mask/
@ 2018-07-17 13:17 Brian Evans
  0 siblings, 0 replies; 6+ messages in thread
From: Brian Evans @ 2018-07-17 13:17 UTC (permalink / raw
  To: gentoo-commits

commit:     97de79100b7e0b85c93c6d8b48eb3fbae4a7b516
Author:     Brian Evans <grknight <AT> gentoo <DOT> org>
AuthorDate: Tue Jul 17 13:14:25 2018 +0000
Commit:     Brian Evans <grknight <AT> gentoo <DOT> org>
CommitDate: Tue Jul 17 13:14:25 2018 +0000
URL:        https://gitweb.gentoo.org/proj/qa-scripts.git/commit/?id=97de7910

mask_check.py: Have print statements work in Python 3

Fixes alerts from cron

 package.mask/mask_check.py | 90 +++++++++++++++++++++++-----------------------
 1 file changed, 45 insertions(+), 45 deletions(-)

diff --git a/package.mask/mask_check.py b/package.mask/mask_check.py
index 92af0c6..77b493a 100755
--- a/package.mask/mask_check.py
+++ b/package.mask/mask_check.py
@@ -1,5 +1,5 @@
 #!/usr/bin/env python
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2018 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 # python mask_check.py $(find /usr/portage/profiles -type f -name '*.mask' -not -regex '.*/prefix/.*')
@@ -40,9 +40,9 @@ def pkgcmp_atom(pkgdir, pkg):
 
 	revre = re.compile( ("^" + re.escape(ppkg) + "(-r\d+)?.ebuild$") )
 
-#	print "DBG: checking for %s" % pkg
-#	print "DBG: Got %i ebuilds:" % len(ebuilds)
-#	print ebuilds
+#	print("DBG: checking for %s" % pkg)
+#	print("DBG: Got %i ebuilds:" % len(ebuilds))
+#	print(ebuilds)
 
 	for ebuild in ebuilds:
 		# workaround? for - prefix
@@ -52,24 +52,24 @@ def pkgcmp_atom(pkgdir, pkg):
 		if pkg.startswith( ("=", "~") ):
 			if pkg.startswith("~"):
 				if revre.match(ebuild):
-#					print "DBG: revmatch '%s' '%s'" % (pkg, ebuild)
+#					print("DBG: revmatch '%s' '%s'" % (pkg, ebuild))
 					return 1
 				else:
-#					print "DBG: revmatch continue"
+#					print("DBG: revmatch continue")
 					continue
 			if pkg.endswith("*"):
 				if ebuild.startswith(ppkg):
-#					print "DBG: startswith '%s' '%s'" % (pkg, ebuild)
+#					print("DBG: startswith '%s' '%s'" % (pkg, ebuild))
 					return 1
 				else:
-#					print "DBG: startswith continue"
+#					print("DBG: startswith continue")
 					continue
 			else:
 				if ebuild == (ppkg + ".ebuild"):
-#					print "DBG: '%s' == '%s'" % (ppkg, ppkg)
+#					print("DBG: '%s' == '%s'" % (ppkg, ppkg))
 					return 1
 				else:
-#					print "DBG: == continue"
+#					print("DBG: == continue")
 					continue
 
 		if pkg.startswith( (">=", ">", "<=", "<") ):
@@ -86,38 +86,38 @@ def pkgcmp_atom(pkgdir, pkg):
 			if ourpkg[2] != "r0":
 				ourpkgv = ourpkgv + "-" + ourpkg[2]
 
-#			print "MYPKGV:", mypkgv, "OURPKGV:", ourpkgv, "RESULT 'vercmp('%s', '%s'): %i" % (mypkgv, ourpkgv, vercmp(mypkgv, ourpkgv))
+#			print("MYPKGV:", mypkgv, "OURPKGV:", ourpkgv, "RESULT 'vercmp('%s', '%s'): %i" % (mypkgv, ourpkgv, vercmp(mypkgv, ourpkgv)))
 
 			if pkg.startswith(">="):
 				if vercmp(mypkgv, ourpkgv) <= 0:
-#					print "HIT: '%s' >= '%s'" % (ourpkg, mypkg)
+#					print("HIT: '%s' >= '%s'" % (ourpkg, mypkg))
 					return 1
 				else:
-#					print ">= continue"
+#					print(">= continue")
 					continue
 			if pkg.startswith(">") and not pkg.startswith(">="):
 				if vercmp(mypkgv, ourpkgv) < 0:
-#					print "HIT: '%s' > '%s'" % (ourpkg, mypkg)
+#					print("HIT: '%s' > '%s'" % (ourpkg, mypkg))
 					return 1
 				else:
-#					print "> continue"
+#					print("> continue")
 					continue
 			if pkg.startswith("<="):
 				if vercmp(mypkgv, ourpkgv) >= 0:
-#					print "HIT: '%s' <= '%s'" % (ourpkg, mypkg)
+#					print("HIT: '%s' <= '%s'" % (ourpkg, mypkg))
 					return 1
 				else:
-#					print "<= continue"
+#					print("<= continue"
 					continue
 			if pkg.startswith("<") and not pkg.startswith("<="):
 				if vercmp(mypkgv, ourpkgv) > 0:
-#					print "HIT: '%s' < '%s'" % (ourpkg, mypkg)
+#					print("HIT: '%s' < '%s'" % (ourpkg, mypkg))
 					return 1
 				else:
-#					print "< continue"
+#					print("< continue")
 					continue
 
-#	print "Nothing found... '%s' is invalid" % pkg
+#	print("Nothing found... '%s' is invalid" % pkg)
 	return 0
 
 def check_locuse(portdir, pkg, invalid):
@@ -196,26 +196,26 @@ def check_use(portdir, line):
 			else:
 				_flag = "%s_%s" % (basename(usedesc_f).replace(".desc", ""), _flag)
 				globuse.append(_flag)
-#				print "GLOB: ", _flag
+#				print("GLOB: ", _flag)
 
 		usedesc_fd.close()
 
-#	print globuse
+#	print(globuse)
 #	exit(1)
 
 	for flag in useflags:
 		if not flag in globuse:
 			# nothing found
 			invalid.append(flag)
-#			print "Add useflag %s" %flag
+#			print("Add useflag %s" %flag)
 
 	# check metadata.xml
 	if invalid:
 		invalid = check_locuse(portdir, pkg, invalid)
 
 
-#	print portdir, pkg, useflags
-#	print globuse
+#	print(portdir, pkg, useflags)
+#	print(globuse)
 
 	if invalid:
 		return (pkg, invalid)
@@ -224,24 +224,24 @@ def check_use(portdir, line):
 
 # <cat>/<pkg> <use> ...
 def check_pkg(portdir, line):
-#	print "PKGM1:", line
+#	print("PKGM1:", line)
 	pkgm = line.split(" ")[0]
-#	print "PKGM2:", pkgm
-#	print "DBG:", line.split(" ")
+#	print("PKGM2:", pkgm)
+#	print("DBG:", line.split(" "))
 
 	if pkgm.startswith("-"):
 		pkgm = pkgm[1:]
 
 	if pkgm.startswith(OPERATORS):
 		pkg = []
-#		print "DBG1: %s" % pkgm
+#		print("DBG1: %s" % pkgm)
 		plain_pkg = strip_atoms(pkgm)
-#		print "DBG2: %s" % plain_pkg
+#		print("DBG2: %s" % plain_pkg)
 
 		pkg = pkgsplit(plain_pkg)
 		if not pkg:
-			print >> stderr, "Error encountered during pkgsplit(), please contact idl0r@gentoo.org including the whole output!"
-			print >> stderr, "1: %s; 2: %s" % (pkgm, plain_pkg)
+			print("Error encountered during pkgsplit(), please contact idl0r@gentoo.org including the whole output!", file=stderr)
+			print("1: %s; 2: %s" % (pkgm, plain_pkg), file=stderr)
 			return 0
 
 		plain_pkg = strip_atoms(pkg[0])
@@ -305,33 +305,33 @@ def obsolete_pmask(portdir = None, package_mask=None):
 
 		# don't check useflags with check_pkg
 		if line.find("/") != -1 and not check_pkg(portdir, line):
-#			print "Add whole entry: '%s'" % line
+#			print("Add whole entry: '%s'" % line)
 			invalid_entries.append(line)
 		else:
 			invalid_use = check_use(portdir, line)
 			if invalid_use:
-#				print "Add useflags: '%s %s'" % (invalid_use[0], invalid_use[1])
+#				print("Add useflags: '%s %s'" % (invalid_use[0], invalid_use[1]))
 				invalid_entries.append(invalid_use)
 
 	pmask.close()
 
 	if invalid_entries:
-		print "Found %i invalid/obsolete entries in %s:" % (len(invalid_entries), package_mask)
+		print("Found %i invalid/obsolete entries in %s:" % (len(invalid_entries), package_mask))
 		for invalid in invalid_entries:
 			if isinstance(invalid, tuple):
-				print invalid[0], invalid[1]
+				print(invalid[0], invalid[1])
 			else:
-				print invalid
-		print ""
+				print(invalid)
+		print("")
 
 if __name__ == "__main__":
-	print "A list of invalid/obsolete package.mask entries in gentoo-x86, see bug 105016"
-	print "Generated on: %s" % strftime( "%a %b %d %H:%M:%S %Z %Y", gmtime() )
-	print "Timestamp of tree: %s" % get_timestamp()
-	print "NOTE: if a package is listed as <category>/<package> <flag> ..."
-	print "	or <category>/<package> then the whole entry is invalid/obsolete."
-	print "NOTE: if a package is listed as <category>/<package> [ <flag>, ... ] then the listed useflags are invalid."
-	print ""
+	print("A list of invalid/obsolete package.mask entries in gentoo repository, see bug 105016")
+	print("Generated on: %s" % strftime( "%a %b %d %H:%M:%S %Z %Y", gmtime() ))
+	print("Timestamp of tree: %s" % get_timestamp())
+	print("NOTE: if a package is listed as <category>/<package> <flag> ...")
+	print("	or <category>/<package> then the whole entry is invalid/obsolete.")
+	print("NOTE: if a package is listed as <category>/<package> [ <flag>, ... ] then the listed useflags are invalid.")
+	print("")
 
 	if len(argv) > 1:
 		for _pmask in argv[1:]:


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-07-17 13:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-17 13:17 [gentoo-commits] proj/qa-scripts:master commit in: package.mask/ Brian Evans
  -- strict thread matches above, loose matches on Subject: below --
2018-07-17 13:17 Brian Evans
2012-04-01 22:28 Christian Ruppert
2011-04-15 20:28 Jeremy Olexa
2011-03-29 18:11 Christian Ruppert
2011-03-29 18:10 Christian Ruppert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox