Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(325)

Side by Side Diff: chrome/installer/test/alternate_version_generator_main.cc

Issue 6546027: Add a --force command line option to the alternate_version_generator to allow... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // This file provides a command-line interface to 5 // This file provides a command-line interface to
6 // upgrade_test::GenerateAlternateVersion(). 6 // upgrade_test::GenerateAlternateVersion().
7 7
8 #include <cstdio> 8 #include <cstdio>
9 #include <cstdlib> 9 #include <cstdlib>
10 10
11 #include "base/at_exit.h" 11 #include "base/at_exit.h"
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/file_path.h" 14 #include "base/file_path.h"
15 #include "base/file_util.h" 15 #include "base/file_util.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/path_service.h" 17 #include "base/path_service.h"
18 #include "chrome/installer/test/alternate_version_generator.h" 18 #include "chrome/installer/test/alternate_version_generator.h"
19 19
20 namespace { 20 namespace {
21 21
22 const wchar_t kDefaultMiniInstallerFile[] = L"mini_installer.exe"; 22 const wchar_t kDefaultMiniInstallerFile[] = L"mini_installer.exe";
23 const wchar_t kDefaultOutPath[] = L"mini_installer_new.exe"; 23 const wchar_t kDefaultOutPath[] = L"mini_installer_new.exe";
24 24
25 namespace switches { 25 namespace switches {
26 26
27 const char kForce[] = "force";
27 const char kHelp[] = "help"; 28 const char kHelp[] = "help";
28 const char kMiniInstaller[] = "mini_installer"; 29 const char kMiniInstaller[] = "mini_installer";
29 const char kOut[] = "out"; 30 const char kOut[] = "out";
30 const char kPrevious[] = "previous"; 31 const char kPrevious[] = "previous";
31 32
32 } // namespace switches 33 } // namespace switches
33 34
34 namespace errors { 35 namespace errors {
35 36
36 enum ErrorCode { 37 enum ErrorCode {
(...skipping 30 matching lines...) Expand all
67 if (!detail.empty()) 68 if (!detail.empty())
68 fwprintf(stderr, L" (%s)\n", detail.c_str()); 69 fwprintf(stderr, L" (%s)\n", detail.c_str());
69 else 70 else
70 fwprintf(stderr, L"\n"); 71 fwprintf(stderr, L"\n");
71 } 72 }
72 73
73 fwprintf(stderr, 74 fwprintf(stderr,
74 L"Usage: %s [ OPTIONS ]\n" 75 L"Usage: %s [ OPTIONS ]\n"
75 L" Where OPTIONS is one or more of:\n" 76 L" Where OPTIONS is one or more of:\n"
76 L" --help Display this help message.\n" 77 L" --help Display this help message.\n"
78 L" --force Overwrite any existing output files.\n"
77 L" --mini_installer=SRC_PATH Path to mini_installer.exe. Default value is\n" 79 L" --mini_installer=SRC_PATH Path to mini_installer.exe. Default value is\n"
78 L" \"mini_installer.exe\" in the same directory as\n" 80 L" \"mini_installer.exe\" in the same directory as\n"
79 L" this program.\n" 81 L" this program.\n"
80 L" --out=OUT_PATH Path to output file. Default value is\n" 82 L" --out=OUT_PATH Path to output file. Default value is\n"
81 L" \"mini_installer_new.exe\" in the current\n" 83 L" \"mini_installer_new.exe\" in the current\n"
82 L" directory.\n" 84 L" directory.\n"
83 L" --previous OUT_PATH will have a lower version than\n" 85 L" --previous OUT_PATH will have a lower version than\n"
84 L" SRC_PATH. By default, OUT_PATH will have a\n" 86 L" SRC_PATH. By default, OUT_PATH will have a\n"
85 L" higher version.\n" 87 L" higher version.\n"
86 L" --7za_path=7ZA_PATH Path to the directory holding 7za.exe. Defaults\n" 88 L" --7za_path=7ZA_PATH Path to the directory holding 7za.exe. Defaults\n"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 } 141 }
140 142
141 if (!file_util::PathExists(mini_installer)) { 143 if (!file_util::PathExists(mini_installer)) {
142 DumpUsage(*cmd_line, errors::MINI_INSTALLER_NOT_FOUND, 144 DumpUsage(*cmd_line, errors::MINI_INSTALLER_NOT_FOUND,
143 mini_installer.value()); 145 mini_installer.value());
144 return EXIT_FAILURE; 146 return EXIT_FAILURE;
145 } 147 }
146 148
147 FilePath out; 149 FilePath out;
148 GetOutPath(*cmd_line, &out); 150 GetOutPath(*cmd_line, &out);
149 if (file_util::PathExists(out)) { 151 if (!cmd_line->HasSwitch(switches::kForce) && file_util::PathExists(out)) {
150 DumpUsage(*cmd_line, errors::OUT_FILE_EXISTS, out.value()); 152 DumpUsage(*cmd_line, errors::OUT_FILE_EXISTS, out.value());
151 return EXIT_FAILURE; 153 return EXIT_FAILURE;
152 } 154 }
153 155
154 upgrade_test::Direction direction = GetDirection(*cmd_line); 156 upgrade_test::Direction direction = GetDirection(*cmd_line);
155 157
156 std::wstring original_version; 158 std::wstring original_version;
157 std::wstring new_version; 159 std::wstring new_version;
158 160
159 if (upgrade_test::GenerateAlternateVersion(mini_installer, out, direction, 161 if (upgrade_test::GenerateAlternateVersion(mini_installer, out, direction,
160 &original_version, &new_version)) { 162 &original_version, &new_version)) {
161 fwprintf(stdout, L"Generated version %s from version %s\n", 163 fwprintf(stdout, L"Generated version %s from version %s\n",
162 new_version.c_str(), original_version.c_str()); 164 new_version.c_str(), original_version.c_str());
163 return EXIT_SUCCESS; 165 return EXIT_SUCCESS;
164 } 166 }
165 167
166 DumpUsage(*cmd_line, errors::GENERATION_FAILED, mini_installer.value()); 168 DumpUsage(*cmd_line, errors::GENERATION_FAILED, mini_installer.value());
167 return EXIT_FAILURE; 169 return EXIT_FAILURE;
168 } 170 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698