Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 324355

Summary: [ui] Install from Update Site does not distinguish between target OSes
Product: [Eclipse Project] Equinox Reporter: Robert Weisz <weisz>
Component: p2Assignee: DJ Houghton <dj.houghton>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: john.arthorne, susan, thomas
Version: 3.6Flags: john.arthorne: review+
Target Milestone: 3.7 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Screenshots of Update Site
none
picked the wrong OS
none
Testcase Update site
none
patch
none
updated patch
none
update site for testing none

Description Robert Weisz CLA 2010-09-02 17:02:58 EDT
Build Identifier: I20100608-0911  (Eclipse 3.6 Helios)

See attached an Update Site zip file,  that contains features for both Windows and Linux.  The GUI doesn't differentiate between them,  and the display shows as if the same features shows twice.  But as per screenshot attached,  you could select one of them,  and it could be for the wrong OS,  which is detected and error presented to user.  So this detection could be done earlier,  and the display filtered to show only the feature matching the current OS.

Reproducible: Always

Steps to Reproduce:
1. Download and unzip the attached CC.zip file  (it is an Update Site).
2. Start Eclipse,  click Help->Install New Software
3. Click on Add and point to the unzipped Update Site from 1.
4. Uncheck "Group Items by Category"
5. You will see two identical entries,  as per screenshot
6. Try picking one, then the other,  and you will get an error when you pick the Linux one and you are on Windows.
Comment 1 Robert Weisz CLA 2010-09-02 17:10:47 EDT
Created attachment 178102 [details]
Screenshots of Update Site
Comment 2 Robert Weisz CLA 2010-09-02 17:11:31 EDT
Created attachment 178103 [details]
picked the wrong OS
Comment 3 Robert Weisz CLA 2010-09-02 18:48:06 EDT
This behavior is reproducible in 3.5 as well as 3.6.

Example Update Site file CC.zip is 3MB,  so too large to attach directly it seems.  Looking for alternatives.
Comment 4 Robert Weisz CLA 2010-09-02 22:02:46 EDT
Created attachment 178115 [details]
Testcase Update site
Comment 5 Denis Roy CLA 2010-09-03 17:31:12 EDT
The content of attachment 178115 [details] has been deleted by
    Denis Roy <denis.roy@eclipse.org>
who provided the following reason:

Deleted as requested by the team

The token used to delete this attachment was generated at 2010-09-03 17:30:56 EDT.
Comment 6 DJ Houghton CLA 2010-09-08 17:47:57 EDT
Thomas, I believe this should be done in the UI but I am having problems writing the proper query. Basically it should be a query which is "all IUs whose filter matches the given os/ws/nl combo".

I've tried writing some compound queries but keep getting an IllegalArgumentException when I get to the filter matching part. I've looked at the doc on the wiki but am stumped. Do you have any suggestions? Thanks.
Comment 7 Thomas Hallgren CLA 2010-09-09 06:00:47 EDT
The IU filter will match against a special IU (the 'context' IU). You can create this IU like this:

 Map env = new Hashtable();
 env.put("osgi.os", "linux");
 env.put("osgi.ws", "gtk");
 env.put("osgi.arch", "x86");
 IInstallableUnit envIU = InstallableUnit.contextIU(env);

Now, if you only want to match IU's on filters, you just do this.

 IQuery<IInstallableUnit> query = QueryUtil.createMatchQuery("$0 ~= filter", envIU);
Comment 8 DJ Houghton CLA 2010-09-09 09:00:51 EDT
Cool, thanks Thomas. I've modified it slightly to suit my needs and it works. 

For reference, this is what I've done:

IQuery<IInstallableUnit> groupQuery = QueryUtil.createIUGroupQuery();
IQuery<IInstallableUnit> filterQuery = QueryUtil.createMatchQuery("filter == null || $0 ~= filter", envIU);
IQuery<IInstallableUnit> query = QueryUtil.createCompoundQuery(groupQuery, filterQuery, true);
Comment 9 DJ Houghton CLA 2010-09-09 10:21:17 EDT
Created attachment 178520 [details]
patch

Here is a patch which adds a new checkbox to the Available IUs page and filters out the results based on the profile's environment settings, if applicable.
Comment 10 DJ Houghton CLA 2010-09-09 10:48:42 EDT
Comment on attachment 178520 [details]
patch

Patch isn't quite right, doesn't handle the case where we are viewing via categories.
Comment 11 DJ Houghton CLA 2010-09-09 11:33:22 EDT
Created attachment 178525 [details]
updated patch

Here is an updated patch which works whether we are viewing by category, or not.
Comment 12 DJ Houghton CLA 2010-09-09 11:35:43 EDT
Susan, do you mind reviewing this one for me? I think it is pretty straight forward but I'm not a UI guy. No hurry to get it in for the milestone next week. I'll mark it M3 so we don't lose track of it.
Comment 13 DJ Houghton CLA 2010-10-08 17:16:14 EDT
Bumping to M4 since I'm going to be on holidays. Susan, if you have time to review feel free to release for M3.
Comment 14 DJ Houghton CLA 2010-12-03 09:10:42 EST
Created attachment 184467 [details]
update site for testing
Comment 15 John Arthorne CLA 2010-12-14 10:33:30 EST
Looks good. I also tested on the helios repository, where it filtered out the Linux-specific contributions from Linux tools project.
Comment 16 DJ Houghton CLA 2010-12-14 11:16:09 EST
Patch released to HEAD.