mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -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()
|
self.contentsSeq = SeqValue()
|
||||||
|
|
||||||
# We allow the first one to fail quietly.
|
# 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,
|
""" Reads the contents.xml file from the indicated sourceDir,
|
||||||
and updates the internal set of packages appropriately. """
|
and updates the internal set of packages appropriately. """
|
||||||
|
|
||||||
@ -170,10 +170,15 @@ class PackageMerger:
|
|||||||
xpackage = xcontents.FirstChildElement('package')
|
xpackage = xcontents.FirstChildElement('package')
|
||||||
while xpackage:
|
while xpackage:
|
||||||
pe = self.PackageEntry(xpackage, sourceDir)
|
pe = self.PackageEntry(xpackage, sourceDir)
|
||||||
other = self.contents.get(pe.getKey(), None)
|
|
||||||
if not other or pe.isNewer(other):
|
# Filter out any packages not listed in
|
||||||
# Store this package in the resulting output.
|
# packageNames (unless packageNames is None,
|
||||||
self.contents[pe.getKey()] = pe
|
# 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')
|
xpackage = xpackage.NextSiblingElement('package')
|
||||||
|
|
||||||
@ -268,10 +273,13 @@ class PackageMerger:
|
|||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def merge(self, sourceDir):
|
def merge(self, sourceDir, packageNames = None):
|
||||||
""" Adds the contents of the indicated source directory into
|
""" Adds the contents of the indicated source directory into
|
||||||
the current pool. """
|
the current pool. If packageNames is not None, it is a list
|
||||||
if not self.__readContentsFile(sourceDir):
|
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)
|
message = "Couldn't read %s" % (sourceDir)
|
||||||
raise PackageMergerError, message
|
raise PackageMergerError, message
|
||||||
|
|
||||||
|
@ -30,6 +30,14 @@ Options:
|
|||||||
are checked for self-consistency with regards to hashes and
|
are checked for self-consistency with regards to hashes and
|
||||||
timestamps.
|
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
|
-h
|
||||||
Display this help
|
Display this help
|
||||||
"""
|
"""
|
||||||
@ -47,14 +55,17 @@ def usage(code, msg = ''):
|
|||||||
sys.exit(code)
|
sys.exit(code)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(sys.argv[1:], 'i:h')
|
opts, args = getopt.getopt(sys.argv[1:], 'i:p:h')
|
||||||
except getopt.error, msg:
|
except getopt.error, msg:
|
||||||
usage(1, msg)
|
usage(1, msg)
|
||||||
|
|
||||||
installDir = None
|
installDir = None
|
||||||
|
packageNames = []
|
||||||
for opt, arg in opts:
|
for opt, arg in opts:
|
||||||
if opt == '-i':
|
if opt == '-i':
|
||||||
installDir = Filename.fromOsSpecific(arg)
|
installDir = Filename.fromOsSpecific(arg)
|
||||||
|
elif opt == '-p':
|
||||||
|
packageNames += arg.split(',')
|
||||||
|
|
||||||
elif opt == '-h':
|
elif opt == '-h':
|
||||||
usage(0)
|
usage(0)
|
||||||
@ -62,6 +73,10 @@ for opt, arg in opts:
|
|||||||
print 'illegal option: ' + arg
|
print 'illegal option: ' + arg
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
if not packageNames:
|
||||||
|
# No package names means allow all packages.
|
||||||
|
packageNames = None
|
||||||
|
|
||||||
inputDirs = []
|
inputDirs = []
|
||||||
for arg in args:
|
for arg in args:
|
||||||
inputDirs.append(Filename.fromOsSpecific(arg))
|
inputDirs.append(Filename.fromOsSpecific(arg))
|
||||||
@ -75,7 +90,7 @@ for arg in args:
|
|||||||
try:
|
try:
|
||||||
pm = PackageMerger.PackageMerger(installDir)
|
pm = PackageMerger.PackageMerger(installDir)
|
||||||
for dir in inputDirs:
|
for dir in inputDirs:
|
||||||
pm.merge(dir)
|
pm.merge(dir, packageNames = packageNames)
|
||||||
pm.close()
|
pm.close()
|
||||||
|
|
||||||
except PackageMerger.PackageMergerError:
|
except PackageMerger.PackageMergerError:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user