| e4 selfupdate  [message #898684] | 
Fri, 27 July 2012 04:14   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
hi all,  
 
i have a pure e4 application project test that includes a feature project,  
i would like to use p2 to automatically update the application, that's the method  
i call on startup:    
 
 
public static IStatus checkForUpdates(final IProvisioningAgent agent, final IProgressMonitor monitor) throws OperationCanceledException, InvocationTargetException {
		addUpdateSite(agent); //add my http update site
		ProvisioningSession session = new ProvisioningSession(agent);
		ProvisioningContext context = new ProvisioningContext(agent);
		IProfileRegistry profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
		IProfile self = profileRegistry.getProfile(IProfileRegistry.SELF);
		Set<IInstallableUnit> ius = self.query(QueryUtil.createIUAnyQuery(), monitor).toSet();
		UpdateOperation operation = new UpdateOperation(session, ius);
		SubMonitor sub = SubMonitor.convert(new NullProgressMonitor(), "Checking for application updates...", 200);
		IStatus status = operation.resolveModal(sub.newChild(100));
		LOG.info(status);
		if (status.getCode() == UpdateOperation.STATUS_NOTHING_TO_UPDATE) {
			return status;
		}
		if (status.getSeverity() == IStatus.CANCEL) {
			throw new OperationCanceledException();
		}
		if (status.getSeverity() != IStatus.ERROR) {
			// More complex status handling might include showing the user what
			// updates are available if there are multiples, differentiating
			// patches vs. updates, etc. In this example, we simply update as
			// suggested by the operation.
			ProvisioningJob job = operation.getProvisioningJob(null);
			if (job == null) {
				return new Status(IStatus.ERROR, "p2testapp", "ProvisioningJob could not be created - does this application support p2 software installation?");
			}
			status = job.runModal(sub.newChild(100));
			LOG.info(status);
			if (status.getSeverity() == IStatus.CANCEL) {
				throw new OperationCanceledException();
			}
		}
		return status;
	}
 
 
and that's what a get: "...Only one of the following can be installed at once...  p2testapp.feature 1.0.0.20120725 .... p2testapp.feature 1.0.0.20120730..." 
 
 
[main] INFO  p2testapp.p2.P2Util  - Status ERROR: org.eclipse.equinox.p2.operations code=0 Operation details null children=[org.eclipse.equinox.internal.provisional.p2.director.PlannerStatus@13da8a5] 
[main] INFO  p2testapp.p2.P2Util  - Status: false 
[main] INFO  p2testapp.p2.P2Util  - Message: Operation details 
[main] INFO  p2testapp.p2.P2Util  - org.eclipse.equinox.internal.provisional.p2.director.PlannerStatus@13da8a5 
[main] INFO  p2testapp.p2.P2Util  - Status ERROR: org.eclipse.equinox.p2.director code=0 Software being installed: p2testapp.feature 1.0.0.20120730 (p2testapp.feature.feature.group 1.0.0.20120730) null 
[main] INFO  p2testapp.p2.P2Util  - Status ERROR: org.eclipse.equinox.p2.director code=0 Software currently installed: p2testapp.product 1.0.0.20120725 (p2testapp.product 1.0.0.20120725) null 
[main] INFO  p2testapp.p2.P2Util  - Status ERROR: org.eclipse.equinox.p2.director code=1 Only one of the following can be installed at once:  null children=[Status ERROR: org.eclipse.equinox.p2.director code=0 p2testapp.feature 1.0.0.20120725 (p2testapp.feature.feature.jar 1.0.0.20120725) null Status ERROR: org.eclipse.equinox.p2.director code=0 p2testapp.feature 1.0.0.20120730 (p2testapp.feature.feature.jar 1.0.0.20120730) null] 
[main] INFO  p2testapp.p2.P2Util  - Status ERROR: org.eclipse.equinox.p2.director code=1 Cannot satisfy dependency: null children=[Status ERROR: org.eclipse.equinox.p2.director code=0 From: p2testapp.feature 1.0.0.20120725 (p2testapp.feature.feature.group 1.0.0.20120725) null Status ERROR: org.eclipse.equinox.p2.director code=0 To: p2testapp.feature.feature.jar [1.0.0.20120725] null] 
[main] INFO  p2testapp.p2.P2Util  - Status ERROR: org.eclipse.equinox.p2.director code=1 Cannot satisfy dependency: null children=[Status ERROR: org.eclipse.equinox.p2.director code=0 From: p2testapp.feature 1.0.0.20120730 (p2testapp.feature.feature.group 1.0.0.20120730) null Status ERROR: org.eclipse.equinox.p2.director code=0 To: p2testapp.feature.feature.jar [1.0.0.20120730] null] 
[main] INFO  p2testapp.p2.P2Util  - Status ERROR: org.eclipse.equinox.p2.director code=1 Cannot satisfy dependency: null children=[Status ERROR: org.eclipse.equinox.p2.director code=0 From: p2testapp.product 1.0.0.20120725 (p2testapp.product 1.0.0.20120725) null Status ERROR: org.eclipse.equinox.p2.director code=0 To: p2testapp.feature.feature.group [1.0.0.20120725] null] 
 
 
i have been struggling with p2 for some days now, i think the problem could be that my product is a singleton (and must be) and p2 does not automatically update any existing version of a root UI, i've tried to uninstall and install but i get another error. I've also tried the P2Util class at http://wiki.eclipse.org/Equinox/p2/Adding_Self-Update_to_an_RCP_Application 
but it tells to me the there are not updates: "Status INFO: org.eclipse.equinox.p2.operations code=10000 No updates were found. null" 
 
so, where I'm wrong?  
 |  
 |  
  | 
 | 
| Re: e4 selfupdate  [message #1000367 is a reply to message #1000290] | 
Mon, 14 January 2013 10:54    | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Hi Christoph,  
 
i'm using this class to update my application: 
 
public class P2Util {
	private static Logger LOG = Logger.getLogger(P2Util.class);
	public static IStatus checkForUpdates(IProvisioningAgent agent, IProgressMonitor monitor) throws Exception {
		try {
			addUpdateSite(agent);
			ProvisioningSession session = new ProvisioningSession(agent);
			// the default update operation looks for updates to the currently
			// running profile, using the default profile root marker. To change
			// which installable units are being updated, use the more detailed
			// constructors.
			UpdateOperation operation = new UpdateOperation(session);
			SubMonitor sub = SubMonitor.convert(monitor, "Checking for application updates...", 200);
			IStatus status = operation.resolveModal(sub.newChild(100));
			if (status.getCode() == UpdateOperation.STATUS_NOTHING_TO_UPDATE) {
				return status;
			}
			if (status.getSeverity() == IStatus.CANCEL)
				throw new OperationCanceledException();
			if (status.getSeverity() != IStatus.ERROR) {
				// More complex status handling might include showing the user what updates
				// are available if there are multiples, differentiating patches vs. updates, etc.
				// In this example, we simply update as suggested by the operation.
				ProvisioningJob job = operation.getProvisioningJob(null);
				status = job.runModal(sub.newChild(100));
				if (status.getSeverity() == IStatus.CANCEL)
					throw new OperationCanceledException();
			}
			return status;
		} catch (Throwable ex) {
			LOG.error(ex);
			return null;
		} finally {
			// if (useProxy) {
			// proxySettings.resetProxy();
			// }
		}
	}
	private static void addUpdateSite(IProvisioningAgent provisioningAgent) throws InvocationTargetException {
		// Load repository manager
		IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) provisioningAgent.getService(IMetadataRepositoryManager.SERVICE_NAME);
		if (metadataManager == null) {
			System.err.println("Metadata manager was null");
			Throwable throwable = new Throwable("Could not load Metadata Repository Manager");
			throwable.fillInStackTrace();
			throw new InvocationTargetException(throwable);
		}
		// Load artifact manager
		IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) provisioningAgent.getService(IArtifactRepositoryManager.SERVICE_NAME);
		if (artifactManager == null) {
			System.err.println("Artifact manager was null");
			Throwable throwable = new Throwable("Could not load Artifact Repository Manager");
			throwable.fillInStackTrace();
			throw new InvocationTargetException(throwable);
		}
		// Load repo
		try {
			URI repoLocation = new URI(Configuration.instance().getAutoUpdatesUrl());
			System.out.println("Adding repository " + repoLocation);
			metadataManager.loadRepository(repoLocation, null);
			artifactManager.loadRepository(repoLocation, null);
		} catch (ProvisionException pe) {
			System.err.println("Caught provisioning exception " + pe.getMessage()/* , pe */);
			throw new InvocationTargetException(pe);
		} catch (URISyntaxException e) {
			System.err.println("Caught URI syntax exception " + e.getMessage()/* , e */);
			throw new InvocationTargetException(e);
		}
	}
}
 
 
 
