[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [p2-dev] Can I change the location to extract features during provisioning using P2 Provisioning Agent?

Hi Devs,

I'm still having trouble overriding org.eclipse.equinox.p2.cache property of the running profile during runtime.

I tried changing the above property value for the currently running profile as below, using profileRegistry.setProfileStateProperty() method.

             IProfile profile = "">
       long timeStamp = profile.getTimestamp();
       IStatus status = profileRegistry.setProfileStateProperty(IProfileRegistry.SELF, timeStamp, "org.eclipse.equinox.p2.cache",  System.getProperty("carbon.home") + File.separator + "repository" + File.separator + "components");
       System.out.println("setting the p2.cache prop status: " + status.getMessage());

With above change, I see that a new file: state.properties is created in /p2/org.eclipse.equinox.p2.engine/profileRegistry/WSO2CarbonProfile.profile with the changed property value entry for the running profile.timestamp;

With above property change for the running Profile state, I expected the new installing features to be extracted at
but still the features at runtime are extracted to

And profile.getProperty(""org.eclipse.equinox.p2.cache"") still points to :/dileepa/kernel/trunk/distribution/kernel/target/wso2carbon-core-4.1.0-SNAPSHOT/repository/components/WSO2CarbonProfile

Am I doing something wrong here to locate the /features, /plugins directories during runtime?
Is there any way I can specify the bundlePool (features, plugin directories) at runtime so that my installing features can correctly find the the relative path to files to be copied during installation (


On Sat, Feb 23, 2013 at 12:46 AM, Dileepa Jayakody <dileepa@xxxxxxxx> wrote:
Hi Mikhail and all,

Thanks a lot for the detailed explanation. Appreciate it very much :),  Pascal's presentation@slideshare was also very helpful for me to understand p2 concepts.

My requirement is to share the same /features, /plugins created during build-time using p2-director, for feature-installations at runtime.
When I looked at my profile in p2/org.eclipse.equinox.p2.engine/profileRegistry/WSO2CarbonProfile.profile I can see below properties;

<profile id='WSO2CarbonProfile' timestamp='1361556570247'>
  <properties size='5'>
    <property name='org.eclipse.equinox.p2.installFolder' value='/dileepa/kernel/trunk/distribution/kernel/target/WSO2Carbon/WSO2CarbonProfile'/>
    <property name='org.eclipse.equinox.p2.cache' value='/dileepa/kernel/trunk/distribution/kernel/target/WSO2Carbon'/>
    <property name='org.eclipse.update.install.features' value='true'/>
    <property name='org.eclipse.equinox.p2.roaming' value='true'/>
    <property name='org.eclipse.equinox.p2.environments' value='osgi.nl=en_GB,osgi.ws=gtk,osgi.arch=x86,osgi.os=linux'/>

As you can see, the 'org.eclipse.equinox.p2.cache' property is set to the target-root (WSO2Carbon); and this is where both /features, /plugins directories are created as we give -bundlepool ${basedir}/target/WSO2Carbon in director.

The issue I'm facing is during runtime when performing a provisioning action the /features, /plugins are not extracted to above location; instead they are extracted inside the running-Profile's root directory, and I see during runtime p2.cache location is initialized as below;
org.eclipse.equinox.p2.cache : /dileepa/kernel/trunk/distribution/kernel/target/wso2carbon-core-4.1.0-SNAPSHOT/repository/components/WSO2CarbonProfile

(Please note that in the build-phase after the features are installed using p2-director we manually copy the generated p2 stuff under a new target folder :/wso2carbon-core-4.1.0-SNAPSHOT/repository/components. So /target/WSO2Carbon corresponds to target/wso2carbon-core-4.1.0-SNAPSHOT/repository/components directory in the final target)

According to the original property set in the Profile, org.eclipse.equinox.p2.cache should have being initialized with : /dileepa/kernel/trunk/distribution/kernel/target/wso2carbon-core-4.1.0-SNAPSHOT/repository/components

But it points to the running Profile's root directory (
/dileepa/kernel/trunk/distribution/kernel/target/wso2carbon-core-4.1.0-SNAPSHOT/repository/components/WSO2CarbonProfile) and my features with p2-instructions to copy files are not installed correctly giving IOExceptions as it can't find the source file using the given file-path ${installFolder}/features/${feature.id}_${version}/myFile.txt.

