Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » How do I update an application without losing customizations in config.ini?
How do I update an application without losing customizations in config.ini? [message #929541] Mon, 01 October 2012 14:52 Go to next message
Erik Emanuelsson is currently offline Erik EmanuelssonFriend
Messages: 4
Registered: October 2012
Junior Member
We have an RCP app based on Eclipse 3.7 to which we recently added p2-support. It all works fine and we can update the application and install new/update customizations to it just fine via the mechanisms provided by the p2 framework.

With some extra customizations to the base mechanisms which lets us control update sites + perform install and update operations during application start we have also added optional automatic installation of new features and update of existing features to help our enterprise customers keep their applications up to date. This should allow them to only pack a pure application + some custom settings files once (create a centralized installation package they can push out to users and this is an expensive and time consuming process for them) and then let the update functionality in the application update it to the latest version and install the latest versions of all their customizations automatically.

This all works pretty well apart from one thing. One of our enterprise customers want to use another value for "osgi.instance.area" than the one we ship in our default build. We have this set to a subfolder in "@user.home", but on their clients (Windows XP and Windows 7) this is mapped to a directory that the users have limited quota on so they want it moved to somewhere else.
It is not a problem for them to have the existing config.ini file replaced with a custom one in the version that they pack initially, but when the application is updated it gets overwritten with the default file and hence the value of "osgi.instance.area" is no longer their custom value.

One idea for solving this that I have been pursuing is to generate a new version of a customer specific feature each time we release a new version of our application. The customer could then update both the application and the customization feature at the same time and get their custom value set that way.

I have tried to implement this customization in the form of a simple feature with basically just a "p2.inf" file that replaces the value in "config.ini" with a custom value using the touchpoint "setProgramProperty" like this
instructions.configure=\
org.eclipse.equinox.p2.touchpoint.eclipse.setProgramProperty(propName:osgi.instance.area,propValue:C\:/custompath/instancearea);

This works fine if the customization feature is installed/updated _after_ the application has been updated. If it is installed/updated at the same time as the application itself it has no effect and if we let the application start up with the default value, the standard location is used and we get data written in the directory they do not want to pollute.

I have also tried to use the touchpoint addProgramArg to try to set the "osgi.instance.area" as a program argument instead like this
instructions.configure=\
org.eclipse.equinox.p2.touchpoint.eclipse.addProgramArg(programArg:-data C\:/custompath/instancearea);

instructions.unconfigure=\
org.eclipse.equinox.p2.touchpoint.eclipse.removeProgramArg(programArg:-data C\:/custompath/instancearea);

but even though the argument gets placed into the "myapp.ini"-file, the instance area that is set as a program argument has a lower priority than the one found in the "config.ini"-file and only becomes active if I remove the property from "config.ini".

Does anyone have any tips on how to get a customized "osgi.instance.area" set so it is set and available during the first start of an application after it has been updated?

It is very likely that I do not know enough about p2 and that this limits me in how I approach this problem so any help from you more hardcore p2 users is welcome.
Re: How do I update an application without losing customizations in config.ini? [message #929581 is a reply to message #929541] Mon, 01 October 2012 15:27 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Your small feature with the p2.inf is the option I would have tried as well.

What if you add a dependency from the feature to your product IU (with a wide version range)?

PW


Re: How do I update an application without losing customizations in config.ini? [message #929694 is a reply to message #929581] Mon, 01 October 2012 17:15 Go to previous messageGo to next message
Erik Emanuelsson is currently offline Erik EmanuelssonFriend
Messages: 4
Registered: October 2012
Junior Member
I have made some experiments with dependency requirements from the custom feature to our product feature

First I started with a base state
- application v1.0.0.qualifier (simulated to have settings set as if packed)

Experiment 1:
Enabled update sites contain 
* application v1.0.1.qualifier
* custom_configini v1.0.1 (which requires application feature v1.0.0 or greater)
During the startup, the application is updated and the custom_configini feature is installed. Then the application is restarted.
Result:
Installed software
* application v1.0.1.qualifier
* custom_configini v1.0.1.qualifier
Configuration:
* osgi.instance.area=file:/C:/Users/<myusername>/instancearea
Basically the customization had no effect. In this case I know that the customization feature is installed before the application is updated as we perform our InstallOperation before we call the UpdateOperation. This could affect things I guess.


Experiment 2:
Enabled update sites contain 
* application v1.0.1.qualifier
* custom_configini v1.0.1 (which requires application feature v1.0.1 or greater)
During the startup, the application is updated but the custom_configini feature is not installed. Then the application is restarted.
Result:
Installed software
* application v1.0.1.qualifier
Configuration:
* osgi.instance.area=file:/C:/Users/<myusername>/instancearea
The customization was not installed as its requirements were not fulfilled by the application at the time it was first started. We also have a mechanism in place that lets us avoid update and install checks during startup if the application was just updated by our startup checks last time so the now installable customization will be installed next startup. (if it works as we want the application + customizations should be up to date if application restarted due to updates).


I will do some experiments tomorrow and see if I can get it to work as I want if I force the application to be updated first and then update/install other stuff. Hopefully it is just an order problem.
Re: How do I update an application without losing customizations in config.ini? [message #930588 is a reply to message #929694] Tue, 02 October 2012 13:05 Go to previous message
Erik Emanuelsson is currently offline Erik EmanuelssonFriend
Messages: 4
Registered: October 2012
Junior Member
Today I did some tests where I forced the updates and installs to occur in different orders and as long as I make sure that the application was updated before other features were updated or installed it works fine.

In my code I do not handle feature dependencies at all and I think that is what caused the problem to begin with. Ideally I think I will have to flesh out that part of my code to and make sure that stuff gets installed/updated in the correct order.

Anyway, thanks for your feedback, Paul.
Previous Topic:Any way to force P2 to install new packages?
Next Topic:Subsystem Service Specification in Equinox?
Goto Forum:
  


Current Time: Thu Apr 25 00:30:53 GMT 2024

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

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

Back to the top