allow ppackage to drop p3d files into the current directory by default

This commit is contained in:
David Rose 2010-02-23 21:41:58 +00:00
parent cfe0796c46
commit 2eaf5a88b5
2 changed files with 43 additions and 14 deletions

View File

@ -339,6 +339,10 @@ class Packager:
def close(self):
""" Writes out the contents of the current package. """
if not self.p3dApplication and not self.packager.allowPackages:
message = 'Cannot generate packages without an installDir; use -i'
raise PackagerError, message
if not self.host:
self.host = self.packager.host
@ -629,11 +633,14 @@ class Packager:
print "Generating %s" % (self.packageFilename)
self.packageFullpath = Filename(self.packager.installDir, self.packageFilename)
self.packageFullpath.makeDir()
if self.p3dApplication:
self.packageFullpath = Filename(self.packager.p3dInstallDir, self.packageFilename)
self.packageFullpath.makeDir()
self.makeP3dInfo()
else:
self.packageFullpath = Filename(self.packager.installDir, self.packageFilename)
self.packageFullpath.makeDir()
self.multifile.repack()
# Also sign the multifile before we close it.
@ -686,6 +693,10 @@ class Packager:
if self.version:
packageDir += '/' + self.version
if not self.packager.allowPackages:
message = 'Cannot generate packages without an installDir; use -i'
raise PackagerError, message
installPath = Filename(self.packager.installDir, packageDir)
# Remove any files already in the installPath.
origFiles = vfs.scanDirectory(installPath)
@ -2144,8 +2155,18 @@ class Packager:
self.currentPackage = None
# We must have an actual install directory.
assert(self.installDir)
if self.installDir:
# If we were given an install directory, we can build
# packages as well as plain p3d files, and it all goes
# into the specified directory.
self.p3dInstallDir = self.installDir
self.allowPackages = True
else:
# If we don't have an actual install directory, we can
# only build p3d files, and we drop them into the current
# directory.
self.p3dInstallDir = '.'
self.allowPackages = False
if not PandaSystem.getPackageVersionString() or not PandaSystem.getPackageHostUrl():
raise PackagerError, 'This script must be run using a version of Panda3D that has been built\nfor distribution. Try using ppackage.p3d or packp3d.p3d instead.'
@ -2170,9 +2191,10 @@ class Packager:
if not package.p3dApplication and not package.solo:
packageNames.append(package.packageName)
from PatchMaker import PatchMaker
pm = PatchMaker(self.installDir)
pm.buildPatches(packageNames = packageNames)
if packageNames:
from PatchMaker import PatchMaker
pm = PatchMaker(self.installDir)
pm.buildPatches(packageNames = packageNames)
def readPackageDef(self, packageDef, packageNames = None):
""" Reads the named .pdef file and constructs the named
@ -2339,6 +2361,11 @@ class Packager:
package.p3dApplication = p3dApplication
package.solo = solo
if not package.p3dApplication and not self.allowPackages:
message = 'Cannot generate packages without an installDir; use -i'
raise PackagerError, message
def endPackage(self):
""" Closes the current package specification. This actually
@ -3123,6 +3150,10 @@ class Packager:
self.contents = {}
self.contentsChanged = False
if not self.allowPackages:
# Don't bother.
return
contentsFilename = Filename(self.installDir, 'contents.xml')
doc = TiXmlDocument(contentsFilename.toOsSpecific())
if not doc.LoadFile():

View File

@ -142,7 +142,7 @@ for opt, arg in opts:
elif opt == '-p':
buildPatches = True
elif opt == '-s':
installSearch.appendDirectory(Filename.fromOsSpecific(arg))
installSearch.append(Filename.fromOsSpecific(arg))
elif opt == '-S':
tokens = arg.split(',')
while len(tokens) < 4:
@ -172,10 +172,6 @@ packageNames = None
if len(args) > 1:
packageNames = args[1:]
if not installDir:
print '\nYou must name the target install directory with the -i parameter.\n'
sys.exit(1)
if universalBinaries:
if platforms:
print '\nYou may not specify both -u and -P.\n'
@ -190,7 +186,9 @@ if not platforms:
for platform in platforms:
packager = Packager.Packager(platform = platform)
packager.installDir = installDir
packager.installSearch = [installDir] + installSearch + packager.installSearch
packager.installSearch = installSearch + packager.installSearch
if installDir is not None:
packager.installSearch = [installDir] + packager.installSearch
packager.signParams = signParams
packager.allowPythonDev = allowPythonDev
packager.systemRoot = systemRoot