diff options
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.ui.sdk.scheduler')
4 files changed, 32 insertions, 95 deletions
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/META-INF/MANIFEST.MF index e4498d102..01351065d 100644 --- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/META-INF/MANIFEST.MF @@ -22,6 +22,7 @@ Import-Package: com.ibm.icu.util;version="4.0.1", org.eclipse.equinox.internal.p2.engine.phases, org.eclipse.equinox.internal.p2.garbagecollector, org.eclipse.equinox.internal.p2.metadata.query, + org.eclipse.equinox.internal.p2.touchpoint.eclipse;version="2.0.0", org.eclipse.equinox.internal.p2.ui, org.eclipse.equinox.internal.p2.ui.actions, org.eclipse.equinox.internal.p2.ui.query, diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdateScheduler.java b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdateScheduler.java index 67b5c98e8..330b2252b 100644 --- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdateScheduler.java +++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdateScheduler.java @@ -15,6 +15,7 @@ package org.eclipse.equinox.internal.p2.ui.sdk.scheduler; import com.ibm.icu.util.Calendar; import com.ibm.icu.util.ULocale; import java.io.File; +import java.net.URI; import java.util.Iterator; import java.util.Set; import org.eclipse.core.runtime.*; @@ -32,6 +33,8 @@ import org.eclipse.equinox.p2.engine.query.UserVisibleRootQuery; import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.query.IQuery; import org.eclipse.equinox.p2.query.QueryUtil; +import org.eclipse.equinox.p2.repository.IRepositoryManager; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.osgi.service.datalocation.Location; @@ -49,6 +52,7 @@ public class AutomaticUpdateScheduler implements IStartup { private static final String ECLIPSE_P2_SKIP_MIGRATION_WIZARD = "eclipse.p2.skipMigrationWizard"; //$NON-NLS-1$ private static final String ECLIPSE_P2_SKIP_MOVED_INSTALL_DETECTION = "eclipse.p2.skipMovedInstallDetection"; //$NON-NLS-1$ + public static final String MIGRATION_DIALOG_SHOWN = "migrationDialogShown"; //$NON-NLS-1$ // values are to be picked up from the arrays DAYS and HOURS public static final String P_DAY = "day"; //$NON-NLS-1$ @@ -113,14 +117,22 @@ public class AutomaticUpdateScheduler implements IStartup { return false; IProfile previousProfile = null; + URI[] reposToMigrate = null; if (!skipFirstTimeMigration() && !configurationSpecifiedManually() && isFirstTimeRunningThisSharedInstance(agent, registry, currentProfile)) { File searchRoot = getSearchLocation(); if (searchRoot == null) return false; - previousProfile = new PreviousConfigurationFinder(getConfigurationLocation().getParentFile()).findPreviousInstalls(searchRoot, getInstallFolder()); + + IProvisioningAgent otherConfigAgent = new PreviousConfigurationFinder(getConfigurationLocation().getParentFile()).findPreviousInstalls(searchRoot, getInstallFolder()); + if (otherConfigAgent == null) { + return false; + } + previousProfile = ((IProfileRegistry) otherConfigAgent.getService(IProfileRegistry.SERVICE_NAME)).getProfile(IProfileRegistry.SELF); if (previousProfile == null) return false; + reposToMigrate = ((IMetadataRepositoryManager) otherConfigAgent.getService(IMetadataRepositoryManager.SERVICE_NAME)).getKnownRepositories(IRepositoryManager.REPOSITORIES_NON_SYSTEM); + //At this point we consider that the migration is done since we will present something to the user. registry.setProfileStateProperty(currentProfile.getProfileId(), registry.listProfileTimestamps(currentProfile.getProfileId())[0], "INITIAL", "DONE"); } @@ -143,7 +155,7 @@ public class AutomaticUpdateScheduler implements IStartup { } - //The search location is two level up from teh configuration location. + //The search location is two level up from the configuration location. private File getSearchLocation() { File parent = getConfigurationLocation().getParentFile(); if (parent == null) @@ -173,8 +185,8 @@ public class AutomaticUpdateScheduler implements IStartup { long[] history = registry.listProfileTimestamps(currentProfile.getProfileId()); boolean isInitial = IProfile.STATE_SHARED_INSTALL_VALUE_INITIAL.equals(registry.getProfileStateProperties(currentProfile.getProfileId(), history[0]).get(IProfile.STATE_PROP_SHARED_INSTALL)); if (isInitial) - return false; - return "DONE".equals(registry.getProfileStateProperties(currentProfile.getProfileId(), history[0]).get("INITIAL")); + return true; + return !"DONE".equals(registry.getProfileStateProperties(currentProfile.getProfileId(), history[0]).get("INITIAL")); } /** @@ -206,7 +218,6 @@ public class AutomaticUpdateScheduler implements IStartup { } private void openMigrationWizard(final IProfile inputProfile) { - Display d = Display.getDefault(); d.asyncExec(new Runnable() { public void run() { @@ -229,25 +240,8 @@ public class AutomaticUpdateScheduler implements IStartup { if (lastReset == null) return false; return lastShownMigration < lastReset.getTimestamp(); - - // && !remindMeLater()) - // return false; - // - // final String PREF_MIGRATION_DIALOG_SHOWN = "migrationDialogShown"; //$NON-NLS-1$ - // - // //Have we already shown the migration dialog - // if (AutomaticUpdatePlugin.getDefault().getPreferenceStore().getString(PREF_MIGRATION_DIALOG_SHOWN) == resetState) - // return false; - // - // //Remember that we are showing the migration dialog - // AutomaticUpdatePlugin.getDefault().getPreferenceStore().setValue(PREF_MIGRATION_DIALOG_SHOWN, resetState); - // AutomaticUpdatePlugin.getDefault().savePreferences(); - // - // return true; } - public static final String MIGRATION_DIALOG_SHOWN = "migrationDialogShown"; //$NON-NLS-1$ - //Get the timestamp that we migrated from private long getLastShownMigration() { return AutomaticUpdatePlugin.getDefault().getPreferenceStore().getLong(MIGRATION_DIALOG_SHOWN); diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/ConfigAreaToAgent.java b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/ConfigAreaToAgent.java deleted file mode 100644 index 071f7ae64..000000000 --- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/ConfigAreaToAgent.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.eclipse.equinox.internal.p2.ui.sdk.scheduler; - -import java.io.*; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Properties; -import org.eclipse.core.runtime.URIUtil; -import org.eclipse.equinox.p2.core.IProvisioningAgent; -import org.eclipse.equinox.p2.core.ProvisionException; -import org.eclipse.equinox.p2.engine.IProfile; -import org.eclipse.equinox.p2.engine.IProfileRegistry; - -public class ConfigAreaToAgent { - public IProfile fromConfigurationToProfile(File configurationFolder) { - //TODO dispose the agent - String toBeImportedProfileId = null; - File config = new File(configurationFolder, "configuration/config.ini"); //$NON-NLS-1$ - URI configArea = config.getParentFile().toURI(); - InputStream is = null; - // default area - File p2DataArea = new File(configurationFolder, "p2"); //$NON-NLS-1$ - try { - Properties props = new Properties(); - is = new FileInputStream(config); - props.load(is); - toBeImportedProfileId = props.getProperty("eclipse.p2.profile"); //$NON-NLS-1$ - String url = props.getProperty("eclipse.p2.data.area"); //$NON-NLS-1$ - if (url != null) { - final String CONFIG_DIR = "@config.dir/"; //$NON-NLS-1$ - final String FILE_PROTOCOL = "file:"; //$NON-NLS-1$ - if (url.startsWith(CONFIG_DIR)) - url = FILE_PROTOCOL + url.substring(CONFIG_DIR.length()); - p2DataArea = new File(URIUtil.makeAbsolute(URIUtil.fromString(new File(url.substring(FILE_PROTOCOL.length())).isAbsolute() ? url : url.substring(FILE_PROTOCOL.length())), configArea)); - } - } catch (IOException ioe) { - //ignore - } catch (URISyntaxException e) { - return null; - } finally { - try { - is.close(); - } catch (IOException ioe) { - //ignore - } - is = null; - } - if (p2DataArea.exists()) { - IProvisioningAgent agent = null; - try { - agent = AutomaticUpdatePlugin.getDefault().getAgentProvider().createAgent(p2DataArea.toURI()); - } catch (ProvisionException e) { - //Can't happen - } - IProfileRegistry registry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME); - if (toBeImportedProfileId != null) - return registry.getProfile(toBeImportedProfileId); - - //TODO we may need to set the SELF profile on the registry to load the repos - IProfile[] allProfiles = registry.getProfiles(); - if (allProfiles.length == 1) - return allProfiles[0]; - - // IMetadataRepositoryManager metadataRepoMgr = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME); - // URI[] metadataRepos = metadataRepoMgr.getKnownRepositories(IRepositoryManager.REPOSITORIES_NON_SYSTEM); - //TODO deal with the repos - } - return null; - } - -} diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/PreviousConfigurationFinder.java b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/PreviousConfigurationFinder.java index fadfe4157..68dbf8f62 100644 --- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/PreviousConfigurationFinder.java +++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/PreviousConfigurationFinder.java @@ -1,11 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2013 Ericsson AB and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Ericsson AB - initial API and implementation + *******************************************************************************/ package org.eclipse.equinox.internal.p2.ui.sdk.scheduler; +import org.eclipse.equinox.internal.p2.touchpoint.eclipse.AgentFromInstall; + import java.io.*; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.eclipse.core.runtime.Platform; -import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.core.IProvisioningAgent; public class PreviousConfigurationFinder { @@ -130,7 +142,7 @@ public class PreviousConfigurationFinder { return new ConfigurationDescriptor(m.group(1), new Identifier(m.group(2)), m.group(3), m.group(4), candidate.getAbsoluteFile()); } - public IProfile findPreviousInstalls(File searchRoot, File installFolder) { + public IProvisioningAgent findPreviousInstalls(File searchRoot, File installFolder) { List<ConfigurationDescriptor> potentialConfigurations = readPreviousConfigurations(searchRoot); ConfigurationDescriptor runningConfiguration = getConfigdataFromProductFile(installFolder); if (runningConfiguration == null) @@ -140,7 +152,7 @@ public class PreviousConfigurationFinder { match = findMostRelevantConfigurationFromProductId(potentialConfigurations, runningConfiguration); if (match == null) return null; - return new ConfigAreaToAgent().fromConfigurationToProfile(match.getConfig()); + return AgentFromInstall.createAgentFrom(AutomaticUpdatePlugin.getDefault().getAgentProvider(), null, new File(match.getConfig(), "configuration"), null); //$NON-NLS-1$ } private ConfigurationDescriptor getConfigdataFromProductFile(File installFolder) { |