my repository contains the files generated by the product export in the "repository" dir.  
 
That's the list of plugins i have incuded in my feature: 
 
<plugin
      id="org.eclipse.ecf"
      download-size="0"
      install-size="0"
      version="0.0.0"
      unpack="false"/>
<plugin
      id="org.eclipse.ecf.filetransfer"
      download-size="0"
      install-size="0"
      version="0.0.0"
      unpack="false"/>
<plugin
      id="org.eclipse.ecf.identity"
      download-size="0"
      install-size="0"
      version="0.0.0"
      unpack="false"/>
<plugin
      id="org.eclipse.ecf.provider.filetransfer"
      download-size="0"
      install-size="0"
      version="0.0.0"
      unpack="false"/>
<plugin
      id="org.eclipse.ecf.provider.filetransfer.httpclient"
      download-size="0"
      install-size="0"
      version="0.0.0"
      unpack="false"/>
<plugin
      id="org.eclipse.ecf.provider.filetransfer.httpclient.ssl"
      download-size="0"
      install-size="0"
      version="0.0.0"
      fragment="true"
      unpack="false"/>
<plugin
      id="org.eclipse.ecf.provider.filetransfer.ssl"
      download-size="0"
      install-size="0"
      version="0.0.0"
      fragment="true"
      unpack="false"/>
