126
1 © 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license Using p2 for fun and profit Pascal Rapicault* Ian Bull** Andrew Niefer* Jeff McAffer** * IBM Rational ** EclipseSource

Understanding and extending p2 for fun and profit

Embed Size (px)

DESCRIPTION

In a tutorial style, this detailed presentation covers all the major aspects of p2. It ranges from the simple usage of product delivery to an in-depth presentation of the p2 concepts.

Citation preview

Page 1: Understanding and extending p2 for fun and profit

1© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license

Using p2 for fun and profit

Pascal Rapicault*

Ian Bull**

Andrew Niefer*

Jeff McAffer**

* IBM Rational** EclipseSource

Page 2: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 2

Engineers Users

TestAutomated Builds

Test

source code

open source

licensed software

in-house built

applications

tools

runtimes

Provision what – where

Page 3: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 3

• Packaged applications – source code

• Strict policy control – full flexibility

• Approved repositories – any repository

• Fixed configuration – dynamic configuration

• Fully automatic – user driven – (headless)

• Update to latest – update to policy controlled (downgrade)

Wide range of requirements

Page 4: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 4

• An extensible provisioning platform

• Install and update technology in the SDK since 3.4– New UI, simplified workflow– Manage Eclipse, RCP and more

• exe, ini, bundles, registry keys, native code, …– Shared bundles across Eclipse-based products

• A provisioning solution for OSGi™ systems– Managing non-running instance– Start level, framework extension– Fine-grained dependency management

p2 is about installing!

Page 5: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 5

• Eclipse proves the power of componentization

• Componentization naturally spreads

• More components → more management

• Management is hard

• It’s all about the Contract– Defining– Instantiating– Executing– Maintaining

Trends in Eclipse

Page 6: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 6

How does p2 help?

• Manages the contract– Dependencies– Code– Settings– Integrations– Non-Eclipse parts

• Extensible

• GUI and Headless

• One consistent model

Page 7: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 7

From Install to Service

• Installing and Updating are the same operations

• Installed shape same as zip shape– Flexibility in delivery

• Programmatic API for all operations

p2 offers a continuum from initial installation to serviceability

Page 8: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 8

p2 in wild

• Installer for products (EPP Wizard, WindRiver, Motorola, IBM Rational, etc.)

• Server managed deployment solution and distros (Genuitec, EclipseSource)

• Remote management of device (EclipseSource)

• Dynamic builder – Buckminster (Cloudsmith)

• Provisioning of server side (EclipseSource)

• Cloud provisioning (EclipseSource)

Page 9: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 9

Outline

p2 by example• Integrating p2 in a feature based RCP application• p2 concepts and architecture• Layout of our application on disk and additional p2 concepts• Creating and delivering an update• Creating and delivering an extension

• Automated build and repo management• Repo management• Metadata publication (source and product)• Categorizing content

Deeper in p2• Additional p2 constructs• From plug-ins and feaures to metadata• Plug-ins map• Reusing and tweaking the UI• Advanced concepts

Page 10: Understanding and extending p2 for fun and profit

10© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license

p2 by exampleIntegrating p2 in a feature based RCP applicationp2 concepts and architectureLayout of our application on disk and additional p2 conceptsCreating and delivering an updateCreating and delivering an extension

Build and repo management

Deeper in p2

Page 11: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 11

What is RCP?

• Rich Client Platform

• The minimal set of plug-ins needed to build a Rich Client Application

• Clients are free to use other plug-ins– Help– p2– GEF / Draw2D– Birt– …

Integrate p2 in an RCP Application• Publish the application to a repository• Install the application using p2• Update an existing install

• Add new functionality to the RCP application 

Page 12: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 12

What is a Product?

• An application-specific branding on top of a configuration of Eclipse plug-ins– Application icon– Splash screen– Help -> About information– Platform specific launcher

Page 13: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 13

Integrate p2 in an RCP Application• Publish the application to a repository• Install the application using p2• Update an existing install

• Add new functionality to the RCP application 

In the following example we are using a feature based product. However plug-in based product is supported Create a Bundle for your mail application

Every bundle needs a name and version with a qualifier

Let's call ours: org.example.mail

Creating a feature based product

Page 14: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 14

Integrate p2 in an RCP Application• Publish the application to a repository• Install the application using p2• Update an existing install

• Add new functionality to the RCP application 

Every bundle needs a name and version with a qualifier

Of course we want a Rich Client Application

Creating a feature based product

Page 15: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 15

PDE contains all sorts of examples, templates and documentation

Creating a feature based product

Page 16: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 16

Features have a name and version too

Let's create a Feature

Creating a feature for our plug-in

Page 17: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 17

In order to keep things separated in the application, we create a feature that contains the p2 plug-ins we need.

For this example, it does not include the support for legacy sites nor drop-ins.

A feature for the p2 parts

Page 18: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 18

Let's create a Product

Let's base ourproduct off features

On the dependencies tab we add the features that constitute the product

Creating the product file

Page 19: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 19

Launching the product (from within eclipse)

