mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 16:58:40 -04:00
add -p option to restrict package selection
This commit is contained in:
parent
e034e375c9
commit
3db2e1a13d
@ -136,9 +136,9 @@ class PackageMerger:
|
||||
self.contentsSeq = SeqValue()
|
||||
|
||||
# We allow the first one to fail quietly.
|
||||
self.__readContentsFile(self.installDir)
|
||||
self.__readContentsFile(self.installDir, None)
|
||||
|
||||
def __readContentsFile(self, sourceDir):
|
||||
def __readContentsFile(self, sourceDir, packageNames):
|
||||
""" Reads the contents.xml file from the indicated sourceDir,
|
||||
and updates the internal set of packages appropriately. """
|
||||
|
||||
@ -170,10 +170,15 @@ class PackageMerger:
|
||||
xpackage = xcontents.FirstChildElement('package')
|
||||
while xpackage:
|
||||
pe = self.PackageEntry(xpackage, sourceDir)
|
||||
other = self.contents.get(pe.getKey(), None)
|
||||
if not other or pe.isNewer(other):
|
||||
# Store this package in the resulting output.
|
||||
self.contents[pe.getKey()] = pe
|
||||
|
||||
# Filter out any packages not listed in
|
||||
# packageNames (unless packageNames is None,
|
||||
# in which case don't filter anything).
|
||||
if packageNames is None or pe.packageName in packageNames:
|
||||
other = self.contents.get(pe.getKey(), None)
|
||||
if not other or pe.isNewer(other):
|
||||
# Store this package in the resulting output.
|
||||
self.contents[pe.getKey()] = pe
|
||||
|
||||
xpackage = xpackage.NextSiblingElement('package')
|
||||
|
||||
@ -268,10 +273,13 @@ class PackageMerger:
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
def merge(self, sourceDir):
|
||||
def merge(self, sourceDir, packageNames = None):
|
||||
""" Adds the contents of the indicated source directory into
|
||||
the current pool. """
|
||||
if not self.__readContentsFile(sourceDir):
|
||||
the current pool. If packageNames is not None, it is a list
|
||||
of package names that we wish to include from the source;
|
||||
packages not named in this list will be unchanged. """
|
||||
|
||||
if not self.__readContentsFile(sourceDir, packageNames):
|
||||
message = "Couldn't read %s" % (sourceDir)
|
||||
raise PackageMergerError, message
|
||||
|
||||
|
@ -30,6 +30,14 @@ Options:
|
||||
are checked for self-consistency with regards to hashes and
|
||||
timestamps.
|
||||
|
||||
-p packageName[,packageName...]
|
||||
Specifies one or more particular packages by name that are to be
|
||||
included from the input directories. Any packages not in this
|
||||
list are left unchanged in the install directory, even if there
|
||||
is a newer version in one of the input directories. If no
|
||||
packages are named, all packages are involved. This option may
|
||||
be repeated.
|
||||
|
||||
-h
|
||||
Display this help
|
||||
"""
|
||||
@ -47,14 +55,17 @@ def usage(code, msg = ''):
|
||||
sys.exit(code)
|
||||
|
||||
try:
|
||||
opts, args = getopt.getopt(sys.argv[1:], 'i:h')
|
||||
opts, args = getopt.getopt(sys.argv[1:], 'i:p:h')
|
||||
except getopt.error, msg:
|
||||
usage(1, msg)
|
||||
|
||||
installDir = None
|
||||
packageNames = []
|
||||
for opt, arg in opts:
|
||||
if opt == '-i':
|
||||
installDir = Filename.fromOsSpecific(arg)
|
||||
elif opt == '-p':
|
||||
packageNames += arg.split(',')
|
||||
|
||||
elif opt == '-h':
|
||||
usage(0)
|
||||
@ -62,6 +73,10 @@ for opt, arg in opts:
|
||||
print 'illegal option: ' + arg
|
||||
sys.exit(1)
|
||||
|
||||
if not packageNames:
|
||||
# No package names means allow all packages.
|
||||
packageNames = None
|
||||
|
||||
inputDirs = []
|
||||
for arg in args:
|
||||
inputDirs.append(Filename.fromOsSpecific(arg))
|
||||
@ -75,7 +90,7 @@ for arg in args:
|
||||
try:
|
||||
pm = PackageMerger.PackageMerger(installDir)
|
||||
for dir in inputDirs:
|
||||
pm.merge(dir)
|
||||
pm.merge(dir, packageNames = packageNames)
|
||||
pm.close()
|
||||
|
||||
except PackageMerger.PackageMergerError:
|
||||
|
Loading…
x
Reference in New Issue
Block a user