Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 219866 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/equinox/internal/provisional/p2/metadata/generator/Generator.java (-7 / +31 lines)
Lines 750-755 Link Here
750
		cu.setTouchpointType(MetadataGeneratorHelper.TOUCHPOINT_NATIVE);
750
		cu.setTouchpointType(MetadataGeneratorHelper.TOUCHPOINT_NATIVE);
751
		Map touchpointData = new HashMap();
751
		Map touchpointData = new HashMap();
752
		String configurationData = "unzip(source:@artifact, target:${installFolder});"; //$NON-NLS-1$
752
		String configurationData = "unzip(source:@artifact, target:${installFolder});"; //$NON-NLS-1$
753
754
		IInstallableUnit launcherNameIU = null;
755
756
		File executableLocation = info.getExecutableLocation();
757
		if (executableLocation != null) {
758
			if (!executableLocation.exists() && Constants.OS_WIN32.equals(os) && !executableLocation.getName().endsWith(".exe")) //$NON-NLS-1$
759
				executableLocation = new File(executableLocation.getParentFile(), executableLocation.getName() + ".exe"); //$NON-NLS-1$
760
761
			if (executableLocation.exists() && executableLocation.isFile())
762
				launcherNameIU = MetadataGeneratorHelper.generateLauncherSetter(executableLocation.getName(), launcherId, launcherVersion, os, ws, arch, result.rootIUs);
763
		}
764
753
		if (Constants.OS_MACOSX.equals(os)) {
765
		if (Constants.OS_MACOSX.equals(os)) {
754
			File[] appFolders = root.listFiles(new FilenameFilter() {
766
			File[] appFolders = root.listFiles(new FilenameFilter() {
755
				public boolean accept(File dir, String name) {
767
				public boolean accept(File dir, String name) {
Lines 762-780 Link Here
762
					File[] launcherFiles = macOSFolder.listFiles();
774
					File[] launcherFiles = macOSFolder.listFiles();
763
					for (int j = 0; j < launcherFiles.length; j++) {
775
					for (int j = 0; j < launcherFiles.length; j++) {
764
						configurationData += " chmod(targetDir:${installFolder}/" + appFolders[i].getName() + "/Contents/MacOS/, targetFile:" + launcherFiles[j].getName() + ", permissions:755);"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
776
						configurationData += " chmod(targetDir:${installFolder}/" + appFolders[i].getName() + "/Contents/MacOS/, targetFile:" + launcherFiles[j].getName() + ", permissions:755);"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
765
						if (new Path(launcherFiles[j].getName()).getFileExtension() == null)
777
						if (executableLocation == null && launcherFiles[i].isFile() && new Path(launcherFiles[j].getName()).getFileExtension() == null)
766
							MetadataGeneratorHelper.generateLauncherSetter(launcherFiles[j].getName(), launcherId, launcherVersion, os, ws, arch, result.rootIUs);
778
							launcherNameIU = MetadataGeneratorHelper.generateLauncherSetter(launcherFiles[j].getName(), launcherId, launcherVersion, os, ws, arch, result.rootIUs);
767
					}
779
					}
768
				}
780
				}
769
			}
781
			}
770
		}
782
		} else if (!Constants.OS_WIN32.equals(os)) {
771
		if (!Constants.OS_WIN32.equals(os) && !Constants.OS_MACOSX.equals(os)) {
772
			File[] launcherFiles = root.listFiles();
783
			File[] launcherFiles = root.listFiles();
773
			for (int i = 0; i < launcherFiles.length; i++) {
784
			for (int i = 0; launcherFiles != null && i < launcherFiles.length; i++) {
774
				configurationData += " chmod(targetDir:${installFolder}, targetFile:" + launcherFiles[i].getName() + ", permissions:755);"; //$NON-NLS-1$ //$NON-NLS-2$
785
				configurationData += " chmod(targetDir:${installFolder}, targetFile:" + launcherFiles[i].getName() + ", permissions:755);"; //$NON-NLS-1$ //$NON-NLS-2$
775
				if (new Path(launcherFiles[i].getName()).getFileExtension() == null)
786
				if (executableLocation == null && launcherFiles[i].isFile() && new Path(launcherFiles[i].getName()).getFileExtension() == null)
776
					MetadataGeneratorHelper.generateLauncherSetter(launcherFiles[i].getName(), launcherId, launcherVersion, os, ws, arch, result.rootIUs);
787
					launcherNameIU = MetadataGeneratorHelper.generateLauncherSetter(launcherFiles[i].getName(), launcherId, launcherVersion, os, ws, arch, result.rootIUs);
777
			}
788
			}
789
		} else if (launcherNameIU == null) {
790
			//windows
791
			File[] launcherFiles = root.listFiles(new FilenameFilter() {
792
				public boolean accept(File parent, String name) {
793
					return name.endsWith(".exe"); //$NON-NLS-1$
794
				}
795
			});
796
			if (launcherFiles != null && launcherFiles.length > 0)
797
				launcherNameIU = MetadataGeneratorHelper.generateLauncherSetter(launcherFiles[0].getName(), launcherId, launcherVersion, os, ws, arch, result.rootIUs);
778
		}
798
		}
779
		touchpointData.put("install", configurationData); //$NON-NLS-1$
799
		touchpointData.put("install", configurationData); //$NON-NLS-1$
780
		String unConfigurationData = "cleanupzip(source:@artifact, target:${installFolder});"; //$NON-NLS-1$
800
		String unConfigurationData = "cleanupzip(source:@artifact, target:${installFolder});"; //$NON-NLS-1$
Lines 785-793 Link Here
785
		//The Product Query will need to include the launcher CU fragments as a workaround to bug 218890
805
		//The Product Query will need to include the launcher CU fragments as a workaround to bug 218890
786
		if (result.configurationIUs.containsKey(launcherIdPrefix)) {
806
		if (result.configurationIUs.containsKey(launcherIdPrefix)) {
787
			((Set) result.configurationIUs.get(launcherIdPrefix)).add(unit);
807
			((Set) result.configurationIUs.get(launcherIdPrefix)).add(unit);
808
			if (launcherNameIU != null)
809
				((Set) result.configurationIUs.get(launcherIdPrefix)).add(launcherNameIU);
788
		} else {
810
		} else {
789
			Set set = new HashSet();
811
			Set set = new HashSet();
790
			set.add(unit);
812
			set.add(unit);
813
			if (launcherNameIU != null)
814
				set.add(launcherNameIU);
791
			result.configurationIUs.put(launcherIdPrefix, set);
815
			result.configurationIUs.put(launcherIdPrefix, set);
792
		}
816
		}
793
817
(-)src/org/eclipse/equinox/internal/provisional/p2/metadata/generator/MetadataGeneratorHelper.java (-6 / +10 lines)
Lines 772-778 Link Here
772
		// TODO: shouldn't the filter for the group be constructed from os, ws, arch, nl
772
		// TODO: shouldn't the filter for the group be constructed from os, ws, arch, nl
773
		// 		 of the feature?
773
		// 		 of the feature?
774
		// iu.setFilter(filter);
774
		// iu.setFilter(filter);
775
		
775
776
		// Create set of provided capabilities
776
		// Create set of provided capabilities
777
		ArrayList providedCapabilities = new ArrayList();
777
		ArrayList providedCapabilities = new ArrayList();
778
		providedCapabilities.add(createSelfCapability(id, version));
778
		providedCapabilities.add(createSelfCapability(id, version));
Lines 923-945 Link Here
923
		return createArtifactDescriptor(key, launcher, false, true);
923
		return createArtifactDescriptor(key, launcher, false, true);
924
	}
924
	}
