Bläddra i källkod

Attempt at fixing stuff

rdb 15 år sedan
förälder
incheckning
4b7d6ef51d
1 ändrade filer med 40 tillägg och 23 borttagningar
  1. 40 23
      direct/src/p3d/DeploymentTools.py

+ 40 - 23
direct/src/p3d/DeploymentTools.py

@@ -240,6 +240,42 @@ class Installer:
             try: shutil.rmtree(self.tempDir.toOsSpecific())
             try: shutil.rmtree(self.tempDir.toOsSpecific())
             except: pass
             except: pass
 
 
+    def __installPackage(self, name, version, platform, host, superHost = None):
+        """ Internal function used by installPackagesInto.
+        Returns a *list* of packages, not a single one; None on failure. """
+
+        # Always try the super host first, if any.
+        package = None
+        if superHost:
+            if platform:
+                package = superHost.getPackage(name, version, platform)
+            if not package:
+                package = superHost.getPackage(name, version)
+
+        if not package and platform:
+            package = host.getPackage(name, version, platform)
+        if not package:
+            package = host.getPackage(name, version)
+        if not package:
+            Installer.notify.error("Package %s %s for %s not known on %s" % (
+                name, version, platform, host.hostUrl))
+            return []
+
+        package.installed = True # Hack not to let it unnecessarily install itself
+        if not package.downloadDescFile(self.http):
+            Installer.notify.error("  -> %s failed for platform %s" % (package.packageName, package.platform))
+            return []
+        if not package.downloadPackage(self.http):
+            Installer.notify.error("  -> %s failed for platform %s" % (package.packageName, package.platform))
+            return []
+
+        packages = [package]
+        # Check for any dependencies.
+        for rname, rversion, rhost in package.requires:
+            packages += self.__installPackage(rname, rversion, platform, rhost, superHost)
+
+        return packages
+
     def installPackagesInto(self, hostDir, platform):
     def installPackagesInto(self, hostDir, platform):
         """ Installs the packages required by the .p3d file into
         """ Installs the packages required by the .p3d file into
         the specified directory, for the given platform. """
         the specified directory, for the given platform. """
@@ -266,27 +302,8 @@ class Installer:
                         superHost = None
                         superHost = None
 
 
         for name, version in self.requirements:
         for name, version in self.requirements:
-            package = None
-            if superHost:
-                package = superHost.getPackage(name, version, platform)
-                if not package:
-                    package = superHost.getPackage(name, version)
-            if not package:
-                package = host.getPackage(name, version, platform)
-            if not package:
-                package = host.getPackage(name, version)
-            if not package:
-                Installer.notify.error("Package %s %s for %s not known on %s" % (
-                    name, version, platform, host.hostUrl))
-                continue
-            package.installed = True # Hack not to let it unnecessarily install itself
-            packages.append(package)
-            if not package.downloadDescFile(self.http):
-                Installer.notify.error("  -> %s failed for platform %s" % (package.packageName, package.platform))
-                continue
-            if not package.downloadPackage(self.http):
-                Installer.notify.error("  -> %s failed for platform %s" % (package.packageName, package.platform))
-                continue
+            packages += \
+                self.__installPackage(name, version, platform, host, superHost)
 
 
         # 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
         imageHost = host
@@ -325,7 +342,7 @@ 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)
-                os.chmod(archive.toOsSpecific(), 0600)
+                os.chmod(archive.toOsSpecific(), 0644)
                 if not mf.openReadWrite(archive):
                 if not mf.openReadWrite(archive):
                     Installer.notify.warning("Failed to open archive %s" % (archive))
                     Installer.notify.warning("Failed to open archive %s" % (archive))
                     continue
                     continue
@@ -349,7 +366,7 @@ class Installer:
                     archive.unlink()
                     archive.unlink()
                 else:
                 else:
                     mf.close()
                     mf.close()
-                    os.chmod(archive.toOsSpecific(), 0400)
+                    os.chmod(archive.toOsSpecific(), 0444)
 
 
         # Write out our own contents.xml file.
         # Write out our own contents.xml file.
         doc = TiXmlDocument()
         doc = TiXmlDocument()