fix some pdeploy issues on win32

This commit is contained in:
David Rose 2011-02-15 21:30:23 +00:00
parent 9c1c10ea4b
commit 7de7c793bc
2 changed files with 55 additions and 15 deletions

View File

@ -245,15 +245,21 @@ class Installer:
continue continue
# Also install the 'images' package from the same host that p3dembed was downloaded from. # Also install the 'images' package from the same host that p3dembed was downloaded from.
imageHost = host
if host.hostUrl != self.standalone.host.hostUrl: if host.hostUrl != self.standalone.host.hostUrl:
host = HostInfo(self.standalone.host.hostUrl, appRunner = appRunner, hostDir = hostDir, asMirror = False, perPlatform = False) imageHost = HostInfo(self.standalone.host.hostUrl, appRunner = appRunner, hostDir = hostDir, asMirror = False, perPlatform = False)
if not host.hasContentsFile: if not imageHost.hasContentsFile:
if not host.readContentsFile(): if not imageHost.readContentsFile():
if not host.downloadContentsFile(self.http): if not imageHost.downloadContentsFile(self.http):
Installer.notify.error("couldn't read host %s" % host.hostUrl) Installer.notify.error("couldn't read host %s" % imageHost.hostUrl)
return return
for package in superHost.getPackages(name = "images") + host.getPackages(name = "images"): imagePackages = []
if superHost:
imagePackages += superHost.getPackages(name = "images")
imagePackages += imageHost.getPackages(name = "images")
for package in imagePackages:
package.installed = True # Hack not to let it unnecessarily install itself package.installed = True # Hack not to let it unnecessarily install itself
packages.append(package) packages.append(package)
if not package.downloadDescFile(self.http): if not package.downloadDescFile(self.http):
@ -275,8 +281,9 @@ class Installer:
mf = Multifile() mf = Multifile()
# Make sure that it isn't mounted before altering it, just to be safe # Make sure that it isn't mounted before altering it, just to be safe
vfs.unmount(archive) vfs.unmount(archive)
if not mf.openRead(archive): os.chmod(archive.toOsSpecific(), 0600)
Installer.notify.warning("Failed to open archive " + archive) if not mf.openReadWrite(archive):
Installer.notify.warning("Failed to open archive %s" % (archive))
continue continue
# We don't iterate over getNumSubfiles because we're # We don't iterate over getNumSubfiles because we're
@ -285,6 +292,7 @@ class Installer:
for subfile in subfiles: for subfile in subfiles:
# We do *NOT* call vfs.exists here in case the package is mounted. # We do *NOT* call vfs.exists here in case the package is mounted.
if Filename(package.getPackageDir(), subfile).exists(): if Filename(package.getPackageDir(), subfile).exists():
Installer.notify.debug("Removing already-extracted %s from multifile" % (subfile))
mf.removeSubfile(subfile) mf.removeSubfile(subfile)
# This seems essential for mf.close() not to crash later. # This seems essential for mf.close() not to crash later.
@ -292,11 +300,12 @@ class Installer:
# If we have no subfiles left, we can just remove the multifile. # If we have no subfiles left, we can just remove the multifile.
if mf.getNumSubfiles() == 0: if mf.getNumSubfiles() == 0:
Installer.notify.info("Removing empty archive " + package.uncompressedArchive.filename) Installer.notify.info("Removing empty archive %s" % (package.uncompressedArchive.filename))
mf.close() mf.close()
archive.unlink() archive.unlink()
else: else:
mf.close() mf.close()
os.chmod(archive.toOsSpecific(), 0400)
# Write out our own contents.xml file. # Write out our own contents.xml file.
doc = TiXmlDocument() doc = TiXmlDocument()
@ -673,7 +682,7 @@ class Installer:
nsi.write('!define MUI_ABORTWARNING\n') nsi.write('!define MUI_ABORTWARNING\n')
nsi.write('!define MUI_FINISHPAGE_RUN\n') nsi.write('!define MUI_FINISHPAGE_RUN\n')
nsi.write('!define MUI_FINISHPAGE_RUN_FUNCTION launch\n') nsi.write('!define MUI_FINISHPAGE_RUN_FUNCTION launch\n')
nsi.write('!define MUI_FINISHPAGE_RUN_TEXT "Play %s"\n' % self.fullname) nsi.write('!define MUI_FINISHPAGE_RUN_TEXT "Run %s"\n' % self.fullname)
nsi.write('\n') nsi.write('\n')
nsi.write('Var StartMenuFolder\n') nsi.write('Var StartMenuFolder\n')
nsi.write('!insertmacro MUI_PAGE_WELCOME\n') nsi.write('!insertmacro MUI_PAGE_WELCOME\n')
@ -696,7 +705,7 @@ class Installer:
for f in extrafiles: for f in extrafiles:
nsi.write(' File "%s"\n' % f.toOsSpecific()) nsi.write(' File "%s"\n' % f.toOsSpecific())
curdir = "" curdir = ""
for root, dirs, files in os.walk(hostDir.toOsSpecific()): for root, dirs, files in self.os_walk(hostDir.toOsSpecific()):
for name in files: for name in files:
file = Filename.fromOsSpecific(os.path.join(root, name)) file = Filename.fromOsSpecific(os.path.join(root, name))
file.makeAbsolute() file.makeAbsolute()
@ -710,6 +719,7 @@ class Installer:
nsi.write(' ; Start menu items\n') nsi.write(' ; Start menu items\n')
nsi.write(' !insertmacro MUI_STARTMENU_WRITE_BEGIN Application\n') nsi.write(' !insertmacro MUI_STARTMENU_WRITE_BEGIN Application\n')
nsi.write(' CreateDirectory "$SMPROGRAMS\\$StartMenuFolder"\n') nsi.write(' CreateDirectory "$SMPROGRAMS\\$StartMenuFolder"\n')
nsi.write(' CreateShortCut "$SMPROGRAMS\\$StartMenuFolder\\%s.lnk" "$INSTDIR\\%s.exe"\n' % (self.fullname, self.shortname))
nsi.write(' CreateShortCut "$SMPROGRAMS\\$StartMenuFolder\\Uninstall.lnk" "$INSTDIR\\Uninstall.exe"\n') nsi.write(' CreateShortCut "$SMPROGRAMS\\$StartMenuFolder\\Uninstall.lnk" "$INSTDIR\\Uninstall.exe"\n')
nsi.write(' !insertmacro MUI_STARTMENU_WRITE_END\n') nsi.write(' !insertmacro MUI_STARTMENU_WRITE_END\n')
nsi.write('SectionEnd\n') nsi.write('SectionEnd\n')
@ -735,9 +745,14 @@ class Installer:
cmd += " /" + o cmd += " /" + o
else: else:
cmd += " -" + o cmd += " -" + o
cmd += " " + nsifile.toOsSpecific() cmd += " \"" + nsifile.toOsSpecific() + "\""
print cmd print cmd
os.system(cmd) try:
retcode = subprocess.call(cmd, shell = False)
if retcode != 0:
self.notify.warning("Failure invoking NSIS command.")
except OSError:
self.notify.warning("Unable to invoke NSIS command.")
nsifile.unlink() nsifile.unlink()
try: try:
@ -746,3 +761,27 @@ class Installer:
try: shutil.rmtree(hostDir.toOsSpecific()) try: shutil.rmtree(hostDir.toOsSpecific())
except: pass except: pass
return output return output
def os_walk(self, top):
""" Re-implements os.walk(). For some reason the built-in
definition is failing on Windows when this is run within a p3d
environment!? """
dirnames = []
filenames = []
dirlist = os.listdir(top)
if dirlist:
for file in dirlist:
path = os.path.join(top, file)
if os.path.isdir(path):
dirnames.append(file)
else:
filenames.append(file)
yield (top, dirnames, filenames)
for dir in dirnames:
next = os.path.join(top, dir)
for tuple in self.os_walk(next):
yield tuple

View File

@ -306,6 +306,7 @@ class PackageInfo:
if not self.__readDescFile(): if not self.__readDescFile():
# Weird, it passed the hash check, but we still can't read # Weird, it passed the hash check, but we still can't read
# it. # it.
filename = Filename(self.getPackageDir(), self.descFileBasename)
self.notify.warning("Failure reading %s" % (filename)) self.notify.warning("Failure reading %s" % (filename))
yield self.stepFailed; return yield self.stepFailed; return