diff options
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CheckAndPromptNativePackage.java')
-rw-r--r-- | bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CheckAndPromptNativePackage.java | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CheckAndPromptNativePackage.java b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CheckAndPromptNativePackage.java index 38dd03da3..66f2cad4a 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CheckAndPromptNativePackage.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/CheckAndPromptNativePackage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014, 2017 Rapicorp, Inc. and others. + * Copyright (c) 2014, 2019 Rapicorp, Inc. and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -20,6 +20,7 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.equinox.internal.p2.touchpoint.natives.*; import org.eclipse.equinox.p2.engine.spi.ProvisioningAction; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.osgi.util.NLS; public class CheckAndPromptNativePackage extends ProvisioningAction { @@ -30,22 +31,24 @@ public class CheckAndPromptNativePackage extends ProvisioningAction { @Override public IStatus execute(Map<String, Object> parameters) { - //Get and check the paremeters + // Get and check the paremeters String distro = (String) parameters.get(ActionConstants.PARM_LINUX_DISTRO); String packageName = (String) parameters.get(ActionConstants.PARM_LINUX_PACKAGE_NAME); String packageVersion = (String) parameters.get(ActionConstants.PARM_LINUX_PACKAGE_VERSION); String versionComparator = (String) parameters.get(ActionConstants.PARM_LINUX_VERSION_COMPARATOR); + IInstallableUnit iu = (IInstallableUnit) parameters.get(ActionConstants.PARM_IU); if (distro == null || packageName == null || (versionComparator != null && packageVersion == null)) return new Status(IStatus.ERROR, Activator.ID, Messages.Incorrect_Command); distro = distro.toLowerCase(); - //If we are not running the distro we are provisioning, do nothing and return + // If we are not running the distro we are provisioning, do nothing and return if (!runningDistro(distro)) return Status.OK_STATUS; - //Check if the desired package is installed and collect information in the touchpoint + // Check if the desired package is installed and collect information in the + // touchpoint File scriptToExecute = NativeTouchpoint.getFileFromBundle(distro, IS_INSTALLED); if (scriptToExecute == null) return new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.Cannot_Find_status, distro)); @@ -64,23 +67,26 @@ public class CheckAndPromptNativePackage extends ProvisioningAction { } int exitValue = new ProcessBuilder(cmd).start().waitFor(); switch (exitValue) { - case 0 : - return Status.OK_STATUS; - case 1 : - case 2 : - ((NativeTouchpoint) getTouchpoint()).addPackageToInstall(new NativePackageEntry(packageName, packageVersion, versionComparator)); - ((NativeTouchpoint) getTouchpoint()).setDistro(distro); - return Status.OK_STATUS; + case 0: + return Status.OK_STATUS; + case 1: + case 2: + ((NativeTouchpoint) getTouchpoint()).addPackageToInstall( + new NativePackageEntry(packageName, packageVersion, versionComparator), iu); + ((NativeTouchpoint) getTouchpoint()).setDistro(distro); + return Status.OK_STATUS; } } catch (IOException e) { - return new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.Cannot_Check_Package, new String[] {packageName, packageVersion, distro})); + return new Status(IStatus.ERROR, Activator.ID, + NLS.bind(Messages.Cannot_Check_Package, new String[] { packageName, packageVersion, distro })); } catch (InterruptedException e) { - return new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.Cannot_Check_Package, new String[] {packageName, packageVersion, distro})); + return new Status(IStatus.ERROR, Activator.ID, + NLS.bind(Messages.Cannot_Check_Package, new String[] { packageName, packageVersion, distro })); } return Status.OK_STATUS; } - //Check if the given distro is currently being run + // Check if the given distro is currently being run protected boolean runningDistro(String distro) { try { File scriptToExecute = NativeTouchpoint.getFileFromBundle(distro, IS_RUNNING); @@ -103,7 +109,7 @@ public class CheckAndPromptNativePackage extends ProvisioningAction { @Override public IStatus undo(Map<String, Object> parameters) { - //Nothing to do since we are not modifying any state. + // Nothing to do since we are not modifying any state. return null; } |