eclipse/eclipse-updatehomedir.patch

273 lines
11 KiB
Diff
Raw Normal View History

2006-06-02 21:46:07 +00:00
Index: src/org/eclipse/update/search/UpdateSearchRequest.java
===================================================================
RCS file: /home/eclipse/org.eclipse.update.core/src/org/eclipse/update/search/UpdateSearchRequest.java,v
retrieving revision 1.27
diff -u -r1.27 UpdateSearchRequest.java
--- plugins/org.eclipse.update.core/src/org/eclipse/update/search/UpdateSearchRequest.java 29 Mar 2006 23:37:07 -0000 1.27
+++ plugins/org.eclipse.update.core/src/org/eclipse/update/search/UpdateSearchRequest.java 30 Mar 2006 06:02:10 -0000
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.update.search;
+import java.io.File;
import java.net.URL;
import java.util.ArrayList;
@@ -140,11 +141,11 @@
this.category = category;
this.scope = scope;
}
+
/**
* Returns the search catagory used in this request.
* @return the search category
*/
-
public IUpdateSearchCategory getCategory() {
return category;
}
@@ -251,6 +252,10 @@
// currently, the next conditional is only executed (qsite!=null) when
// running an update search.
if (qsite != null && searchFeatureProvidedSites) {
+ // do not update features that are installed in read-only locations
+ IFeature feature = query.getFeature();
+ if (feature != null && !feature.getSite().getCurrentConfiguredSite().verifyUpdatableStatus().isOK())
+ continue;
// check for mapping
IUpdateSiteAdapter mappedSite = getMappedSite(updatePolicy, qsite);
// when there is no mapped site the feature is not updatable
Index: src/org/eclipse/update/search/IUpdateSearchQuery.java
===================================================================
RCS file: /home/eclipse/org.eclipse.update.core/src/org/eclipse/update/search/IUpdateSearchQuery.java,v
retrieving revision 1.8
diff -u -r1.8 IUpdateSearchQuery.java
--- plugins/org.eclipse.update.core/src/org/eclipse/update/search/IUpdateSearchQuery.java 1 Mar 2005 20:29:16 -0000 1.8
+++ plugins/org.eclipse.update.core/src/org/eclipse/update/search/IUpdateSearchQuery.java 30 Mar 2006 06:02:10 -0000
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Red Hat Incorporated - getFeature() API addition
*******************************************************************************/
package org.eclipse.update.search;
@@ -50,4 +51,12 @@
* @param monitor a progress monitor to report search progress within the provided site
*/
public void run(ISite site, String [] categoriesToSkip, IUpdateSearchFilter filter, IUpdateSearchResultCollector collector, IProgressMonitor monitor);
+
+/**
+ * Returns IFeature associated with the IUpdateSearchQuery
+ *
+ * @return the IFeature that is associated with the IUpdateSearchQuery
+ * @since 3.2
+ */
+ public IFeature getFeature();
}
Index: src/org/eclipse/update/internal/search/OptionalFeatureSearchCategory.java
===================================================================
RCS file: /home/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/search/OptionalFeatureSearchCategory.java,v
retrieving revision 1.8
diff -u -r1.8 OptionalFeatureSearchCategory.java
--- plugins/org.eclipse.update.core/src/org/eclipse/update/internal/search/OptionalFeatureSearchCategory.java 1 Mar 2005 20:29:16 -0000 1.8
+++ plugins/org.eclipse.update.core/src/org/eclipse/update/internal/search/OptionalFeatureSearchCategory.java 30 Mar 2006 06:02:10 -0000
@@ -76,6 +76,13 @@
public IQueryUpdateSiteAdapter getQuerySearchSite() {
return null;
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.update.internal.ui.search.ISearchQuery#getFeature()
+ */
+ public IFeature getFeature() {
+ return null;
+ }
}
public void addVersionedIdentifier(VersionedIdentifier vid) {
Index: src/org/eclipse/update/internal/search/UpdatesSearchCategory.java
===================================================================
RCS file: /home/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/search/UpdatesSearchCategory.java,v
retrieving revision 1.26
diff -u -r1.26 UpdatesSearchCategory.java
--- plugins/org.eclipse.update.core/src/org/eclipse/update/internal/search/UpdatesSearchCategory.java 23 May 2005 17:59:41 -0000 1.26
+++ plugins/org.eclipse.update.core/src/org/eclipse/update/internal/search/UpdatesSearchCategory.java 30 Mar 2006 06:02:10 -0000
@@ -285,6 +285,10 @@
monitor.worked(1);
monitor.done();
}
+
+ public IFeature getFeature() {
+ return candidate;
+ }
}
private ArrayList candidates;
Index: src/org/eclipse/update/internal/search/SiteSearchCategory.java
===================================================================
RCS file: /home/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/search/SiteSearchCategory.java,v
retrieving revision 1.12
diff -u -r1.12 SiteSearchCategory.java
--- plugins/org.eclipse.update.core/src/org/eclipse/update/internal/search/SiteSearchCategory.java 29 Mar 2006 23:37:08 -0000 1.12
+++ plugins/org.eclipse.update.core/src/org/eclipse/update/internal/search/SiteSearchCategory.java 30 Mar 2006 06:02:10 -0000
@@ -114,6 +114,12 @@
public IQueryUpdateSiteAdapter getQuerySearchSite() {
return null;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.update.internal.ui.search.ISearchQuery#getFeature()
+ */
+ public IFeature getFeature() {
+ return null;
+ }
}
public SiteSearchCategory() {
Index: src/org/eclipse/update/internal/core/ConfiguredSite.java
===================================================================
RCS file: /home/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/core/ConfiguredSite.java,v
retrieving revision 1.96
diff -u -r1.96 ConfiguredSite.java
--- plugins/org.eclipse.update.core/src/org/eclipse/update/internal/core/ConfiguredSite.java 30 Mar 2006 02:34:37 -0000 1.96
+++ plugins/org.eclipse.update.core/src/org/eclipse/update/internal/core/ConfiguredSite.java 30 Mar 2006 06:02:10 -0000
@@ -35,6 +35,7 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.osgi.util.NLS;
import org.eclipse.update.configuration.IActivity;
import org.eclipse.update.configuration.IConfiguredSite;
@@ -803,7 +804,9 @@
}
} else {
File container = getSiteContaining(file);
- if (container != null) {
+ // allow the install location to pass even though it looks like this
+ // site is contained in another site
+ if (container != null && !siteLocation.equals(Platform.getInstallLocation().getURL().getFile())) {
verifyStatus = createStatus(IStatus.ERROR, NLS.bind(Messages.ConfiguredSite_ContainedInAnotherSite, (new String[] { container.getAbsolutePath() })), null);
return verifyStatus;
}
Index: src/org/eclipse/update/internal/ui/wizards/InstallWizard2.java
===================================================================
RCS file: /home/eclipse/org.eclipse.update.ui/src/org/eclipse/update/internal/ui/wizards/InstallWizard2.java,v
retrieving revision 1.8
diff -u -r1.8 InstallWizard2.java
--- plugins/org.eclipse.update.ui/src/org/eclipse/update/internal/ui/wizards/InstallWizard2.java 17 Mar 2006 06:02:44 -0000 1.8
+++ plugins/org.eclipse.update.ui/src/org/eclipse/update/internal/ui/wizards/InstallWizard2.java 30 Mar 2006 06:02:11 -0000
@@ -148,7 +148,7 @@
addPage(licensePage);
optionalFeaturesPage = new OptionalFeaturesPage(config);
addPage(optionalFeaturesPage);
- targetPage = new TargetPage(config);
+ targetPage = new TargetPage(config, isUpdate);
addPage(targetPage);
}
Index: src/org/eclipse/update/internal/ui/wizards/TargetPage.java
===================================================================
RCS file: /home/eclipse/org.eclipse.update.ui/src/org/eclipse/update/internal/ui/wizards/TargetPage.java,v
retrieving revision 1.74
diff -u -r1.74 TargetPage.java
--- plugins/org.eclipse.update.ui/src/org/eclipse/update/internal/ui/wizards/TargetPage.java 21 Nov 2005 21:39:24 -0000 1.74
+++ plugins/org.eclipse.update.ui/src/org/eclipse/update/internal/ui/wizards/TargetPage.java 30 Mar 2006 06:02:11 -0000
@@ -13,6 +13,9 @@
import java.io.*;
import java.util.*;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.resource.*;
import org.eclipse.jface.viewers.*;
@@ -41,6 +44,7 @@
private Label installLocation;
private Button changeLocation;
static HashSet added;
+ private boolean isUpdate; // whether the wizard is updating a feature or installing a new one
class JobsContentProvider
extends DefaultContentProvider
@@ -113,13 +117,14 @@
/**
* Constructor for ReviewPage2
*/
- public TargetPage(IInstallConfiguration config) {
+ public TargetPage(IInstallConfiguration config, boolean isUpdate) {
super("Target"); //$NON-NLS-1$
setTitle(UpdateUIMessages.InstallWizard_TargetPage_title);
setDescription(UpdateUIMessages.InstallWizard_TargetPage_desc);
this.config = config;
UpdateUI.getDefault().getLabelProvider().connect(this);
configListener = new ConfigListener();
+ this.isUpdate = isUpdate;
}
public void setJobs(IInstallFeatureOperation[] jobs) {
@@ -150,7 +155,7 @@
label.setLayoutData(gd);
installLocation = new Label(client, SWT.NULL);
- installLocation.setText("foo"); //$NON-NLS-1$
+ installLocation.setText(""); //$NON-NLS-1$
gd = new GridData(GridData.FILL_HORIZONTAL);
installLocation.setLayoutData(gd);
@@ -360,17 +365,51 @@
continue;
}
- jobs[i].setTargetSite(getFirstTargetSite(jobs[i]));
+ IConfiguredSite csite = getFirstTargetSite(jobs[i]);
+ if (csite == null && Platform.getInstallLocation().isReadOnly() && isUpdate == false) {
+ // there are no updateable sites, the installation location is read-only and we are installing a new feature
+ // make an update site in the user's home direcotry
+ File site= new File(System.getProperty("user.home") + File.separator + ".eclipse" + File.separator + //$NON-NLS-1$
+ Platform.getProduct().getId() + File.separator + "updates"); //$NON-NLS-1$
+
+ try {
+ csite = config.createConfiguredSite(site);
+ config.addConfiguredSite(csite);
+ IStatus status = csite.verifyUpdatableStatus();
+ if (!status.isOK())
+ throw new CoreException(status);
+
+ } catch (CoreException e) {
+ // there was a problem, the user must choose an installation site
+ csite = null;
+ // no need to check if the directory exists because File.delete() returns false if it's not there
+ deleteDir(site);
+ }
+ }
+ jobs[i].setTargetSite(csite);
}
}
+
+ private boolean deleteDir(File dir) {
+ if (dir.isDirectory()) {
+ String[] files = dir.list();
+ for (int i=0; i < files.length; i++) {
+ if (!deleteDir(new File(dir, files[i]))) {
+ return false;
+ }
+ }
+ }
+ return dir.delete();
+ }
private IConfiguredSite getFirstTargetSite(IInstallFeatureOperation job) {
IConfiguredSite[] sites = config.getConfiguredSites();
for (int i = 0; i < sites.length; i++) {
IConfiguredSite csite = sites[i];
- if (getSiteVisibility(csite, job))
+ if (getSiteVisibility(csite, job) &&
+ csite.getSite().getCurrentConfiguredSite().verifyUpdatableStatus().isOK())
return csite;
}
return null;