| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // The file contains the implementation of the mini_installer re-versioner. | 5 // The file contains the implementation of the mini_installer re-versioner. |
| 6 // The main function (GenerateNextVersion) does the following in a temp dir: | 6 // The main function (GenerateNextVersion) does the following in a temp dir: |
| 7 // - Extracts and unpacks setup.exe and the Chrome-bin folder from | 7 // - Extracts and unpacks setup.exe and the Chrome-bin folder from |
| 8 // mini_installer.exe. | 8 // mini_installer.exe. |
| 9 // - Inspects setup.exe to determine the current version. | 9 // - Inspects setup.exe to determine the current version. |
| 10 // - Runs through all .dll and .exe files: | 10 // - Runs through all .dll and .exe files: |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 const char kSwitch7zaPath[] = "7za_path"; | 68 const char kSwitch7zaPath[] = "7za_path"; |
| 69 const wchar_t kTempDirPrefix[] = L"mini_installer_test_temp"; | 69 const wchar_t kTempDirPrefix[] = L"mini_installer_test_temp"; |
| 70 | 70 |
| 71 // A helper class for creating and cleaning a temporary directory. A temporary | 71 // A helper class for creating and cleaning a temporary directory. A temporary |
| 72 // directory is created in Initialize and destroyed (along with all of its | 72 // directory is created in Initialize and destroyed (along with all of its |
| 73 // contents) when the guard instance is destroyed. | 73 // contents) when the guard instance is destroyed. |
| 74 class ScopedTempDirectory { | 74 class ScopedTempDirectory { |
| 75 public: | 75 public: |
| 76 ScopedTempDirectory() { } | 76 ScopedTempDirectory() { } |
| 77 ~ScopedTempDirectory() { | 77 ~ScopedTempDirectory() { |
| 78 if (!directory_.empty() && !file_util::Delete(directory_, true)) { | 78 if (!directory_.empty() && !base::Delete(directory_, true)) { |
| 79 LOG(DFATAL) << "Failed deleting temporary directory \"" | 79 LOG(DFATAL) << "Failed deleting temporary directory \"" |
| 80 << directory_.value() << "\""; | 80 << directory_.value() << "\""; |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 // Creates a temporary directory. | 83 // Creates a temporary directory. |
| 84 bool Initialize() { | 84 bool Initialize() { |
| 85 DCHECK(directory_.empty()); | 85 DCHECK(directory_.empty()); |
| 86 if (!file_util::CreateNewTempDirectory(&kTempDirPrefix[0], &directory_)) { | 86 if (!file_util::CreateNewTempDirectory(&kTempDirPrefix[0], &directory_)) { |
| 87 LOG(DFATAL) << "Failed creating temporary directory."; | 87 LOG(DFATAL) << "Failed creating temporary directory."; |
| 88 return false; | 88 return false; |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 | 595 |
| 596 // Unpack chrome.7z | 596 // Unpack chrome.7z |
| 597 if (LzmaUtil::UnPackArchive(chrome_7z_name, work_dir.directory().value(), | 597 if (LzmaUtil::UnPackArchive(chrome_7z_name, work_dir.directory().value(), |
| 598 NULL) != NO_ERROR) { | 598 NULL) != NO_ERROR) { |
| 599 LOG(DFATAL) << "Failed unpacking \"" << chrome_7z_name << "\""; | 599 LOG(DFATAL) << "Failed unpacking \"" << chrome_7z_name << "\""; |
| 600 return false; | 600 return false; |
| 601 } | 601 } |
| 602 | 602 |
| 603 // Get rid of intermediate files | 603 // Get rid of intermediate files |
| 604 base::FilePath chrome_7z(chrome_7z_name); | 604 base::FilePath chrome_7z(chrome_7z_name); |
| 605 if (!file_util::Delete(chrome_7z, false) || | 605 if (!base::Delete(chrome_7z, false) || |
| 606 !file_util::Delete(chrome_packed_7z, false) || | 606 !base::Delete(chrome_packed_7z, false) || |
| 607 !file_util::Delete(setup_ex_, false)) { | 607 !base::Delete(setup_ex_, false)) { |
| 608 LOG(DFATAL) << "Failed deleting intermediate files"; | 608 LOG(DFATAL) << "Failed deleting intermediate files"; |
| 609 return false; | 609 return false; |
| 610 } | 610 } |
| 611 | 611 |
| 612 // Increment the version in all files. | 612 // Increment the version in all files. |
| 613 ApplyAlternateVersion(work_dir.directory(), direction, original_version, | 613 ApplyAlternateVersion(work_dir.directory(), direction, original_version, |
| 614 new_version); | 614 new_version); |
| 615 | 615 |
| 616 // Pack up files into chrome.7z | 616 // Pack up files into chrome.7z |
| 617 if (!CreateArchive(chrome_7z, work_dir.directory().Append(&kChromeBin[0]), 0)) | 617 if (!CreateArchive(chrome_7z, work_dir.directory().Append(&kChromeBin[0]), 0)) |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 return false; | 692 return false; |
| 693 } | 693 } |
| 694 ctx.current_version_str = ctx.current_version.ToString(); | 694 ctx.current_version_str = ctx.current_version.ToString(); |
| 695 ctx.new_version = ChromeVersion::FromString(version.GetString()); | 695 ctx.new_version = ChromeVersion::FromString(version.GetString()); |
| 696 ctx.new_version_str = ctx.new_version.ToString(); | 696 ctx.new_version_str = ctx.new_version.ToString(); |
| 697 | 697 |
| 698 return UpdateVersionIfMatch(target_file, &ctx); | 698 return UpdateVersionIfMatch(target_file, &ctx); |
| 699 } | 699 } |
| 700 | 700 |
| 701 } // namespace upgrade_test | 701 } // namespace upgrade_test |
| OLD | NEW |