[469837] Support for shared (read-only) installations produced using
bundle pools

https://bugs.eclipse.org/bugs/show_bug.cgi?id=469837
diff --git a/plugins/org.eclipse.oomph.p2.core/src/org/eclipse/oomph/p2/internal/core/AgentImpl.java b/plugins/org.eclipse.oomph.p2.core/src/org/eclipse/oomph/p2/internal/core/AgentImpl.java
index 9f533ae..0474053 100644
--- a/plugins/org.eclipse.oomph.p2.core/src/org/eclipse/oomph/p2/internal/core/AgentImpl.java
+++ b/plugins/org.eclipse.oomph.p2.core/src/org/eclipse/oomph/p2/internal/core/AgentImpl.java
@@ -947,33 +947,29 @@
       {
         if ("-startup".equals(trimmedKey))
         {
-          // For the -startup value, check if it's a relative path.
-          if (value.startsWith("../"))
+          // Create the URI for the value, and resolve it against the base URI (in case it's relative) and also check that this library file actually exists.
+          URI absoluteLauncherLibraryLocation = URI.createFileURI(value.trim()).resolve(baseURI);
+          File absoluteLauncherLibraryFile = new File(absoluteLauncherLibraryLocation.toFileString());
+          if (absoluteLauncherLibraryFile.isFile())
           {
-            // Resolve it against the base URI and check that this file actually exists.
-            URI absoluteLauncherLibraryLocation = URI.createURI(value.trim()).resolve(baseURI);
-            File absoluteLauncherLibraryFile = new File(absoluteLauncherLibraryLocation.toFileString());
-            if (absoluteLauncherLibraryFile.exists())
+            // We'll copy this to the installation folder.
+            // We do this because the Equinox launcher org.eclipse.equinox.launcher.Main.getInstallLocation()
+            // computes the installation location from the location of this bundle.
+            // If we leave it as a relative path that references something outside the installation,
+            // the installation can't roam.
+            // Note that on the Mac we're replacing it with a relative path that starts with ..
+            // so we'd better be sure we don't try to copy the file to itself.
+            File localLauncherLibraryFile = new File(new File(installFolder, "plugins"), absoluteLauncherLibraryLocation.lastSegment());
+            if (!localLauncherLibraryFile.equals(absoluteLauncherLibraryFile))
             {
-              // We'll copy this to the installation folder.
-              // We do this because the Equinox launcher org.eclipse.equinox.launcher.Main.getInstallLocation()
-              // computes the installation location from the location of this bundle.
-              // If we leave it as a relative path that references something outside the installation,
-              // the installation can't roam.
-              // Note that on the Mac we're replacing it with a relative path that starts with ..
-              // so we'd better be sure we don't try to copy the file to itself.
-              File localLauncherLibraryFile = new File(new File(installFolder, "plugins"), absoluteLauncherLibraryLocation.lastSegment());
-              if (!localLauncherLibraryFile.equals(absoluteLauncherLibraryFile))
-              {
-                IOUtil.copyFile(absoluteLauncherLibraryFile, localLauncherLibraryFile);
+              IOUtil.copyFile(absoluteLauncherLibraryFile, localLauncherLibraryFile);
 
-                // Remember the line feed convention used for this section.
-                nl = key.substring(trimmedKey.length());
+              // Remember the line feed convention used for this section.
+              nl = key.substring(trimmedKey.length());
 
-                // The value is therefore the relative path to this copied target within the installation.
-                value = (Platform.OS_MACOSX.equals(Util.getOSFromProfile(profile)) ? "../Eclipse/plugins/" : "plugins/")
-                    + absoluteLauncherLibraryLocation.lastSegment() + nl;
-              }
+              // The value is therefore the relative path to this copied target within the installation.
+              value = (Platform.OS_MACOSX.equals(Util.getOSFromProfile(profile)) ? "../Eclipse/plugins/" : "plugins/")
+                  + absoluteLauncherLibraryLocation.lastSegment() + nl;
             }
           }
         }