3

Before p2, one could write a custom install handler with a feature that was executed to do any 'custom' task during installation.

I see that with p2 the custom install handler is no longer supported. I keep hearing about 'custom touchpoints' being the replacement for that.

However I cant find any concrete example/documentation for it.

Can anyone tell me how to get the functionality of custom install handlers with the p2 update manager.

Edit: A description of what I want to do -

I need to edit the eclipse.ini file and set the -Xmx property to a value based on whether we are running inside a 64 bit or 32 bit env.

Edit 2: I tried creating a p2.inf file in my feature with the following line -

instructions.install = \
addJvmArg(jvmArg:-Xmx900m);

instructions.install.import= \
org.eclipse.equinox.p2.touchpoint.eclipse.addJvmArg,

and it works, however it does not differentiate between 32 and 64 bit.

ThinkingStiff
  • 64,767
  • 30
  • 146
  • 239
pdeva
  • 43,605
  • 46
  • 133
  • 171

3 Answers3

4

p2.inf definitely is the right place to perform customized actions. It is a good place to add vm arguments into .ini. You could put a p2.inf under your feature/plug-in.

Updated on 20 Dec.:

I tried it on my own environment, it works well to set different vm args when installing the same feature on linux 32bit and 64bit. You could download the example code to play with it.

#create a requirement on the IU fragment we are creating
requires.2.namespace=org.eclipse.equinox.p2.iu
requires.2.name=configure.com.example.yourfeature.linux.x86
requires.2.range=[1.0.0,1.0.0]
requires.2.greedy=true
requires.2.filter=(&(osgi.os=linux)(osgi.arch=x86))

#create a IU frament named configure.com.example.yourfeature.linux.x86 for linux 32 bit
units.0.id=configure.com.example.yourfeature.linux.x86
units.0.version=1.0.0
units.0.filter=(&(osgi.os=linux)(osgi.arch=x86))
units.0.provides.1.namespace=org.eclipse.equinox.p2.iu
units.0.provides.1.name=configure.com.example.yourfeature.linux.x86
units.0.provides.1.version=1.0.0
units.0.instructions.configure=addJvmArg(jvmArg:-Xmx500m);
units.0.instructions.configure.import=org.eclipse.equinox.p2.touchpoint.eclipse.addJvmArg,

#create a requirement on the IU fragment we are creating
requires.3.namespace=org.eclipse.equinox.p2.iu
requires.3.name=configure.com.example.yourfeature.linux.x86_64
requires.3.range=[1.0.0,1.0.0]
requires.3.greedy=true
requires.3.filter=(&(osgi.os=linux)(osgi.arch=x86_64))

#create a IU frament named configure.com.example.yourfeature.linux.x86_64 for linux 64 bit
units.1.id=configure.com.example.yourfeature.linux.x86_64
units.1.version=1.0.0
units.1.filter=(&(osgi.os=linux)(osgi.arch=x86_64))
units.1.provides.1.namespace=org.eclipse.equinox.p2.iu
units.1.provides.1.name=configure.com.example.yourfeature.linux.x86_64
units.1.provides.1.version=1.0.0
units.1.instructions.configure=org.eclipse.equinox.p2.touchpoint.eclipse.addJvmArg(jvmArg:-Xmx900m);
Kane
  • 8,035
  • 7
  • 46
  • 75
  • doesnt seem to work :( i even removed the units.o.filter line. Also if I am correct for the line : units.0.hostRequirements.1.name=com.example.yourfeature the feature name had to replaced with the actual id of my feature. – pdeva Dec 15 '10 at 10:28
  • is there any way to debug this? – pdeva Dec 15 '10 at 10:29
  • how do you deploy your features? using PDE export or PDE build? You can remote debug both of those way, add breakpoint into org.eclipse.equinox.p2.publisher.eclipse.AdviceFileAdvice class – Kane Dec 16 '10 at 02:46
  • update the example code. You would try to deploy a repository of a sample rcp to have a look at the content.xml for reference. – Kane Dec 16 '10 at 02:55
  • Kane, the updated code also doesnt seem to work. btw, going down this train of thought though, how would this be modified to check for a 32 bit version too so that a lower value for xmx can be set for 32 bit and higher for 64 bit? – pdeva Dec 19 '10 at 17:06
  • As for deploying, right now i am just creating a local update site from within eclipse and installing it using the eclipse installer gui which uses the p2 director i guess – pdeva Dec 19 '10 at 17:07
  • @pdeva, I tried it by myself, and made a small example to demonstrate it. – Kane Dec 20 '10 at 07:34
0

There are two articles that explain how to achieve this:

First one covers a bit more options, second is only about P2 touchpoints.

WARNING: when we added custom touchpoints to our plugin, it started deadlocking (quite often, but not always) at install time (we did not want the risk and removed them). Maybe we did something wrong but this is something to be aware of.

Built-in touchpoints seem to work fine, though.

Neeme Praks
  • 8,956
  • 5
  • 47
  • 47
0

I think the most complete docs on the matter is the Eclipse wiki. You're probably interested in "native touchpoint actions", but it is also possible to implement your own touchpoint action, i.e. a Java class which is invoked as part of the installation process.

EDIT: Customizing Metadata contains some info on what you can put in the p2.inf file. The example given there is:

 instructions.install = \
    ln(targetDir:@artifact,linkTarget:foo/lib.1.so,linkName:lib.so);\
    chmod(targetDir:@artifact,targetFile:lib/lib.so,permissions:755);
 instructions.install.import= \
    org.eclipse.equinox.p2.touchpoint.natives.ln,\
    org.eclipse.equinox.p2.touchpoint.natives.chmod
JesperE
  • 63,317
  • 21
  • 138
  • 197
  • I think I need the custom touchpoint action, ie invoke my own Java class. However I dont see any info for it in the wiki page. – pdeva Dec 13 '10 at 18:55
  • https://eclipsesource.com/blogs/2013/05/23/custom-touchpoints-in-p2/ here is the link for custom touchpoint tutorial. – ilke Muhtaroglu Oct 05 '18 at 09:01