Page 20: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 20

In self-hosting mode, the application being launched is not p2-enabled, as such the p2 dialogs can not be brought up. We can only update if we have a profile.This problem will unlikely be addressed in 3.5.

The running product

Page 21: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 21

Publishing the application to a repository

Page 22: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 22

The result of the export

The export produced the application in a runnable form and also repositories. The application in a runnable form is *not* p2-enabled and will fail to open the p2 dialogs. This should be fixed for 3.5. Notice the file extensions on the artifacts and content file! What's in these JAR files? p2 repositories.

Page 23: Understanding and extending p2 for fun and profit

23© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license

p2 by exampleIntegrating p2 in a feature based RCP applicationp2 concepts and architectureLayout of our application on disk and additional p2 conceptsCreating and delivering an updateCreating and delivering an extension

Build and repo management

Deeper in p2

Page 24: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 24

One construct to rule them all

Decouple decision making from the actual content

Everything is an IUEverything is installable

It is also referred to as “metadata”

IU(id, ver)

Page 25: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 25

Anatomy of an IU

Provided

CapabilitiesRequired

Capabilities

Properties

Artifact reference

Actions

IU(id, ver)

Class: IInstallableUnit

Page 26: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 26

Anatomy of an IU, more

• Update description– This allows to control of which IU and IU is an update of

• Applicability filter– This allows for an IU to express when it is only applicable to a

particular environment.

Page 27: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 27

Anatomy of an IU, requirements / capabilities

• Capabilities and requirements are the mechanism by which an IU express what it provides and what needs.

• A capability is composed of a:– Namespace (string), name (string) and version

• A requirement is composed of a:– Namespace, name and version range

• Namespace, name and version are open ended.

• The requirements and capabilities expressed by IUs can be arbitrary and don’t have to all be in the same namespace.– Resources – RPMs, .exes, docs, …– Virtual – if you can define a capability, I can depend on it

Page 28: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 28

Separation of concerns

• Installable Unit– Exists independently of the repository

• Metadata Repository– Store only Installable Units

• Artifact Repository– Store only Artifacts

Metadata Artifacts

Page 29: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 29

Artifacts

• Bytes/content to be installed

• Any form– JARs (e.g., bundles, features, …)– Binary executables– RPM, MSI, …

• Defined, maintained, loaded and used separately from the metadata

Page 30: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 30

Repositories

p2 does not force a serialization format for repositories

• Defined as an interface, IRepository

• All repositories have– Identity– Version– Description

• Repos can be queried– Allows for delayed loading– Captures standard questions

Page 31: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 31

Metadata Repository

• Defined as an interface, IMetadataRepository

• Add/remove installable units

• Add references to other repos

• Created by factories

• Looked up in an IMetadataRepositoryManager service

Page 32: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 32

Built-in metadata repositories

• URL and Local based– Simple XML format on disk (content.jar / content.xml)– Write (re)writes the entire structure

• Update site repo– site.xml and features are auto-published into local repo– Bundle IUs published as partial IUs and filled in on demand

Page 33: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 33

Artifact Repository

• Defined as an interface, IArtifactRepository

• Add/remove descriptors

• Test content

• Access artifacts by descriptor

• Created by factories

• Looked up in an IArtifactRepositoryManager service

Page 34: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 34

Artifact Repository

• An artifact can be stored in multiple forms

• IArtifactKey, is the artifact identifier independently of its form– A key is made of: Classifier, name, version– The key is what an installable unit refers to

• IArtifactDescriptor identifies actual content in a particular form– Location of actual artifact (can be independent of repository

location)– Processing steps necessary to recreate the artifact in the

expected form (e.g. unpack for pack200’ed jars)– Download size, on-disk size, MD5, etc..

Page 35: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 35

Id + version == unique content

• For artifacts and IUs:– Id + version == unique content

• Failing this could result in problems: [1]– Your user does not run the content it should– MD5 or signature verification error at install time

• PDE and p2 help avoid these problems with comparison tools

[1] Andrew’s short talk.

Page 36: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 36

Built-in artifact repositories

• SimpleArtifactRepository– Simple XML format on disk (artifacts.jar / artifacts.xml)– Write (re)writes the entire structure

Page 37: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 37

p2 Architecture

Metadata Artifacts

Runtimes

Profiles

OS

Eclipse

Engine

Eclipse

Classic

Eclipse

for C++

Other

Director Repositories

Touchpoints

Page 38: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 38

The Director Application

A command line app to perform

basic provisioning operations (install / uninstall)

• The director is capable of provisioning a complete installation from scratch or simply extending your application

• Can provision into self or another application

http://wiki.eclipse.org/Equinox_p2_director_application

Page 39: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 39

Running the director

./eclipse

-console -consolelog

-application org.eclipse.equinox.p2.director.app.application

-metadataRepository file:c:/mail/repository

-artifactRepository file:c:/mail/repository

-installIU com.example.mail.product

-destination c:/mail/tmp/ -profile MailProfile

-vmargs -Declipse.p2.data.area=c:/mail/tmp/eclipse/p2

