summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorepasrap2012-11-13 17:14:07 (EST)
committerPascal Rapicault2012-11-16 22:46:50 (EST)
commit2e76918e2f52b5bbccb6362d15b9641d1b36b8f9 (patch)
tree5955c1176a571ddfbb1de6a8e919b5fd9a283855
parentf0c014f98919be76c6abd2a8fb8d172500774099 (diff)
downloadrt.equinox.p2-2e76918e2f52b5bbccb6362d15b9641d1b36b8f9.zip
rt.equinox.p2-2e76918e2f52b5bbccb6362d15b9641d1b36b8f9.tar.gz
rt.equinox.p2-2e76918e2f52b5bbccb6362d15b9641d1b36b8f9.tar.bz2
Allow to install from a repository without copying the artifacts
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Repo2Runnable.java19
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/Repo2RunnableTask.java9
-rw-r--r--bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/artifact/IArtifactRepository.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java18
4 files changed, 48 insertions, 4 deletions
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Repo2Runnable.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Repo2Runnable.java
index e814e9f..91d6d42 100644
--- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Repo2Runnable.java
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Repo2Runnable.java
@@ -27,8 +27,7 @@ import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.query.QueryUtil;
-import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
-import org.eclipse.equinox.p2.repository.artifact.IArtifactRequest;
+import org.eclipse.equinox.p2.repository.artifact.*;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
/**
@@ -45,6 +44,8 @@ public class Repo2Runnable extends AbstractApplication implements IApplication {
private static final String PARM_OPERAND = "operand"; //$NON-NLS-1$
private static final String PARM_PROFILE = "profile"; //$NON-NLS-1$
+ private boolean flagAsRunnable = false;
+
protected class CollectNativesAction extends ProvisioningAction {
public IStatus execute(Map<String, Object> parameters) {
InstallableUnitOperand operand = (InstallableUnitOperand) parameters.get(PARM_OPERAND);
@@ -146,6 +147,7 @@ public class Repo2Runnable extends AbstractApplication implements IApplication {
// publish the metadata to a destination - if requested
publishMetadata(progress.newChild(1));
+ setRunnableProperty(destinationArtifactRepository);
// return the resulting status
return result;
} finally {
@@ -155,6 +157,11 @@ public class Repo2Runnable extends AbstractApplication implements IApplication {
}
}
+ private void setRunnableProperty(IArtifactRepository destinationArtifactRepository) {
+ if (flagAsRunnable)
+ destinationArtifactRepository.setProperty(IArtifactRepository.PROP_RUNNABLE, Boolean.TRUE.toString(), new NullProgressMonitor());
+ }
+
protected URI[] getRepositories(boolean metadata) {
List<URI> repos = new ArrayList<URI>();
for (RepositoryDescriptor repo : sourceRepositories) {
@@ -269,9 +276,17 @@ public class Repo2Runnable extends AbstractApplication implements IApplication {
destination.setLocation(URIUtil.fromString(arg));
addDestination(destination);
}
+
+ if (option.equalsIgnoreCase("-flagAsRunnable")) { //$NON-NLS-1$
+ setFlagAsRunnable(true);
+ }
}
}
+ public void setFlagAsRunnable(boolean runnable) {
+ flagAsRunnable = runnable;
+ }
+
/*
* Ensure all mandatory parameters have been set. Throw an exception if there
* are any missing. We don't require the user to specify the artifact repository here,
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/Repo2RunnableTask.java b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/Repo2RunnableTask.java
index a25b594..f782f62 100644
--- a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/Repo2RunnableTask.java
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/Repo2RunnableTask.java
@@ -10,12 +10,11 @@
*******************************************************************************/
package org.eclipse.equinox.p2.internal.repository.tools.tasks;
-import org.eclipse.equinox.p2.core.ProvisionException;
-
import java.util.List;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.internal.repository.tools.Messages;
import org.eclipse.equinox.p2.internal.repository.tools.Repo2Runnable;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
@@ -33,6 +32,7 @@ import org.eclipse.osgi.util.NLS;
public class Repo2RunnableTask extends AbstractRepositoryTask {
private boolean failOnError = true;
+ private boolean flagAsRunnable = false;
/*
* Constructor for the class. Create a new instance of the application
@@ -54,6 +54,7 @@ public class Repo2RunnableTask extends AbstractRepositoryTask {
if ((ius == null || ius.size() == 0) && !(application.hasArtifactSources() || application.hasMetadataSources()))
throw new BuildException(Messages.exception_needIUsOrNonEmptyRepo);
application.setSourceIUs(ius);
+ ((Repo2Runnable) application).setFlagAsRunnable(flagAsRunnable);
IStatus result = application.run(null);
if (failOnError && result.matches(IStatus.ERROR))
throw new ProvisionException(result);
@@ -69,4 +70,8 @@ public class Repo2RunnableTask extends AbstractRepositoryTask {
public void setFailOnError(boolean fail) {
this.failOnError = fail;
}
+
+ public void setFlagAsRunnable(boolean runnable) {
+ this.flagAsRunnable = runnable;
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/artifact/IArtifactRepository.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/artifact/IArtifactRepository.java
index 05c3381..8224c25 100644
--- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/artifact/IArtifactRepository.java
+++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/artifact/IArtifactRepository.java
@@ -34,6 +34,12 @@ import org.eclipse.equinox.p2.repository.artifact.spi.AbstractArtifactRepository
*/
public interface IArtifactRepository extends IRepository<IArtifactKey> {
+ /**
+ * The key for a boolean indicating if the repository is in runnable format.
+ * @see IRepository#getProperties()
+ */
+ public static final String PROP_RUNNABLE = "p2.runnable"; //$NON-NLS-1$
+
/**
* The return code to use when a client could/should retry a failed getArtifact() operation.
* For example, the repository may have additional mirrors that could be consulted.
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java
index da9d011..f371588 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java
@@ -26,6 +26,7 @@ import org.eclipse.equinox.p2.core.spi.Constants;
import org.eclipse.equinox.p2.engine.IProfile;
import org.eclipse.equinox.p2.metadata.*;
import org.eclipse.equinox.p2.repository.IRepository;
+import org.eclipse.equinox.p2.repository.IRepositoryManager;
import org.eclipse.equinox.p2.repository.artifact.*;
import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.osgi.service.environment.EnvironmentInfo;
@@ -143,9 +144,26 @@ public class Util {
}
}
}
+
+ getRunnableRepositories(manager, bundleRepositories);
return new AggregatedBundleRepository(agent, bundleRepositories);
}
+ private static void getRunnableRepositories(IArtifactRepositoryManager manager, List<IFileArtifactRepository> bundleRepositories) {
+ URI[] localURLs = manager.getKnownRepositories(IRepositoryManager.REPOSITORIES_LOCAL);
+ for (int i = 0; i < localURLs.length; i++) {
+ try {
+ IArtifactRepository candidate = manager.loadRepository(localURLs[i], new NullProgressMonitor());
+ if (Boolean.parseBoolean(candidate.getProperty(IArtifactRepository.PROP_RUNNABLE))) {
+ if (candidate != null && candidate instanceof IFileArtifactRepository && !bundleRepositories.contains(candidate))
+ bundleRepositories.add((IFileArtifactRepository) candidate);
+ }
+ } catch (ProvisionException e) {
+ //skip repositories that could not be read
+ }
+ }
+ }
+
private static List<String> getListProfileProperty(IProfile profile, String key) {
List<String> listProperty = new ArrayList<String>();
String dropinRepositories = profile.getProperty(key);