<plugin
      id="org.eclipse.ecf.ssl"
      download-size="0"
      install-size="0"
      version="0.0.0"
      fragment="true"
      unpack="false"/>
<plugin
      id="org.eclipse.equinox.p2.artifact.repository"
      download-size="0"
      install-size="0"
      version="0.0.0"
      unpack="false"/>
<plugin
      id="org.eclipse.equinox.p2.console"
      download-size="0"
      install-size="0"
      version="0.0.0"
      unpack="false"/>
<plugin
      id="org.eclipse.equinox.p2.core"
      download-size="0"
      install-size="0"
      version="0.0.0"
      unpack="false"/>
<plugin
      id="org.eclipse.equinox.p2.director"
      download-size="0"
      install-size="0"
      version="0.0.0"
      unpack="false"/>
<plugin
      id="org.eclipse.equinox.p2.director.app"
      download-size="0"
      install-size="0"
      version="0.0.0"
      unpack="false"/>
<plugin
      id="org.eclipse.equinox.p2.directorywatcher"
      download-size="0"
      install-size="0"
      version="0.0.0"
      unpack="false"/>
<plugin
      id="org.eclipse.equinox.p2.engine"
      download-size="0"
      install-size="0"
      version="0.0.0"
      unpack="false"/>
<plugin
      id="org.eclipse.equinox.p2.extensionlocation"
      download-size="0"
      install-size="0"
      version="0.0.0"
      unpack="false"/>
<plugin
      id="org.eclipse.equinox.p2.garbagecollector"
      download-size="0"
      install-size="0"
      version="0.0.0"
      unpack="false"/>
<plugin
      id="org.eclipse.equinox.p2.jarprocessor"
      download-size="0"
      install-size="0"
      version="0.0.0"
      unpack="false"/>
<plugin
      id="org.eclipse.equinox.p2.metadata"
      download-size="0"
      install-size="0"
      version="0.0.0"
      unpack="false"/>
<plugin
      id="org.eclipse.equinox.p2.metadata.repository"
      download-size="0"
      install-size="0"
      version="0.0.0"
      unpack="false"/>
<plugin
      id="org.eclipse.equinox.p2.operations"
      download-size="0"
      install-size="0"
      version="0.0.0"
      unpack="false"/>
<plugin
      id="org.eclipse.equinox.p2.publisher"
      download-size="0"
      install-size="0"
      version="0.0.0"
      unpack="false"/>
<plugin
      id="org.eclipse.equinox.p2.publisher.eclipse"
      download-size="0"
      install-size="0"
      version="0.0.0"
      unpack="false"/>
<plugin
      id="org.eclipse.equinox.p2.ql"
      download-size="0"
      install-size="0"
      version="0.0.0"
      unpack="false"/>
<plugin
      id="org.eclipse.equinox.p2.reconciler.dropins"
      download-size="0"
      install-size="0"
      version="0.0.0"
      unpack="false"/>
<plugin
      id="org.eclipse.equinox.p2.repository"
      download-size="0"
      install-size="0"
      version="0.0.0"
      unpack="false"/>
<plugin
      id="org.eclipse.equinox.p2.repository.tools"
      download-size="0"
      install-size="0"
      version="0.0.0"
      unpack="false"/>
<plugin
      id="org.eclipse.equinox.p2.touchpoint.eclipse"
      download-size="0"
      install-size="0"
      version="0.0.0"
      unpack="false"/>
<plugin
      id="org.eclipse.equinox.p2.touchpoint.natives"
      download-size="0"
      install-size="0"
      version="0.0.0"
      unpack="false"/>
<plugin
      id="org.eclipse.equinox.p2.transport.ecf"
      download-size="0"
      install-size="0"
      version="0.0.0"
      unpack="false"/>
<plugin
      id="org.eclipse.equinox.p2.ui"
      download-size="0"
      install-size="0"
      version="0.0.0"
      unpack="false"/>
<plugin
      id="org.eclipse.equinox.p2.ui.importexport"
      download-size="0"
      install-size="0"
      version="0.0.0"
      unpack="false"/>
<plugin
      id="org.eclipse.equinox.p2.ui.sdk"
      download-size="0"
      install-size="0"
      version="0.0.0"
      unpack="false"/>
<plugin
      id="org.eclipse.equinox.p2.ui.sdk.scheduler"
      download-size="0"
      install-size="0"
      version="0.0.0"
      unpack="false"/>
<plugin
      id="org.eclipse.equinox.p2.updatechecker"
      download-size="0"
      install-size="0"
      version="0.0.0"
      unpack="false"/>
<plugin
      id="org.eclipse.equinox.p2.updatesite"
      download-size="0"
      install-size="0"
      version="0.0.0"
      unpack="false"/>
 
 
 
...i hope it could help  
 |  
 |  
  | 
 | 
 | 
 | 
 | 
| Re: e4 selfupdate  [message #1731323 is a reply to message #1000290] | 
Wed, 04 May 2016 05:35   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
| 
For completeness: The IProfileregistry can return null if org.eclipse.equinox.ds is not activated. You can easily overlook this, because a provisioning agent is returned from the service registry.
 |  
 |  
  | 
Powered by 
FUDForum. Page generated in 0.08451 seconds