Page 40: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 40

p2 in Action

TransportsHttp/Https

File systemVolume

Repositoriesp2

Update Site

Engine

Eclipse/OSGiNative/OS

Director

ProfilesRuntimes

Provisioning operation requested

Metadata fetched and constraints

analyzed

IU install, uninstall, update

operations

Artifact availability and mirroring

Mirroring

Data transfer

IUs configured into runtimes

Profile updated

Page 41: Understanding and extending p2 for fun and profit

41© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license

p2 by exampleIntegrating p2 in a feature based RCP applicationp2 concepts and architectureLayout of our application on disk and additional p2 conceptsCreating and delivering an updateCreating and delivering an extension

Build and repo management

Deeper in p2

Page 42: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 42

A p2-enabled application

Because we installed our product, we have a profile and the p2 dialog can come up

Page 43: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 43

What is being run

What's our product all about?

Page 44: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 44

Layout of an installation

Configuration area

p2 data area

Artifact repository index. This allows the plug-ins to be served to other instances.

Page 45: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 45

Configuration data detailed

• Simple configurator provides the OSGi framework the list of bundles to run.

• The information stored in bundles.info is– Location, id, version, start level, started state

Configuration area

Simple configurator data

Page 46: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 46

p2 data area

Download cache, where non-eclipse pieces are mirrored before being installed.

Profile registry

Storage for the profile

Lock file created when the profile is being modified

Current and previous state of the system

MailApp.profile

Page 47: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 47

Profile and profile registry

A profile is the complete description in terms of IU of what is installed

• A profile contains– Properties defining the “environment” such as os, ws, arch, install

location, bundle pool location– The list of IUs– Properties associated with each IUs

• Profiles are held by a profile registry• A profile registry can hold on to several profiles

Class: *.p2.engine.IProfile, IProfileRegistry

Page 48: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 48

Management modes and profile registry

• External mode– The p2 plug-ins are external to the application (e.g an installer)

• Co-hosted mode– The p2 plug-ins are in your application (e.g. the Eclipse SDK).

This mode still allows the application to be externally managed.

• For each case, the profile registry (in fact the p2 data area) can be hosted either in the application being managed or in the managing application.

Page 49: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 49

Changing a profile

• A profile is usually created during the initial installation

• It is changed by provisioning operations performed using:

– The director application

– The API

– The UI

– …

Page 50: Understanding and extending p2 for fun and profit

50© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license

p2 by exampleIntegrating p2 in a feature based RCP applicationp2 concepts and architectureLayout of our application on disk and additional p2 conceptsCreating and delivering an updateCreating and delivering an extension

Build and repo management

Deeper in p2

Page 51: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 51

Creating an update

Let's make a small change to our product and update the version

Page 52: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 52

Version Numbers

• p2 relies heavily on version numbers

• major.minor.service.qualifier

• Semantics of segment changes

– Major – Breaking API changes

– Minor – New API

– Service – Bug fixes and minor enhancements

– Qualifier – Build id, source control tag• Qualifier is a string

– Typically source control tag

• IU versions should be monotonically increasing

Page 53: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 53

Installing the update

Page 54: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 54

Installing the update

Note that p2 support dynamic addition or removal of bundles. In this case it is the application that is not dynamic.

Page 55: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 55

After the update and restart

Page 56: Understanding and extending p2 for fun and profit

56© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license

p2 by exampleIntegrating p2 in a feature based RCP applicationp2 concepts and architectureLayout of our application on disk and additional p2 conceptsCreating and delivering an updateCreating and delivering an extension

Build and repo management

Deeper in p2

Page 57: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 57

Creating a new plug-in to install

Don’t forget to specify .qualifier.

Page 58: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 58

Create a feature to deliver our plug-ins

By default p2 UI is not configured to show plug-ins in “Install new software view”. You need to use a feature.

Page 59: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 59

Exporting the feature

How do you create a repository for your exported bundles / features?

You set the option to that effect in the “options” tab.

Page 60: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 60

The publisher

• The publisher is responsible for creating (publishing) repositories from different types of sources

• Bundles and Features Publisher

• UpdateSite Publisher

• Product Publisher

• Category Publisher

Page 61: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 61

Features and Bundles Publisher

./eclipse

-console -consolelog

-application org.eclipse.equinox.p2.publisher.FeaturesAndBundlesPublisher

-metadataRepository file:c:/mail/repository

-artifactRepository file:c:/mail/repository

-source c:/staging

-append

-publishArtifacts

This will generate metadata for the plug-ins and features found in source.Note that PDE has an option to do it automatically.

Page 62: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 62

Installing the newly created extension

Page 63: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 63

Page 64: Understanding and extending p2 for fun and profit

64© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license

p2 by example

Build and repo managementRepo managementMetadata publication (source and product)Categorizing content

Deeper in p2

Page 65: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license

Example: Building with p2

• Import Existing Projects into Workspace

– Select the org.eclipse.pde.build.examples.rcp.cloud.releng.zip archive