Below are the total list of properties initialized in the running Profile during runtime;
Using P2-director we only specify -profileProperties org.eclipse.update.install.features=true, all others props below are intialized by P2 implicitly.

org.eclipse.equinox.p2.installFolder : /dileepa/kernel/trunk/distribution/kernel/target/wso2carbon-core-4.1.0-SNAPSHOT/repository/components/WSO2CarbonProfile
org.eclipse.equinox.p2.cache : /dileepa/kernel/trunk/distribution/kernel/target/wso2carbon-core-4.1.0-SNAPSHOT/repository/components/WSO2CarbonProfile
org.eclipse.update.install.features : true
org.eclipse.equinox.p2.roaming : false
org.eclipse.equinox.p2.environments : osgi.nl=en_GB,osgi.ws=gtk,osgi.arch=x86,osgi.os=linux
eclipse.touchpoint.launcherName : null
org.eclipse.equinox.p2.surrogate : true
org.eclipse.equinox.p2.shared.timestamp : 1361556595118
org.eclipse.equinox.p2.cache.shared : /dileepa/kernel/trunk/distribution/kernel/target/wso2carbon-core-4.1.0-SNAPSHOT/repository/components/WSO2CarbonProfile
org.eclipse.equinox.p2.configurationFolder : /dileepa/kernel/trunk/distribution/kernel/target/wso2carbon-core-4.1.0-SNAPSHOT/repository/components/WSO2CarbonProfile/configuration
org.eclipse.equinox.p2.launcherConfiguration : /dileepa/kernel/trunk/distribution/kernel/target/wso2carbon-core-4.1.0-SNAPSHOT/repository/components/WSO2CarbonProfile/configuration/eclipse.ini.ignored

Is there a way I can override org.eclipse.equinox.p2.cache property of the running profile to point to the correct location?
Does anyone have an idea on how above property defined in the Profile has initialzed with a different value during runtime?
At startup we define osgi.install.area, osgi.configuration.area and eclipse.p2.data.area as per the running Profile. Does these osgi-runtime properties have an effect on changing P2 properties at runtime?


On Fri, Feb 22, 2013 at 5:20 PM, Mikhail Kalkov <mikhail.kalkov@xxxxxxxxxxxxxx> wrote:
Hi Dileepa,

I've found your question interesting and decided to check the p2 source. I'm quite sure you're familiar with p2 terminology but in case something is unclear, you can check Pascal's "Understanding and extending p2 for fun and profit" presentation at Slideshare.net

If you run p2 Director in order to create a new installation, you can give it -destination and -bundlepool arguments. According to org.eclipse.equinox.internal.p2.director.app.DirectorApplication#initializeProfile method (see [1]), destination is used to initialize the org.eclipse.equinox.p2.installFolder and org.eclipse.equinox.p2.cache properties. Furthermore, if a -bundlepool argument is provided, it is used instead to initialize the org.eclipse.equinox.p2.cache property. From my experience, -destination argument and therefore p2.installFolder decide where the p2/ directory will go, whereas -bundlepool and p2.cache decide where features/ and plugins/ will reside. However, I was unable to find references to "features/" or "plugins/" in the source code.

So, I decided to check p2 profile contents and opened p2/org.eclipse.equinox.p2.engine/profileRegistry/SDKProfile.profile/1353405221611.profile.gz. It turned out that some of the first lines are indeed as follows:
    <property name='org.eclipse.equinox.p2.installFolder' value='C:\Users\Mikhail\Applications\eclipse-SDK-4.2.1-win32'/>
    <property name='org.eclipse.equinox.p2.cache' value='C:\Users\Mikhail\Applications\eclipse-SDK-4.2.1-win32'/>
