diff --git a/direct/src/plugin_installer/make_installer.py b/direct/src/plugin_installer/make_installer.py
index 702c3be8cc..9cb1d44475 100755
--- a/direct/src/plugin_installer/make_installer.py
+++ b/direct/src/plugin_installer/make_installer.py
@@ -9,6 +9,11 @@ import zipfile
from optparse import OptionParser
import subprocess
+try:
+ from hashlib import sha1 as sha
+except ImportError:
+ from sha import sha
+
usage = """
This command creates a graphical installer for the
Panda3D plugin and runtime environment.
@@ -60,8 +65,8 @@ parser.add_option('', '--mssdk', dest = 'mssdk',
default = None)
parser.add_option('-i', '--plugin_root', dest = 'plugin_root',
help = 'The root of a directory hierarchy in which the Firefox plugins for various platforms can be found, to build a Firefox xpi file. This is normally the same as the staging directory populated by the -i parameter to ppackage. This directory should contain a directory called "plugin", which contains in turn a number of directories named for the platform, by the Panda plugin convention, e.g. linux_i386, osx_ppc, and so on. Each platform directory should contain a Firefox plugin, e.g. nppanda3d.so.')
-parser.add_option('', '--update_url', dest = 'update_url',
- help = "The URL for the Firefox XPI file's updateURL specification. Optional.")
+parser.add_option('', '--host_url', dest = 'host_url',
+ help = "The URL at which plugin_root will be hosted. This is used to construct the update URL for the xpi file. This is required if you specify --plugin_root.")
(options, args) = parser.parse_args()
@@ -101,15 +106,47 @@ install_rdf = """
{ec8030f7-c20a-464f-9b0e-13a3a9e97384}
3.0
- 3.*
+ *
http://www.panda3d.org/
- %(updateURL)s
+ %(host_url)s/plugin/firefox/nppanda3d.rdf
"""
+##############################################################################
+#
+# This update.rdf file is used when building a Firefox XPI file.
+#
+##############################################################################
+
+update_rdf = """
+
+
+
+
+
+
+
+ %(version)s
+
+
+ {ec8030f7-c20a-464f-9b0e-13a3a9e97384}
+ 3.0
+ *
+ %(host_url)s/plugin/firefox/nppanda3d.xpi
+ sha1:%(xpi_hash)s
+
+
+
+
+
+
+
+"""
+
##############################################################################
#
# This Info.plist file is used only for the OSX 10.4 version of packagemaker.
@@ -344,6 +381,10 @@ def makeXpiFile():
""" Creates a Firefox XPI file, based on the various platform
version files. """
+ if not options.host_url:
+ print "Cannot generate xpi file without --host-url."
+ sys.exit(1)
+
print "Generating xpi file"
root = options.plugin_root
if os.path.isdir(os.path.join(root, 'plugin')):
@@ -353,16 +394,12 @@ def makeXpiFile():
package_id = 'runtime@panda3d.org' #TODO: maybe more customizable?
- updateURL = ''
- if options.update_url:
- updateURL = '%s' % (options.update_url)
-
tempFile = tempfile.mktemp('.txt', 'p3d_')
rdf = open(tempFile, 'w')
rdf.write(install_rdf % {
'package_id' : package_id,
'version' : options.version,
- 'updateURL' : updateURL,
+ 'host_url' : options.host_url,
})
rdf.close()
xpi.write(tempFile, 'install.rdf')
@@ -386,6 +423,21 @@ def makeXpiFile():
addZipTree(xpi, os.path.join(path, pluginFilename),
pluginsXpiDir + '/' + pluginFilename)
+ xpi.close()
+
+ # Now that we've generated the xpi file, get its hash.
+ data = open('nppanda3d.xpi', 'rb').read()
+ xpi_hash = sha(data).hexdigest()
+
+ # And now we can generate the update.rdf file.
+ update = open('update.rdf', 'w')
+ update.write(update_rdf % {
+ 'package_id' : package_id,
+ 'version' : options.version,
+ 'host_url' : options.host_url,
+ 'xpi_hash' : xpi_hash,
+ })
+ update.close()
def addZipTree(zip, sourceFile, zipName):
""" Adds the sourceFile to the zip archive at the indicated name.
diff --git a/direct/src/plugin_standalone/make_osx_bundle.py b/direct/src/plugin_standalone/make_osx_bundle.py
index 720f4be4d3..5f3b9922f6 100755
--- a/direct/src/plugin_standalone/make_osx_bundle.py
+++ b/direct/src/plugin_standalone/make_osx_bundle.py
@@ -44,7 +44,8 @@ def makeBundle(startDir):
# Generate the bundle directory structure
rootFilename = Filename(fstartDir)
bundleFilename = Filename(rootFilename, 'Panda3D.app')
- shutil.rmtree(bundleFilename.toOsSpecific())
+ if os.path.exists(bundleFilename.toOsSpecific()):
+ shutil.rmtree(bundleFilename.toOsSpecific())
plistFilename = Filename(bundleFilename, 'Contents/Info.plist')
plistFilename.makeDir()