mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 01:44:06 -04:00
update.rdf files
This commit is contained in:
parent
a0c7fe7a81
commit
82f49bb352
@ -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 = """<?xml version="1.0"?>
|
||||
<Description>
|
||||
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
|
||||
<em:minVersion>3.0</em:minVersion>
|
||||
<em:maxVersion>3.*</em:maxVersion>
|
||||
<em:maxVersion>*</em:maxVersion>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
<em:homepageURL>http://www.panda3d.org/</em:homepageURL>
|
||||
%(updateURL)s
|
||||
<em:updateURL>%(host_url)s/plugin/firefox/nppanda3d.rdf</em:updateURL>
|
||||
</Description>
|
||||
</RDF>
|
||||
"""
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# This update.rdf file is used when building a Firefox XPI file.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
update_rdf = """<?xml version="1.0"?>
|
||||
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
|
||||
|
||||
<RDF:Description about="urn:mozilla:item:%(package_id)s">
|
||||
<em:updates>
|
||||
<RDF:Seq>
|
||||
<RDF:li>
|
||||
<RDF:Description>
|
||||
<em:version>%(version)s</em:version>
|
||||
<em:targetApplication>
|
||||
<RDF:Description>
|
||||
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
|
||||
<em:minVersion>3.0</em:minVersion>
|
||||
<em:maxVersion>*</em:maxVersion>
|
||||
<em:updateLink>%(host_url)s/plugin/firefox/nppanda3d.xpi</em:updateLink>
|
||||
<em:updateHash>sha1:%(xpi_hash)s</em:updateHash>
|
||||
</em:targetApplication>
|
||||
</RDF:Description>
|
||||
</RDF:li>
|
||||
</RDF:Seq>
|
||||
</em:updates>
|
||||
</RDF:Description>
|
||||
</RDF:RDF>
|
||||
"""
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# 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 = '<em:updateURL>%s</em:updateURL>' % (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.
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user