mirror of
https://pagure.io/fedora-kickstarts.git
synced 2025-08-19 14:05:43 +00:00
rewrite list-packages-for-ks.py script to python3
Signed-off-by: Anton Medvedev <amedvede@redhat.com>
This commit is contained in:
parent
16dd11b611
commit
ba34c74b4a
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/python3
|
||||
# Given as input a comps definition and a .ks file, list
|
||||
# the packages which would be installed. This list is
|
||||
# NOT depsolved, it's merely a textual list of explicitly
|
||||
@ -11,31 +11,33 @@
|
||||
import os
|
||||
import sys
|
||||
import getopt
|
||||
import xml.etree.cElementTree as ElementTree
|
||||
import xml.etree.ElementTree as ElementTree
|
||||
|
||||
import pykickstart
|
||||
import pykickstart.parser
|
||||
import pykickstart.version
|
||||
|
||||
|
||||
def usage(ecode):
|
||||
print "Usage: %s [--version=VERSION] COMPS.xml KICKSTART.ks" % (sys.argv[0], )
|
||||
print "List packages installed by KICKSTART."
|
||||
print("Usage: {} [--version=VERSION] COMPS.xml KICKSTART.ks".format(sys.argv[0]))
|
||||
print("List packages installed by KICKSTART.")
|
||||
sys.exit(ecode)
|
||||
|
||||
|
||||
def main():
|
||||
try:
|
||||
opts,args = getopt.getopt(sys.argv[1:], 'h', ['help', 'version=', 'debug'])
|
||||
except getopt.GetoptError, e:
|
||||
opts, args = getopt.getopt(sys.argv[1:], 'h', ['help', 'version=', 'debug'])
|
||||
except getopt.GetoptError as e:
|
||||
usage(1)
|
||||
|
||||
version = None
|
||||
debug = False
|
||||
for o,a in opts:
|
||||
for o, a in opts:
|
||||
if o in ('-h', '--help'):
|
||||
usage(0)
|
||||
elif o in ('--debug', ):
|
||||
elif o in ('--debug',):
|
||||
debug = True
|
||||
elif o in ('--version', ):
|
||||
elif o in ('--version',):
|
||||
version = a
|
||||
|
||||
if len(args) != 2:
|
||||
@ -77,24 +79,26 @@ def main():
|
||||
|
||||
for group in parser.handler.packages.groupList:
|
||||
if debug:
|
||||
print >>sys.stderr, "# Including %d packages from group %r" % (len(packages_for_group[group.name]), group.name)
|
||||
for pkg in packages_for_group[group.name]:
|
||||
print("# Including {} packages from group '{}'".format(len(packages_for_group.get(group.name, [])),
|
||||
group.name), file=sys.stderr)
|
||||
for pkg in packages_for_group.get(group.name, []):
|
||||
pkg_list.add(pkg)
|
||||
if debug:
|
||||
print >>sys.stderr, "# Adding %d explicitly specified packages" % (len(parser.handler.packages.packageList), )
|
||||
print("# Adding {} explicitly specified packages".format(len(parser.handler.packages.packageList)),
|
||||
file=sys.stderr)
|
||||
for pkg in parser.handler.packages.packageList:
|
||||
pkg_list.add(pkg)
|
||||
if debug:
|
||||
print >>sys.stderr, "# Processing %d explicitly excluded packages" % (len(parser.handler.packages.excludedList), )
|
||||
print("# Processing {} explicitly excluded packages".format(len(parser.handler.packages.excludedList)),
|
||||
file=sys.stderr)
|
||||
for pkg in parser.handler.packages.excludedList:
|
||||
if pkg in pkg_list:
|
||||
pkg_list.remove(pkg)
|
||||
pkg_list.discard(pkg)
|
||||
|
||||
for pkg in sorted(pkg_list):
|
||||
print "%s" % (pkg, )
|
||||
print(pkg)
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user