925
925
926
	public static void generateLauncherSetter(String launcherName, String iuId, Version version, String os, String ws, String arch, Set result) {
926
	public static IInstallableUnit generateLauncherSetter(String launcherName, String iuId, Version version, String os, String ws, String arch, Set result) {
927
		InstallableUnitDescription iud = new MetadataFactory.InstallableUnitDescription();
927
		InstallableUnitDescription iud = new MetadataFactory.InstallableUnitDescription();
928
		iud.setId(iuId + '.' + launcherName);
928
		iud.setId(iuId + '.' + launcherName);
929
		iud.setVersion(version);
929
		iud.setVersion(version);
930
		iud.setTouchpointType(MetadataGeneratorHelper.TOUCHPOINT_OSGI);
930
		iud.setTouchpointType(MetadataGeneratorHelper.TOUCHPOINT_OSGI);
931
		iud.setCapabilities(new ProvidedCapability[] {createSelfCapability(iuId + '.' + launcherName, version)});
931
932
932
		if (os != null || ws != null || arch != null) {
933
		if (os != null || ws != null || arch != null) {
933
			String filterOs = os != null ? "(os=" + os + ")" : ""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
934
			String filterOs = os != null ? "(osgi.os=" + os + ")" : ""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
934
			String filterWs = ws != null ? "(ws=" + ws + ")" : ""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
935
			String filterWs = ws != null ? "(osgi.ws=" + ws + ")" : ""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
935
			String filterArch = arch != null ? "(arch=" + arch + ")" : ""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
936
			String filterArch = arch != null ? "(osgi.arch=" + arch + ")" : ""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
936
			iud.setFilter("(& " + filterOs + filterWs + filterArch + ")"); //$NON-NLS-1$ //$NON-NLS-2$
937
			iud.setFilter("(& " + filterOs + filterWs + filterArch + ")"); //$NON-NLS-1$ //$NON-NLS-2$
937
		}
938
		}
938
		Map touchpointData = new HashMap();
939
		Map touchpointData = new HashMap();
939
		touchpointData.put("configure", "setLauncherName(name:" + launcherName + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
940
		touchpointData.put("configure", "setLauncherName(name:" + launcherName + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
940
		touchpointData.put("unconfigure", "setLauncherName()"); //$NON-NLS-1$ //$NON-NLS-2$
941
		touchpointData.put("unconfigure", "setLauncherName()"); //$NON-NLS-1$ //$NON-NLS-2$
941
		iud.addTouchpointData(MetadataFactory.createTouchpointData(touchpointData));
942
		iud.addTouchpointData(MetadataFactory.createTouchpointData(touchpointData));
942
		result.add(MetadataFactory.createInstallableUnit(iud));
943
944
		IInstallableUnit iu = MetadataFactory.createInstallableUnit(iud);
945
		result.add(iu);
946
		return iu;
943
	}
947
	}
944
948
945
	public static ProvidedCapability createSelfCapability(String installableUnitId, Version installableUnitVersion) {
949
	public static ProvidedCapability createSelfCapability(String installableUnitId, Version installableUnitVersion) {

Return to bug 219866