diff options
author | bcwhite <bcwhite@chromium.org> | 2015-07-09 03:58:55 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-07-09 10:59:17 +0000 |
commit | 974453e16791b896bdce75273402834db414a0e9 (patch) | |
tree | c4c4ff689e8ca406b3df20a0817a9a7aefee86df /chrome | |
parent | 4c711b5767ccea7095621defa2fb77580a132cca (diff) | |
download | chromium_src-974453e16791b896bdce75273402834db414a0e9.zip chromium_src-974453e16791b896bdce75273402834db414a0e9.tar.gz chromium_src-974453e16791b896bdce75273402834db414a0e9.tar.bz2 |
Use --previous-version command-line parameter.
If that parameter is provided, match only that specific version
of an install.
BUG=385419
Review URL: https://codereview.chromium.org/1220193008
Cr-Commit-Position: refs/heads/master@{#338011}
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/installer/setup/setup_main.cc | 15 | ||||
-rw-r--r-- | chrome/installer/setup/setup_util.cc | 9 | ||||
-rw-r--r-- | chrome/installer/setup/setup_util.h | 6 | ||||
-rw-r--r-- | chrome/installer/setup/setup_util_unittest.cc | 23 | ||||
-rw-r--r-- | chrome/installer/util/util_constants.cc | 3 | ||||
-rw-r--r-- | chrome/installer/util/util_constants.h | 1 |
6 files changed, 47 insertions, 10 deletions
diff --git a/chrome/installer/setup/setup_main.cc b/chrome/installer/setup/setup_main.cc index 93eb38d4..6b419c7 100644 --- a/chrome/installer/setup/setup_main.cc +++ b/chrome/installer/setup/setup_main.cc @@ -141,7 +141,8 @@ bool UncompressAndPatchChromeArchive( const installer::InstallerState& installer_state, installer::ArchivePatchHelper* archive_helper, installer::ArchiveType* archive_type, - installer::InstallStatus* install_status) { + installer::InstallStatus* install_status, + const base::Version& previous_version) { installer_state.UpdateStage(installer::UNCOMPRESSING); if (!archive_helper->Uncompress(NULL)) { *install_status = installer::UNCOMPRESSION_FAILED; @@ -160,7 +161,8 @@ bool UncompressAndPatchChromeArchive( // Find the installed version's archive to serve as the source for patching. base::FilePath patch_source(installer::FindArchiveToPatch(original_state, - installer_state)); + installer_state, + previous_version)); if (patch_source.empty()) { LOG(ERROR) << "Failed to find archive to patch."; *install_status = installer::DIFF_PATCH_SOURCE_MISSING; @@ -1353,6 +1355,12 @@ InstallStatus InstallProductsHelper(const InstallationState& original_state, base::FilePath uncompressed_archive(cmd_line.GetSwitchValuePath( switches::kUncompressedArchive)); if (uncompressed_archive.empty()) { + base::Version previous_version; + if (cmd_line.HasSwitch(installer::switches::kPreviousVersion)) { + previous_version = base::Version(cmd_line.GetSwitchValueASCII( + installer::switches::kPreviousVersion)); + } + scoped_ptr<ArchivePatchHelper> archive_helper( CreateChromeArchiveHelper(setup_exe, cmd_line, installer_state, unpack_path)); @@ -1363,7 +1371,8 @@ InstallStatus InstallProductsHelper(const InstallationState& original_state, installer_state, archive_helper.get(), archive_type, - &install_status)) { + &install_status, + previous_version)) { DCHECK_NE(install_status, UNKNOWN_STATUS); return install_status; } diff --git a/chrome/installer/setup/setup_util.cc b/chrome/installer/setup/setup_util.cc index 99ea3f5..7f0af71 100644 --- a/chrome/installer/setup/setup_util.cc +++ b/chrome/installer/setup/setup_util.cc @@ -169,7 +169,14 @@ Version* GetMaxVersionFromArchiveDir(const base::FilePath& chrome_path) { } base::FilePath FindArchiveToPatch(const InstallationState& original_state, - const InstallerState& installer_state) { + const InstallerState& installer_state, + const base::Version& desired_version) { + if (desired_version.IsValid()) { + base::FilePath archive(installer_state.GetInstallerDirectory( + desired_version).Append(kChromeArchive)); + return base::PathExists(archive) ? archive : base::FilePath(); + } + // Check based on the version number advertised to Google Update, since that // is the value used to select a specific differential update. If an archive // can't be found using that, fallback to using the newest version present. diff --git a/chrome/installer/setup/setup_util.h b/chrome/installer/setup/setup_util.h index 0e8dfa3..0b04b7b 100644 --- a/chrome/installer/setup/setup_util.h +++ b/chrome/installer/setup/setup_util.h @@ -52,9 +52,11 @@ int BsdiffPatchFiles(const base::FilePath& src, Version* GetMaxVersionFromArchiveDir(const base::FilePath& chrome_path); // Returns the uncompressed archive of the installed version that serves as the -// source for patching. +// source for patching. If |desired_version| is valid, only the path to that +// version will be returned, or empty if it doesn't exist. base::FilePath FindArchiveToPatch(const InstallationState& original_state, - const InstallerState& installer_state); + const InstallerState& installer_state, + const base::Version& desired_version); // Spawns a new process that waits for a specified amount of time before // attempting to delete |path|. This is useful for setup to delete the diff --git a/chrome/installer/setup/setup_util_unittest.cc b/chrome/installer/setup/setup_util_unittest.cc index 5174d1c..bebf65a 100644 --- a/chrome/installer/setup/setup_util_unittest.cc +++ b/chrome/installer/setup/setup_util_unittest.cc @@ -375,7 +375,7 @@ const BrowserDistribution::Type FindArchiveToPatchTest::kProductType_ = // Test that the path to the advertised product version is found. TEST_F(FindArchiveToPatchTest, ProductVersionFound) { base::FilePath patch_source(installer::FindArchiveToPatch( - *original_state_, *installer_state_)); + *original_state_, *installer_state_, base::Version())); EXPECT_EQ(GetProductVersionArchivePath().value(), patch_source.value()); } @@ -385,13 +385,13 @@ TEST_F(FindArchiveToPatchTest, MaxVersionFound) { // The patch file is absent. ASSERT_TRUE(base::DeleteFile(GetProductVersionArchivePath(), false)); base::FilePath patch_source(installer::FindArchiveToPatch( - *original_state_, *installer_state_)); + *original_state_, *installer_state_, base::Version())); EXPECT_EQ(GetMaxVersionArchivePath().value(), patch_source.value()); // The product doesn't appear to be installed, so the max version is found. UninstallProduct(); patch_source = installer::FindArchiveToPatch( - *original_state_, *installer_state_); + *original_state_, *installer_state_, base::Version()); EXPECT_EQ(GetMaxVersionArchivePath().value(), patch_source.value()); } @@ -403,10 +403,25 @@ TEST_F(FindArchiveToPatchTest, NoVersionFound) { ASSERT_TRUE(base::DeleteFile(GetMaxVersionArchivePath(), false)); base::FilePath patch_source(installer::FindArchiveToPatch( - *original_state_, *installer_state_)); + *original_state_, *installer_state_, base::Version())); EXPECT_EQ(base::FilePath::StringType(), patch_source.value()); } +TEST_F(FindArchiveToPatchTest, DesiredVersionFound) { + base::FilePath patch_source1(installer::FindArchiveToPatch( + *original_state_, *installer_state_, product_version_)); + EXPECT_EQ(GetProductVersionArchivePath().value(), patch_source1.value()); + base::FilePath patch_source2(installer::FindArchiveToPatch( + *original_state_, *installer_state_, max_version_)); + EXPECT_EQ(GetMaxVersionArchivePath().value(), patch_source2.value()); +} + +TEST_F(FindArchiveToPatchTest, DesiredVersionNotFound) { + base::FilePath patch_source(installer::FindArchiveToPatch( + *original_state_, *installer_state_, base::Version("1.2.3.4"))); + EXPECT_EQ(base::FilePath().value(), patch_source.value()); +} + namespace { class MigrateMultiToSingleTest : public testing::Test { diff --git a/chrome/installer/util/util_constants.cc b/chrome/installer/util/util_constants.cc index bfb5406..a1afbcd 100644 --- a/chrome/installer/util/util_constants.cc +++ b/chrome/installer/util/util_constants.cc @@ -96,6 +96,9 @@ const char kNewSetupExe[] = "new-setup-exe"; // Notify the installer that the OS has been upgraded. const char kOnOsUpgrade[] = "on-os-upgrade"; +// Provide the previous version that patch is for. +const char kPreviousVersion[] = "previous-version"; + // Requests that setup attempt to reenable autoupdates for Chrome. const char kReenableAutoupdates[] = "reenable-autoupdates"; diff --git a/chrome/installer/util/util_constants.h b/chrome/installer/util/util_constants.h index b09e65e..389da42 100644 --- a/chrome/installer/util/util_constants.h +++ b/chrome/installer/util/util_constants.h @@ -155,6 +155,7 @@ extern const char kMsi[]; extern const char kMultiInstall[]; extern const char kNewSetupExe[]; extern const char kOnOsUpgrade[]; +extern const char kPreviousVersion[]; extern const char kReenableAutoupdates[]; extern const char kRegisterChromeBrowser[]; extern const char kRegisterChromeBrowserSuffix[]; |