summaryrefslogtreecommitdiff
path: root/usr/src/tools/scripts/validate_pkg.py
diff options
context:
space:
mode:
authorJerry Jelinek <jerry.jelinek@joyent.com>2019-01-11 13:16:51 +0000
committerJerry Jelinek <jerry.jelinek@joyent.com>2019-01-11 13:16:51 +0000
commit882fee1ee6c160a1c4cb56a4874b0039ff1410c0 (patch)
treeadd61009c9f1e3c5849055eedf68b1ad9a8b7d97 /usr/src/tools/scripts/validate_pkg.py
parentb7e394a4a3da3fcdb717314a5ebcd7a5f14def92 (diff)
parent247b7da039fd88350c50e3d7fef15bdab6bef215 (diff)
downloadillumos-joyent-882fee1ee6c160a1c4cb56a4874b0039ff1410c0.tar.gz
[illumos-gate merge]
commit 247b7da039fd88350c50e3d7fef15bdab6bef215 10205 Mounting zfs filesystems on startup shows incorrect data commit b928ac841f6012f92d5aedbd7dfacf443921fee3 10182 dd: print scaled stats commit c65ebfc7045424bd04a6c7719a27b0ad3399ad54 8886 mdns: update to mDNSResponder-878.1.1 commit 35786f6866ae52207d0f1a25fe7ca5f652f32ce0 9823 Deadlock in ACPI Method Evaluation 9824 Update ACPI to joyent/20180629 commit bc36eafdde0c7048471866fc7cea7b93852592db 9822 want iasl commit b75e7d76519aa3dc2e72aa357a039a6b65372a1c 9821 want a way to run vendor-specific commands via libscsi commit 2a613b5974ae49c8b068a3998ff554f8c6f0f593 9747 Implement CPU autoreplace based on Intel PPIN commit ca13eaa51ee900abba73dfb6624e492f7e48863e 9979 Support python3 for in-gate tools Conflicts: usr/src/uts/intel/sys/x86_archext.h usr/src/uts/i86pc/os/cmi_hw.c usr/src/tools/onbld/Checks/DbLookups.py usr/src/lib/fm/topo/modules/i86pc/chip/chip_subr.c
Diffstat (limited to 'usr/src/tools/scripts/validate_pkg.py')
-rw-r--r--usr/src/tools/scripts/validate_pkg.py92
1 files changed, 47 insertions, 45 deletions
diff --git a/usr/src/tools/scripts/validate_pkg.py b/usr/src/tools/scripts/validate_pkg.py
index 6e5858a6ae..77e7d8e5d5 100644
--- a/usr/src/tools/scripts/validate_pkg.py
+++ b/usr/src/tools/scripts/validate_pkg.py
@@ -1,4 +1,4 @@
-#!@PYTHON@
+#!@TOOLS_PYTHON@
#
# CDDL HEADER START
#
@@ -25,6 +25,8 @@
# Use is subject to license terms.
#
+# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
+
#
# Compare the content generated by a build to a set of manifests
# describing how that content is to be delivered.
@@ -132,13 +134,13 @@ class FileInfo(object):
mo = m & stat.S_IRWXO
e = self.editable
- if (((mu & 02) == 0 and (mo & mg & 04) == 04) or
- (t == "file" and mo & 01 == 1) or
+ if (((mu & 0o2) == 0 and (mo & mg & 0o4) == 0o4) or
+ (t == "file" and mo & 0o1 == 1) or
(mg, mo) == (mu, mu) or
((t == "file" and not e or t == "dir" and o == "bin") and
- (mg & 05 == mo & 05)) or
- (t == "file" and o == "bin" and mu & 01 == 01) or
- (m & 0105 != 0 and p.startswith("etc/security/dev/"))):
+ (mg & 0o5 == mo & 0o5)) or
+ (t == "file" and o == "bin" and mu & 0o1 == 0o1) or
+ (m & 0o105 != 0 and p.startswith("etc/security/dev/"))):
w.extend(["%s: owner \"%s\" may be safely " \
"changed to \"root\"" % (p, o)])
@@ -405,38 +407,38 @@ class DirectoryTree(dict):
def compare(self, other):
"""Compare two different sets of FileInfo objects.
"""
- keys1 = frozenset(self.keys())
- keys2 = frozenset(other.keys())
+ keys1 = frozenset(list(self.keys()))
+ keys2 = frozenset(list(other.keys()))
common = keys1.intersection(keys2)
onlykeys1 = keys1.difference(common)
onlykeys2 = keys2.difference(common)
if onlykeys1:
- print "Entries present in %s but not %s:" % \
- (self.name, other.name)
+ print("Entries present in %s but not %s:" % \
+ (self.name, other.name))
for path in sorted(onlykeys1):
- print("\t%s" % str(self[path]))
- print ""
+ print(("\t%s" % str(self[path])))
+ print("")
if onlykeys2:
- print "Entries present in %s but not %s:" % \
- (other.name, self.name)
+ print("Entries present in %s but not %s:" % \
+ (other.name, self.name))
for path in sorted(onlykeys2):
- print("\t%s" % str(other[path]))
- print ""
+ print(("\t%s" % str(other[path])))
+ print("")
nodifferences = True
for path in sorted(common):
if self[path] != other[path]:
if nodifferences:
nodifferences = False
- print "Entries that differ between %s and %s:" \
- % (self.name, other.name)
- print("%14s %s" % (self.name, self[path]))
- print("%14s %s" % (other.name, other[path]))
+ print("Entries that differ between %s and %s:" \
+ % (self.name, other.name))
+ print(("%14s %s" % (self.name, self[path])))
+ print(("%14s %s" % (other.name, other[path])))
if not nodifferences:
- print ""
+ print("")
class BadProtolistFormat(Exception):
@@ -468,7 +470,7 @@ class ProtoTree(DirectoryTree):
if path not in exceptions:
try:
newentries[path] = RealFileInfo(pdir, path)
- except OSError, e:
+ except OSError as e:
sys.stderr.write("Warning: unable to stat %s: %s\n" %
(path, e))
continue
@@ -491,10 +493,10 @@ class ProtoTree(DirectoryTree):
# that cross proto dir boundaries.
#
hk2path = {}
- for path, fileinfo in newentries.iteritems():
+ for path, fileinfo in newentries.items():
if fileinfo.hardkey:
hk2path.setdefault(fileinfo.hardkey, set()).add(path)
- for fileinfo in newentries.itervalues():
+ for fileinfo in newentries.values():
if fileinfo.hardkey:
fileinfo.hardpaths.update(hk2path[fileinfo.hardkey])
self.update(newentries)
@@ -510,7 +512,7 @@ class ProtoTree(DirectoryTree):
try:
plist = open(protolist)
- except IOError, exc:
+ except IOError as exc:
raise IOError("cannot open proto list: %s" % str(exc))
newentries = {}
@@ -543,10 +545,10 @@ class ProtoTree(DirectoryTree):
plist.close()
hk2path = {}
- for path, fileinfo in newentries.iteritems():
+ for path, fileinfo in newentries.items():
if fileinfo.hardkey:
hk2path.setdefault(fileinfo.hardkey, set()).add(path)
- for fileinfo in newentries.itervalues():
+ for fileinfo in newentries.values():
if fileinfo.hardkey:
fileinfo.hardpaths.update(hk2path[fileinfo.hardkey])
self.update(newentries)
@@ -582,9 +584,9 @@ class ManifestTree(DirectoryTree):
mfest = manifest.Manifest()
try:
mfest.set_content(open(os.path.join(root, mfile)).read())
- except IOError, exc:
+ except IOError as exc:
raise IOError("cannot read manifest: %s" % str(exc))
- except actions.ActionError, exc:
+ except actions.ActionError as exc:
raise ManifestParsingError(mfile, str(exc))
#
@@ -657,10 +659,10 @@ class ManifestTree(DirectoryTree):
modewarnings.update(self[path].checkmodes(modechecks))
if len(modewarnings) > 0:
- print "warning: unsafe permissions in %s" % mfile
+ print("warning: unsafe permissions in %s" % mfile)
for w in sorted(modewarnings):
- print w
- print ""
+ print(w)
+ print("")
def adddir(self, mdir, arch, modechecks, exceptions):
"""Walks the specified directory looking for pkg(5) manifests.
@@ -670,14 +672,14 @@ class ManifestTree(DirectoryTree):
stat.S_ISREG(os.lstat(os.path.join(mdir, mfile)).st_mode)):
try:
self.addmanifest(mdir, mfile, arch, modechecks, exceptions)
- except IOError, exc:
+ except IOError as exc:
sys.stderr.write("warning: %s\n" % str(exc))
def resolvehardlinks(self):
"""Populates mode, group, and owner for resolved (ie link target
is present in the manifest tree) hard links.
"""
- for info in self.values():
+ for info in list(self.values()):
if info.name() == "hardlink":
tgt = info.hardkey
if tgt in self:
@@ -696,7 +698,7 @@ class ExceptionList(set):
for fname in files:
try:
self.readexceptionfile(fname, arch)
- except IOError, exc:
+ except IOError as exc:
sys.stderr.write("warning: cannot read exception file: %s\n" %
str(exc))
@@ -772,7 +774,7 @@ def main(argv):
"""
try:
opts, args = getopt.getopt(argv, 'a:e:Ll:Mm:p:vX:')
- except getopt.GetoptError, exc:
+ except getopt.GetoptError as exc:
usage(str(exc))
if args:
@@ -849,8 +851,8 @@ def main(argv):
manifesttree.adddir(mdir, arch, modechecks, exceptions)
if listonly:
manifesttree.resolvehardlinks()
- for info in manifesttree.values():
- print "%s" % info.protostr()
+ for info in list(manifesttree.values()):
+ print("%s" % info.protostr())
sys.exit(0)
if modechecks is not None:
sys.exit(0)
@@ -865,24 +867,24 @@ def main(argv):
for plist in protolists:
try:
protolist.addprotolist(plist, exceptions)
- except IOError, exc:
+ except IOError as exc:
sys.stderr.write("warning: %s\n" % str(exc))
trees.append(protolist)
if verbose and exceptions:
- print "Entries present in exception list but missing from proto area:"
+ print("Entries present in exception list but missing from proto area:")
for exc in sorted(exceptions):
- print "\t%s" % exc
- print ""
+ print("\t%s" % exc)
+ print("")
usedexceptions = originalexceptions.difference(exceptions)
harmfulexceptions = usedexceptions.intersection(manifesttree)
if harmfulexceptions:
- print "Entries present in exception list but also in manifests:"
+ print("Entries present in exception list but also in manifests:")
for exc in sorted(harmfulexceptions):
- print "\t%s" % exc
+ print("\t%s" % exc)
del manifesttree[exc]
- print ""
+ print("")
trees[0].compare(trees[1])