So, I changed directory to the one pointed out in p2.cache property, and discovered the artifacts.xml file. When I opened this file, I found out the following lines in it:
    <rule filter='(&amp; (classifier=osgi.bundle))' output='${repoUrl}/plugins/${id}_${version}.jar'/>
    <rule filter='(&amp; (classifier=binary))' output='${repoUrl}/binary/${id}_${version}'/>
    <rule filter='(&amp; (classifier=org.eclipse.update.feature))' output='${repoUrl}/features/${id}_${version}.jar'/>

To sum up, it seems that p2.installFolder property is used to decide the location of p2/ directory, whereas p2.cache property is used to decide the location of features/ and plugins/. From p2 Director documentation (see [2])  and source code [1] it follows that you can even share bundle pools between several eclipse installations, although I have never tried this.

By the way, concerning you question about config.ini, I've noticed that if you perform a new installation and don't give director -roaming argument, it will put an absolute path in config.ini, whereas with -roaming argument it will use a path relative to OSGi configuration area location. I think, the value in config.ini is used to find a path to p2 profile, which is later used to find a path to p2 bundlepool. So, if you change this path in config.ini, you might be unable to locate p2/ folder. I think what you need is to make sure that the p2.cache property is correctly initialized in your p2 profile.

[1] http://grepcode.com/file/repository.grepcode.com/java/eclipse.org/4.2/org.eclipse.equinox.p2.director/app/1.0.300/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java#DirectorApplication.initializeProfile%28%29
[2] http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Fguide%2Fp2_director.html

Kind regards,
Mikhail Kalkov

Purple Scout AB
Software Developer

Address: Kyrkogatan 20-22, SE-41110 Gothenburg, Sweden
Phone:   +46 (0) 732 - 051405
E-mail:  mikhail.kalkov@xxxxxxxxxxxxxx
Web:     www.purplescout.se

From: "Dileepa Jayakody" <dileepa@xxxxxxxx>
To: "P2 developer discussions" <p2-dev@xxxxxxxxxxx>
Sent: Friday, February 22, 2013 8:57:28 AM
Subject: Re: [p2-dev] Can I change the location to extract features during provisioning using P2 Provisioning Agent?

Hi All,

Does P2 create /features, /plugins directories relative to org.eclipse.equinox.p2.installFolder location during provisioning?
If so can I override this location at runtime?
Can I do this by defining the org.eclipse.equinox.p2.installFolder=@xxxxxxxxxx/../../ in config.ini?

Really appreciate if someone can shed some light on how p2 decides the location to create /features, /plugins directories during provisioning.


On Fri, Feb 22, 2013 at 3:27 AM, Dileepa Jayakody <dileepa@xxxxxxxx> wrote:
Hi All,

How does p2 calculate the location to extract features during provisioning? Is it relative to the osgi.install.area?
The issue I'm facing is, some of the features to install have file-copy instructions in it's p2.infs, and the source files are copied from the features extracted to target directories.
The target distribution contains multiple profiles and their configuration areas defined separately, in below format.

|-p2 {shared p2}

|    |-configuration
|       /config.ini
|       /org.eclipse.equinox.simpleconfigurator/bundles.info
|    |-configuration
|       /config.ini
|       /org.eclipse.equinox.simpleconfigurator/bundles.info
During build phase when we install features via p2-director giving -destination as target/${Profile}.
Then the installing features are extracted to target/features and the relative path to the extracted feature will be ${installFolder}/../features; this works fine using p2-director, and necessary files get copied during build phase.
But during runtime when we do a feature installation using P2-provisioning agent, the features are extracted in target/${Profile}/features and the relative path to source file (${installFolder}/../features) in above file-copy instruction gets invalid.

Is it possible to configure the place to extract features at runtime? Can I explicitly specify the location to extract features to ProvisioningAgent?
Any help for this is really appreciated as I'm kind of stuck here.


Dileepa Jayakody,
Software Engineer, WSO2 Inc.
Lean . Enterprise . Middleware

Mobile : +94777-857616

p2-dev mailing list

p2-dev mailing list

Dileepa Jayakody,
Software Engineer, WSO2 Inc.
Lean . Enterprise . Middleware

Mobile : +94777-857616

Dileepa Jayakody,
Software Engineer, WSO2 Inc.
Lean . Enterprise . Middleware

Mobile : +94777-857616