Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » e4 selfupdate
e4 selfupdate [message #898684] Fri, 27 July 2012 08:14 Go to next message
dimitri s is currently offline dimitri sFriend
Messages: 2
Registered: July 2012
Junior Member
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 #1000290 is a reply to message #898684] Mon, 14 January 2013 12:59 Go to previous messageGo to next message
Christoph Keimel is currently offline Christoph KeimelFriend
Messages: 482
Registered: December 2010
Location: Germany
Senior Member
Hi Dimitri

did you get the Update working with e4? I am currently trying to do the same thing and I am also struggling with p2.

My current problem is, that I have no Profile in the registry. Actualy agent.getService(IProfileRegistry.SERVICE_NAME) returns NULL. Can you tell me which plugin I have to start, so that the IProfileRegistry is registered as a service? (equinox.ds is running).

Greetings
Christoph
Re: e4 selfupdate [message #1000367 is a reply to message #1000290] Mon, 14 January 2013 15:54 Go to previous messageGo to next message
dimitri s is currently offline dimitri sFriend
Messages: 2
Registered: July 2012
Junior Member
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 #1000741 is a reply to message #1000367] Tue, 15 January 2013 11:11 Go to previous messageGo to next message
Christoph Keimel is currently offline Christoph KeimelFriend
Messages: 482
Registered: December 2010
Location: Germany
Senior Member
Hi Dimitri

thanks for sharing!

I am using the same code from the p2 prestartupdate example P2Util class. I also tried adding all the bundles you are using (except for the *.p2.ui.* stuff since I am in a pure E4 environment and I can't pull in the compatibility layer).

It's still not working Sad. I can init and query the repos just fine. The problem seems to be, that there is no SELF profile. By this I mean that profileRegistry.getProfile(IProfileRegistry.SELF) returns NULL. In the end this results in an NPE in P2Util.checkForUpdates because the UpdateOperation does not return a ProvisioningJob.

So if it is working for you, the cause could either be the missing ui plugins or the used versions.
Im am using Juno SR1 with p2 version 2.2.0.

Thanks again for your input. I will continue searching and will post my findings ...

Greetings
Christoph
Re: e4 selfupdate [message #1004539 is a reply to message #898684] Wed, 23 January 2013 12:28 Go to previous messageGo to next message
Laura V is currently offline Laura VFriend
Messages: 32
Registered: March 2012
Member
How does your run configuration look like?
In "Configuration" tab, did you check the checkbox "Support software installation in the launched application"?
This solved the problem for me.
Re: e4 selfupdate [message #1004563 is a reply to message #1004539] Wed, 23 January 2013 13:10 Go to previous messageGo to next message
Christoph Keimel is currently offline Christoph KeimelFriend
Messages: 482
Registered: December 2010
Location: Germany
Senior Member
Hi Laura

thanks for the Tip Smile.

Smile
Christoph
Re: e4 selfupdate [message #1043891 is a reply to message #898684] Thu, 18 April 2013 08:30 Go to previous messageGo to next message
Patrick Moore is currently offline Patrick MooreFriend
Messages: 1
Registered: April 2013
Location: Falls Church
Junior Member

Thanks for your helpful information ......
Re: e4 selfupdate [message #1731323 is a reply to message #1000290] Wed, 04 May 2016 09:35 Go to previous message
Kees Pieters is currently offline Kees PietersFriend
Messages: 10
Registered: October 2015
Junior Member
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.
Previous Topic:Server shutdown: Kill only terminates Equinox launcher, not spawned JVM processes
Next Topic:Any plans to support DS 1.3 in Equinox
Goto Forum:
  


Current Time: Tue Apr 16 20:19:12 GMT 2024

Powered by FUDForum. Page generated in 1.49846 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top