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 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 return base::string16(); | 736 return base::string16(); |
737 } | 737 } |
738 ctx.current_version_str = ctx.current_version.ToString(); | 738 ctx.current_version_str = ctx.current_version.ToString(); |
739 | 739 |
740 if (!IncrementNewVersion(direction, &ctx)) { | 740 if (!IncrementNewVersion(direction, &ctx)) { |
741 LOG(DFATAL) << "Failed to increment version from \"" | 741 LOG(DFATAL) << "Failed to increment version from \"" |
742 << original_file.value() << "\""; | 742 << original_file.value() << "\""; |
743 return base::string16(); | 743 return base::string16(); |
744 } | 744 } |
745 | 745 |
746 base::Version new_version(base::UTF16ToASCII(ctx.new_version_str)); | 746 DCHECK_EQ(ctx.current_version_str.size(), ctx.new_version_str.size()); |
747 GenerateSpecificPEFileVersion(original_file, target_file, new_version); | 747 |
| 748 if (!base::CopyFile(original_file, target_file)) { |
| 749 LOG(DFATAL) << "Failed copying \"" << original_file.value() |
| 750 << "\" to \"" << target_file.value() << "\""; |
| 751 return base::string16(); |
| 752 } |
| 753 |
| 754 if (!UpdateVersionIfMatch(target_file, &ctx)) |
| 755 return base::string16(); |
748 | 756 |
749 return ctx.new_version_str; | 757 return ctx.new_version_str; |
750 } | 758 } |
751 | 759 |
752 bool GenerateSpecificPEFileVersion(const base::FilePath& original_file, | |
753 const base::FilePath& target_file, | |
754 const base::Version& version) { | |
755 // First copy original_file to target_file. | |
756 if (!base::CopyFile(original_file, target_file)) { | |
757 LOG(DFATAL) << "Failed copying \"" << original_file.value() | |
758 << "\" to \"" << target_file.value() << "\""; | |
759 return false; | |
760 } | |
761 | |
762 VisitResourceContext ctx; | |
763 if (!GetFileVersion(target_file, &ctx.current_version)) { | |
764 LOG(DFATAL) << "Failed reading version from \"" << target_file.value() | |
765 << "\""; | |
766 return false; | |
767 } | |
768 ctx.current_version_str = ctx.current_version.ToString(); | |
769 ctx.new_version = ChromeVersion::FromString(version.GetString()); | |
770 ctx.new_version_str = ctx.new_version.ToString(); | |
771 | |
772 return UpdateVersionIfMatch(target_file, &ctx); | |
773 } | |
774 | |
775 } // namespace upgrade_test | 760 } // namespace upgrade_test |
OLD | NEW |