– Choose the org.eclipse.pde.build.examples.rcp.cloud.releng project.

• Import Plugins and Fragments

– Import org.eclipse.pde.build as a binary project

• Running the Example

– Run buildProduct.xml as Ant Build using the same JRE as the workspace

Page 66: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license

Slicing repositories

• The p2.mirror task can easily slice repositories into subset based on given Ius.

• The example requires p2 bundles, as a demonstration we create a new repository containing the contents of the org.eclipse.equinox.p2.user.ui feature, along with a few other bundles.

• Specify IUs to mirror into new location• Set Slicing Options to include the desired dependencies:

– includeOptional : whether to include optional dependencies– followStrict: only follow strict dependencies (eq: [1.0.0.v2009, 1.0.0.v2009]– platformFilter: only mirror Ius matching the given platform filter– includeNonGreedy: mirror non-greedy dependencies

<p2.mirror source="${Eclipse.Repo-3.5M6}" destination="${p2Repo}"> <slicingOptions followStrict="true" /> <iu id="org.eclipse.equinox.p2.user.ui.feature.group" /> <iu id="org.eclipse.ecf"/> <iu id="org.eclipse.ecf.filetransfer"/> .... <iu id="org.apache.ant"/> <iu id="org.eclipse.core.runtime.compatibility.registry"/></p2.mirror>

• The <iu> elements also support a “version” attribute, if this attribute is not specified, the highest version found is mirrored.

[org.eclipse.pde.build.examples.rcp.cloud.releng/buildProduct.xml createP2Repo]

Page 67: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license

Transforming repositories

• Some bundles must be transformed into folder shape before we can compile against them.

• p2 provides a task that tranforms bundles into their installed shape. PDE Build has built in support for this using the properties:– repoBaseLocation : a folder on disk containing repositories to transform– transformedRepoLocation: the destination repository

<p2.repo2runnable destination="${transformedRepoLocation}"> <source dir="${repoBaseLocation}/" includes="*"/></p2.repo2runnable>

<source> elementsNested <source> elements are ant filesets that support an extra attribute “location”• The “location” attribute specifies a URL to a repository used for both metadata and

artifacts• If no “location” attribute is specified:

• folders matched by the fileset are loaded as repositories

• Files ending in “.zip” are loaded as zipped repositories

<iu> elementsNested <iu> elements specify specific IUs to transform• If no <iu> elements are specified, the entire repository is transformed

[org.eclipse.pde.build/scripts/genericTargets.xml transformRepos]

Page 68: Understanding and extending p2 for fun and profit

68© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license

p2 by example

Build and repo managementRepo managementMetadata publication (source and product)Categorizing content

Deeper in p2

Page 69: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license

Publishing metadata

• Publishing from Source

• PDE Build extends the publisher and provides an ant tasks to publish to repositories directly from the source for a bundle or feature:

– Source contains more inputs that can be used to generate metadata (build.properties, p2.inf)

– Features can have rootfile IUs and artifacts associated with them– Allows for some performance gains when over 3.4 style metadata generation.

Publishing from Binaries

The publisher provides an ant task to publish metadata from binary jars:

<p2.publish.featuresAndBundles repository="file:C:/dev/repo"> <bundles dir="C:\eclipse\plugins" includes="org.eclipse.equinox.launcher_1.0.200.v20090306-1900.jar" /> <features dir="C:\eclipse\features" includes="org.eclipse.rcp_3.5.0.v20090307-9RA-FqhFstOCxSdfkxdojLKc"/></p2.publish.featuresAndBundles>

Both the <bundles> and <features> nested elements are ant filesets specifying folders and jars to publish.

PDE Build has an equivalent task “eclipse.publish.featuresAndBundles” which does the same but also supports a “site” attribute for category generation.

[org.eclipse.pde.build.examples.rcp.cloud.releng/buildDirectory/assemble.org.eclipse.pde.build.container.feature.win32.win32.x86.xml]

Page 70: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license

Publishing Products

• Branding Artifacts

• PDE Build supports branding artifacts. This will– Download input artifact, generally artifacts from org.eclipse.equinox.executable– Brand the executable and replace icons– Republish the branded artifact using the product id and version

[org.eclipse.pde.build.examples.rcp.cloud.releng\buildDirectory\assemble.org.eclipse.pde.build.container.feature.p2.xml <eclipse.brand.p2.artifacts>]

Publishing the Product

The publisher provides an ant task to publish products using a .product file. Allows publishing of products without running a build, provided all required IUs already exist in

the repository [org.eclipse.pde.build.examples.rcp.cloud.releng\buildDirectory\assemble.org.eclipse.pde.build.container.feature.p2.xml <p2.publisher.product>]

Default Configuration IUs

PDE Build will generate default configuration IUs for :• Setting default start levels

• Including equinox launchers, setting -startup - -launcher.library

[org.eclipse.pde.build.examples.rcp.cloud.releng\buildDirectory\features\org.eclipse.pde.build.container.feature\product\p2.inf]

Page 71: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license

Running the Director

<java jar="${equinoxLauncherJar}" fork="true" failonerror="true"><arg line="-application org.eclipse.equinox.p2.director.app.application" /><arg line="-nosplash" /><arg line="--launcher.suppressErrors" /><arg line="-consoleLog" /><arg line="-flavor ${p2.flavor}" /><arg line="-installIU ${p2.director.iu}" /><arg line="-version ${p2.director.version}" /><arg line="-p2.os ${os}" /><arg line="-p2.ws ${ws}" /><arg line="-p2.arch ${arch}" /><arg line="-roaming" /><arg line="-profile ${p2.director.profile}" /><arg line="${p2.director.extraArgs}" /><arg line="-metadataRepository"/><arg value="${p2.repo}" /><arg line="-artifactRepository"/><arg value="${p2.repo}" /><arg line="-destination"/><arg value="${p2.director.installPath}" /><arg line="-bundlepool"/><arg value="${p2.director.bundlepool}" />

<jvmarg value="-Declipse.p2.data.area=${p2.director.dataArea}" /><jvmarg line="${p2.director.extraVMArgs}" />

</java>

• PDE Build now automatically invokes the director for properly configured product builds.(see org.eclipse.pde.build/scripts/genericTargets.xml/runDirector)

[org.eclipse.pde.build/scripts/genericTargets.xml runDirector]

Page 72: Understanding and extending p2 for fun and profit

72© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license

p2 by example

Build and repo managementRepo managementMetadata publication (source and product)Categorizing content

Deeper in p2

Page 73: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 73

Categorizing repository content

We define categories using site.xml or category.xml

Page 74: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 74

Creating the category

Page 75: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 75

Categorizing our feature

Page 76: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 76

Page 77: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 77

UpdateSite Publisher

./eclipse

-console -consolelog

-application org.eclipse.equinox.p2.updatesite.UpdateSitePublisher

-metadataRepository file:c:/mail/repository

-artifactRepository file:c:/mail/repository

-source C:\staging\updateSite\com.example.mail.updatesite

-append

-publishArtifacts

When using the category.xml, use the org.eclipse.equinox.p2.publisher.CategoryPublisher

Page 78: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 78

Page 79: Understanding and extending p2 for fun and profit

79© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license

p2 by example

Build and repo management

Deeper in p2Additional p2 constructs

From plug-ins and features to metadata

Plug-ins map

Reusing and tweaking the UI

Advanced concepts

Page 80: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 80

Installable Unit Fragments

• An installable unit fragment is an entity that attaches to an installable unit.

• Much like OSGi fragments, IU fragments are used to complement an existing installable unit and appear as one with the IU they attached to.

• They are typically used to deliver configuration information to an installable unit (e.g. start level).

• IU fragments can be attached to several IU at the same time. See for example the tooling.osgi.bundle.default IU that applies to all bundles.

• Note that IU fragments are not how OSGi fragments are delivered. OSGi fragments are delivered as regular IU with requirements on their host.

Class: IInstallableUnitFragment

Page 81: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 81

Installable Unit Patches

• An installable unit patch has the ability to “modify” the requirements of any other installable unit.

• Deal with three concerns:– The IUs to which the patch apply

– The lifecycle of patch

– The changes applied

Note: In 3.5 the feature patch editor only exposes some of those capabilities.

See also http://aniefer.blogspot.com/2009/06/patching-features-with-p2.html

Page 82: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 82

Installable Units

• There is only 3 kinds of IU:– InstallableUnit, InstallableUnitFragment and InstallableUnitPatch

• To ease the discussion we use the following terms:– Group IU: any IU with the group property set to true. It usually results

from the metadata generated for a feature.

– Product IU: an representing the root of a product (e.g. org.eclipse.sdk.ide). It usually results from the metadata generated for a product.

– CU: an IU Fragment carrying configuration information (e.g. start level)

Page 83: Understanding and extending p2 for fun and profit

83© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license

p2 by example

Build and repo management

Deeper in p2Additional p2 constructs

From plug-ins and features to metadata

Plug-ins map

Reusing and tweaking the UI

Advanced concepts

Page 84: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 84

Understanding the metadata generated

• Feature– A feature results in two IUs: one capturing the dependencies to other plug-ins

and features and one IU representing the feature.jar. – Note that ids for the feature being generated are suffixed:

org.eclipse.rcp org.eclipse.rcp.feature.group & org.eclipse.rcp.feature.jar

• OSGi bundle

– One IU provides capabilities for :• each exported package, • indicating that it is a bundle• Indicating its bundle name

<provided namespace='osgi.bundle' name='org.apache.commons.codec' version='1.3.0'/><provided namespace='java.package' name='org.apache.commons.codec' version='1.3.0'/><provided namespace='java.package' name='org.apache.commons.codec.binary' version='1.3.0'/><provided namespace='java.package' name='org.apache.commons.codec.digest' version='1.3.0'/><provided namespace='java.package' name='org.apache.commons.codec.language' version='1.3.0'/><provided namespace='java.package' name='org.apache.commons.codec.net' version='1.3.0'/><provided namespace='org.eclipse.equinox.p2.eclipse.type' name='bundle' version='1.0.0'/>

Page 85: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 85

Understanding the metadata generated

• OSGi fragment– Same as OSGi bundle plus a capability indicating it is a fragment. The

requirement on the host become regular dependencies

• The exe– An IU

• The config.ini and eclipse.ini– Pure metadata. The files are not downloaded they are the result of the

installation.

– Several InstallableUnitFragments (e.g. toolingorg.eclipse.equinox.launcher or toolingorg.eclipse.equinox.simpleconfigurator).

<provided namespace='osgi.fragment' name='org.eclipse.swt' version='3.5.0.v3536b'/><provided namespace='osgi.bundle' name='org.eclipse.swt.win32.win32.x86' version='3.5.0.v3536b'/>

It is important to remember that this is only the metadata generated by the applicationsprovided as part of the publisher, but the metadata is generic and is yours to extend.

Page 86: Understanding and extending p2 for fun and profit

86© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license

p2 by example

Build and repo management

Deeper in p2Additional p2 constructs

From plug-ins and features to metadata

Plug-ins map

Reusing and tweaking the UI

Advanced concepts

Page 87: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 87

Plug-ins map

ECFE

clip

se

touc

hpoi

nt

Nat

ive

touc

hpoi

nt

Too

ling

OSGi

Upd

ate

site

re

posi

tory

engine

Metadata

Director

Repository

UI …

Page 88: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 88

The minimal set of plug-ins required to provision with p2. They define the core p2 concepts.

• core– Provides some basic infrastructure for most plug-ins. It defines Query, Version

and other helpers.

• metadata– Defines the interfaces for the metadata:

IInstallableUnit, IUFragment, IUPatch

• engine– Executes a set of operations against a profile. Engine.perform(…)– Defines the concept of touchpoint and action: ProvisioningAction– Defines profile preference scope– Contains the download manager (should not be here)

• director– Implements the resolution mechanism of p2. Depends on the org.sat4j.*

bundles.

Core plug-ins (1/2)

Page 89: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 89

Core plug-ins (2/2)

• repository– Defines concept of Repository and repository manager. Interfaces with ECF.

• metadata.repository– Defines the metadata repository API and the repository manager.– Implements the simple metadata repository (content.jar / content.xml), composite metadata

repository. – Ant tasks: p2.composite.* to manage composite repos.– Application: org.eclipse.equinox.p2.metadata.repository.mirrorApplication.

• artifact.repository– Same than metadata repository for artifacts. – Implements processing steps for MD5, pack200 and zipVerifier.– Ant tasks: p2.artifact.mirror, p2.composite.artifact.* to manage composite repos [1].– Application: org.eclipse.equinox.p2.artifact.repository.mirrorApplication.

• garbagecollector– Basic garbage collector loop and extension point. – Repository and touchpoint agnostic.

• examplarysetup– The plug-in of shame. Pulling all the pieces together.

[1] - Ant task - http://wiki.eclipse.org/Equinox/p2_Ant_Tasks

Page 90: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 90

Transport related plug-ins

p2 uses ECF because it offers pluggable transport.

• org.eclipse.equinox.p2.repository– Interfacing of p2 with ECF

• org.eclipse.ecf, org.eclipse.ecf.identity,org.eclipse.ecf.ssl– Core ECF bundles

• org.eclipse.ecf.filetransfer– Defines the interface to transfer file with ECF

• org.eclipse.ecf.provider.filetransfer, org.eclipse.ecf.provider.filetransfer.ssl

– Provides the implemtation of the service defined in ecf.filetransfer

• org.eclipse.ecf.provider.filetransfer.httpclient, org.eclipse.ecf.provider.filetransfer.httpclient.ssl

– Interface ECF with org.apache.commons.httpclient

• org.apache.commons.httpclient– The http client from apache (in 3.5 we are using the 3.0.1 implementation)

Page 91: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 91

Eclipse management

• touchpoint.eclipse– Defines the touchpoint and actions necessary to install into eclipse

(setStartLevel, installBundle, etc). See [1]

• fwkadmin– Abstract the eclipse touchpoint from the implementation details of a particular

OSGi framework.

• fwkadmin.equinox– Implementation of the fwkadmin API for the Equinox framework. It knows how to

reason about config.ini and eclipse.ini

• simpleconfigurator.manipulator– Bundles.info writer.

• simpleconfigurator– This bundle is used on startup to tell the OSGi framework what to run. It reads

the bundles.info file located in configuration/org.eclipse.equinox.simpleconfgurator/bundles.info

[1] – Actions defined by eclipse touchpoint - http://wiki.eclipse.org/Equinox/p2/Engine/Touchpoint_Instructions

Page 92: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 92

Native support

• touchpoint.natives– Defines actions such as chmod, link, unzip, etc. [1]

[1] – Actions defined by native touchpoint - http://wiki.eclipse.org/Equinox/p2/Engine/Touchpoint_Instructions

Page 93: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 93

UI plug-ins

Bundles usable in an eclipse-based application.

• ui– Implementation of the install dialog and wizards.

• ui.sdk (bogus name alert)

– Integration of p2 in an application: contribution in the help menu and preference page.

• ui.sdk.scheduler (bogus name alert)

– UI affordance and preference page for the update checker.

• updatechecker– Provides the ability to check for an update. This is not a UI bundle.

Page 94: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 94

Repositories implementation

p2 allows for alternate repository implementation. Here are few additional ones that are provided.

• extensionlocation– Support to recognize as a repository folders containing the sub folders plugins/

and features

• directorywatcher– Support plug-in for the extension location repository. Monitors the content of the

plug-ins folder.

• updatesite– Support for Eclipse legacy update sites.

• reconciler.dropins– Install all the plug-ins and features found into the dropins/ folder. This is not a

repository in itself.

Page 95: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 95

Misc management bundles

• director.app– Provides a headless way of managing an installation (install / uninstall).– App.: org.eclipse.equinox.p2.director.app.application [1]

• installer– Provides an exemplary simple installer using an SWT-based UI.

[1] – Director application doc - http://wiki.eclipse.org/Equinox_p2_director_application

Page 96: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 96

Tooling plug-ins

Applications and tasks are provided to generate metadata and manage repository

• publisher– A modular and extensible mechanism to generate metadata.– Application: org.eclipse.equinox.p2.publisher.*,

FeaturesAndBundlesPublisher– Ant tasks: p2.publish.product, p2.publish.featureAndBundles,

p2.publisher

• metadata.generator (deprecated in 3.5)

– Generate metadata from an exported product.

• repository.tools– Provides a set of tools to manage repositories

• Ant tasks: p2.mirror, p2.repo2Runnable, [1]• …

• jarprocessor– Helper tool to sign and pack jars

[1] - Ant task - http://wiki.eclipse.org/Equinox/p2_Ant_Tasks

Page 97: Understanding and extending p2 for fun and profit

97© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license

p2 by example

Build and repo management

Deeper in p2Additional p2 constructs

From plug-ins and features to metadata

Plug-ins map

Reusing and tweaking the UI

Advanced concepts

Page 98: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 98

Tweaking the p2 UI for your audience

• The UI is split into 3 bundles.– p2.ui– p2.ui.sdk

• Integration

– p2.ui.sdk.scheduler• Scheduler

Page 99: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 99

Add a p2 Preference Page

• The p2 UI defines a number of preferences– Automatic Updates– Site selection

• We need to add a preference page to our RCP application

Page 100: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 100

Adding Automated Updates and other p2 Preferences

Since the p2 bundles are installed, the p2 preferences can be used.

Page 101: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 101

Remove automatic updates

• Eliminate:– org.eclipse.equinox.p2

.ui.sdk.scheduler– org.eclipse.equinox.p2

.updatechecker

• RCP Mail no longer supports automatic updates

Page 102: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 102

Customizing the UI

• Consider which bundles you need– Always include org.eclipse.equinox.p2.ui– If you wish to use automatic update checking,

include org.eclipse.equinox.p2.updatechecker– If you wish to reuse the SDK UI for automatic update include

org.eclipse.equinox.p2.ui.sdk.scheduler

• Configure an instance of  org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy

Page 103: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 103

Example – Control the Update

• Let’s lock down the application

• Register a new profile– Does not allow users to add sites– Group IUs by category

Page 104: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 104

Example – Control the Update

Page 105: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 105

The controlled mode

Notice that the entry to choose a site is not available.

The preference page to add repo is also removed.

Page 106: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 106

Granularity of what is visible

• By default, the p2 UI shows installed roots– Configure the UI to show all installed bundles– Remove the install history page– Reconfigure the installed software page

• i.e. to remove update

Page 107: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 107

Granularity of what is visible

Page 108: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 108

Updating on Startup

Activator startup code must ensure that the p2 infrastructure bundles are started. Otherwise, the required services may not be found when updates are checked.

Page 109: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 109

UI code snippets

• All the p2 UI examples are available at:http://wiki.eclipse.org/Equinox/p2/Adding_Self-Update_to_an_RCP_Application

• In CVSdev.eclipse.org/cvsroot/rt

org.eclipse.equinox/p2/examples

Page 110: Understanding and extending p2 for fun and profit

110© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license

p2 by example

Build and repo management

Deeper in p2Additional p2 constructs

From plug-ins and features to metadata

Plug-ins map

Reusing and tweaking the UI

Advanced concepts

Page 111: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 111

Queryable / Query

• IQueryable is a general interface for a collection of objects that can be queried

• Query is what you want to see found– Mostly used to find installable units

• In p2 everything dealing with IUs is queryable– MetadataRepository, Profile, result of query…

• Some default queries are provided (see implementors of Query)– InstallableUnitQuery: To find an IU matching an ID and or a version– CapabilityQuery: To find an IU providing a capability matching a given requirement– IUPropertyQuery: To find an IU with a given property– VersionLatestIUVersionQuery: To find the most recent IU

Page 112: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 112

Profile

A profile is the complete description in terms of IU of what is installed

• A profile contains– Properties defining the “environment” such as os, ws, arch,

install location, bundle pool location– The list of IUs– Properties associated with IUs

Class: Org.eclipse.equinox.internal.provisional.p2.engine.IProfile

Page 113: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 113

Planning a profile change

Because of inter IU dependencies, modification against a profile should be planned

• ProfileChangeRequest– Capture the changes you want to make to the profile (e.g. Install, Uninstall).– The request is processed by the Planner– An update is a removal and an addition

• Planner– The entity responsible for the evaluation of the change request, computing the

transitive closure and checking the dependencies– If a solution exists it will find it

• ProvisioningPlan– The planner returns a provisioning plan. The planning succeed pass or fail. Upon

failure explanations are provided. Upon success the plan returns a set of operands to go from the initial state of the profile to the desired state.

Page 114: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 114

Engine

The mechanism by which the profile is actually changed

• Runs over a set of operands (usually resulting from a planning operation) and executes a given set of phases on them. No profile consistency validation is done

Engine.perform(Operand[] ops, PhaseSet phases, IProgressMonitor pm)

• For each phase, the engine interprets from the touchpoint data of the IU, the action specific to the phase. The engine looks up the action to execute.

• Currently 8 phases are defined, and the typical set of phases (and their order) is defined in DefaultPhaseSet. The design allows for new phases could be added, however this would engage serious coding.

• The engine ensures consistency of the modification by performing a “transaction”.

• The engine emit events on the IProvisoningEventBus to describe what is happening. Events on the bus are post events and can not be vetoed.

Page 115: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 115

Engine flowchart

Page 116: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 116

Touchpoint / actions

The decoupling between p2 and the actual system being modified.

It defines how to modify a particular “runtime”.

• An action is a piece of code in charge of changing the system (e.g installing a bundle, setting a start level, etc.). An action can be context free or context bound. See ProvisioningAction

– Example of context free: chmod, unzip– Example of context bound: installBundle, setStartLevel,…

• A touchpoint provides the context in which an action is executed– For example the eclipse touchpoint provides its actions values such as the eclipse

install folder, the bundle pool and is also used to cache some common data structure (e.g. the state of the fwk being modified)

• The extension point for touchpoint and actions is defined in the engine.

Page 117: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 117

Engine and actions put together

Page 118: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 118

Artifact processor

• Artifacts can be stored in various format (e.g. pack200, jar, diff)

• A processor is responsible for transforming an artifact from its “stored” form to its canonical form.

• Processors can also be used to “look at” the bytes as they are coming through

– MD5, zip verifier,

• Mandatory steps are mentioned in the artifact descriptor in the artifact repository

– <example>

• Implementation detail:– The download manager looks at the various shapes under which an artifact is made

available and always prefer the non-canonical one.

• Extension point: org.eclipse.equinox.p2.artifactRepository.ProcessingStep

Page 119: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 119

Canonical

JBDiff

Artifact Repository

Pack200

Pack200Processor

Artifact processor, illustrated

Page 120: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 120

References

• p2 landing page http://wiki.eclipse.org/Equinox_p2

• All p2 articles http://wiki.eclipse.org/Category:Equinox_p2

• Getting the code http://wiki.eclipse.org/Equinox_p2_Getting_Started_for_Developers

• Contacting us– Equinox newsgroup– Mailing list: [email protected]

Page 121: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 121

Thank you

Page 122: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 122

F.A.Q.

Page 123: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 123

Bundle Pooling

• Every profile has a bundle pool location

• Shared pool → multiple profiles share bundles

• Save download time/bandwidth

• Save disk space

• Possible memory savings depending on JRE

• Can be setup with installer or admin UI

Page 124: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license

Installing just a plug-in

It is possible, just grab the IU and install it. The default p2 UI is not allowing for this to not overwhelm users To have p2 metadata for it, you still have to have a feature (PDE

restriction)

Page 125: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 125

Boot sequence

• Without dropins– Simpleconfigurator reads bundles.info and apply it (note that if

bundles.info has not changed, nothing is done).– p2 bundles are not loaded until p2 functionality is invoked (e.g

open the UI)

• With dropins – Simpleconfigurator reads bundles.info and apply it (note that if

bundles.info has not changed, nothing is done).– Reconciler bundles is started– Reconciler finds the bundles in the dropins folder and take them

through a complete installation phase. A new profile file and a new bundles.info are written

– Reconciler re-invoke simpleconfigurator to read bundles.info

Page 126: Understanding and extending p2 for fun and profit

© 2009 IBM Corp. and EclipseSource; All right reserved. Made available under Creative Commons Att. Nc Nd 2.5 license 126

Missing requirements

• The cause of an error indicating a missing requirement usually are:– Missing capabilities: no IU in the repository provides the

capability necessary to the satisfaction of the requirement.– Bogus filter on the IU that could satisfy the requirement– Missing IU: the IU satisfying the requirement is not available in

the repositories being consulted