blob: 91987207d30e3296d0dc24e7369a67c0b22871ac [file] [log] [blame]
Koushik K. Dutta6060e5c2010-02-11 22:27:06 -08001#include <ctype.h>
2#include <errno.h>
3#include <fcntl.h>
4#include <getopt.h>
5#include <limits.h>
6#include <linux/input.h>
7#include <stdio.h>
8#include <stdlib.h>
9#include <string.h>
10#include <sys/reboot.h>
11#include <sys/types.h>
12#include <time.h>
13#include <unistd.h>
14
Koushik K. Duttae9234872010-02-12 00:43:24 -080015#include <sys/wait.h>
16#include <sys/limits.h>
17#include <dirent.h>
Koushik K. Dutta49f56892010-02-25 14:51:05 -080018#include <sys/stat.h>
Koushik K. Duttae9234872010-02-12 00:43:24 -080019
Koushik K. Dutta33370db2010-02-25 11:39:07 -080020#include <signal.h>
21#include <sys/wait.h>
22
Koushik K. Dutta6060e5c2010-02-11 22:27:06 -080023#include "bootloader.h"
24#include "common.h"
25#include "cutils/properties.h"
26#include "firmware.h"
27#include "install.h"
28#include "minui/minui.h"
29#include "minzip/DirUtil.h"
30#include "roots.h"
31#include "recovery_ui.h"
32
Koushik K. Duttaf68aaaf2010-03-07 13:39:21 -080033#include "commands.h"
34#include "amend/amend.h"
35
Koushik K. Duttaa85d7cc2010-03-12 17:00:58 -080036#include "mtdutils/dump_image.h"
37#include "../../external/yaffs2/yaffs2/utils/mkyaffs2image.h"
38
Koushik K. Dutta6060e5c2010-02-11 22:27:06 -080039int signature_check_enabled = 1;
40int script_assert_enabled = 1;
Koushik K. Duttabcdd0032010-02-21 21:10:25 -080041static const char *SDCARD_PACKAGE_FILE = "SDCARD:update.zip";
Koushik K. Dutta6060e5c2010-02-11 22:27:06 -080042
43void
44toggle_signature_check()
45{
46 signature_check_enabled = !signature_check_enabled;
47 ui_print("Signature Check: %s\n", signature_check_enabled ? "Enabled" : "Disabled");
48}
49
50void toggle_script_asserts()
51{
52 script_assert_enabled = !script_assert_enabled;
Koushik K. Duttae9234872010-02-12 00:43:24 -080053 ui_print("Script Asserts: %s\n", script_assert_enabled ? "Enabled" : "Disabled");
54}
55
Koushik K. Duttaea46fe22010-03-08 02:58:04 -080056int install_zip(const char* packagefilepath)
Koushik K. Duttae9234872010-02-12 00:43:24 -080057{
Koushik K. Duttabcdd0032010-02-21 21:10:25 -080058 ui_print("\n-- Installing: %s\n", packagefilepath);
59 set_sdcard_update_bootloader_message();
60 int status = install_package(packagefilepath);
Koushik K. Dutta99fb6fe2010-03-03 00:42:58 -080061 ui_reset_progress();
Koushik K. Duttabcdd0032010-02-21 21:10:25 -080062 if (status != INSTALL_SUCCESS) {
63 ui_set_background(BACKGROUND_ICON_ERROR);
64 ui_print("Installation aborted.\n");
Koushik K. Duttaea46fe22010-03-08 02:58:04 -080065 return 1;
Koushik K. Dutta79ce82c2010-02-25 12:03:17 -080066 }
67 if (firmware_update_pending()) {
68 ui_print("\nReboot via menu to complete\ninstallation.\n");
Koushik K. Dutta001c5b52010-02-25 14:53:57 -080069 }
Koushik K. Dutta001c5b52010-02-25 14:53:57 -080070 ui_set_background(BACKGROUND_ICON_NONE);
Koushik K. Dutta99fb6fe2010-03-03 00:42:58 -080071 ui_print("\nInstall from sdcard complete.\n");
Koushik K. Duttaea46fe22010-03-08 02:58:04 -080072 return 0;
Koushik K. Duttabcdd0032010-02-21 21:10:25 -080073}
74
75char* INSTALL_MENU_ITEMS[] = { "apply sdcard:update.zip",
76 "choose zip from sdcard",
77 "toggle signature verification",
78 "toggle script asserts",
79 NULL };
80#define ITEM_APPLY_SDCARD 0
81#define ITEM_CHOOSE_ZIP 1
82#define ITEM_SIG_CHECK 2
83#define ITEM_ASSERTS 3
84
85void show_install_update_menu()
86{
87 static char* headers[] = { "Apply update from .zip file on SD card",
88 "",
89 NULL
90 };
91 for (;;)
92 {
93 int chosen_item = get_menu_selection(headers, INSTALL_MENU_ITEMS, 0);
94 switch (chosen_item)
95 {
96 case ITEM_ASSERTS:
97 toggle_script_asserts();
98 break;
99 case ITEM_SIG_CHECK:
100 toggle_signature_check();
101 break;
102 case ITEM_APPLY_SDCARD:
103 install_zip(SDCARD_PACKAGE_FILE);
104 break;
105 case ITEM_CHOOSE_ZIP:
106 show_choose_zip_menu();
107 break;
108 default:
109 return;
110 }
111
112 }
113}
114
Koushik K. Dutta49f56892010-02-25 14:51:05 -0800115char** gather_files(const char* directory, const char* fileExtensionOrDirectory, int* numFiles)
Koushik K. Duttabcdd0032010-02-21 21:10:25 -0800116{
Koushik K. Duttae9234872010-02-12 00:43:24 -0800117 char path[PATH_MAX] = "";
118 DIR *dir;
119 struct dirent *de;
120 int total = 0;
121 int i;
122 char** files;
Koushik K. Dutta001c5b52010-02-25 14:53:57 -0800123 int pass;
124 *numFiles = 0;
125 int dirLen = strlen(directory);
Koushik K. Duttae9234872010-02-12 00:43:24 -0800126
Koushik K. Duttabcdd0032010-02-21 21:10:25 -0800127 dir = opendir(directory);
128 if (dir == NULL) {
129 ui_print("Couldn't open directory.\n");
130 return NULL;
131 }
132
Koushik K. Dutta001c5b52010-02-25 14:53:57 -0800133 int extension_length;
134 if (fileExtensionOrDirectory != NULL)
135 extension_length = strlen(fileExtensionOrDirectory);
Koushik K. Duttabcdd0032010-02-21 21:10:25 -0800136
Koushik K. Dutta001c5b52010-02-25 14:53:57 -0800137 int isCounting = 1;
138 i = 0;
139 for (pass = 0; pass < 2; pass++) {
140 while ((de=readdir(dir)) != NULL) {
141 // skip hidden files
142 if (de->d_name[0] == '.')
143 continue;
144
145 // NULL means that we are gathering directories, so skip this
146 if (fileExtensionOrDirectory != NULL)
147 {
148 // make sure that we can have the desired extension (prevent seg fault)
149 if (strlen(de->d_name) < extension_length)
150 continue;
151 // compare the extension
152 if (strcmp(de->d_name + strlen(de->d_name) - extension_length, fileExtensionOrDirectory) != 0)
153 continue;
154 }
155 else
156 {
157 struct stat info;
158 char* fullFileName = (char*)malloc(strlen(de->d_name) + dirLen + 1);
159 strcpy(fullFileName, directory);
160 strcat(fullFileName, de->d_name);
161 stat(fullFileName, &info);
162 free(fullFileName);
163 // make sure it is a directory
164 if (!(S_ISDIR(info.st_mode)))
165 continue;
166 }
167
168 if (pass == 0)
169 {
170 total++;
171 continue;
172 }
173
Koushik K. Dutta49f56892010-02-25 14:51:05 -0800174 files[i] = (char*) malloc(dirLen + strlen(de->d_name) + 2);
175 strcpy(files[i], directory);
176 strcat(files[i], de->d_name);
Koushik K. Dutta001c5b52010-02-25 14:53:57 -0800177 if (fileExtensionOrDirectory == NULL)
178 strcat(files[i], "/");
179 i++;
180 }
181 if (pass == 1)
182 break;
183 if (total == 0)
184 break;
185 rewinddir(dir);
186 *numFiles = total;
187 files = (char**) malloc((total+1)*sizeof(char*));
188 files[total]=NULL;
189 }
Koushik K. Dutta49f56892010-02-25 14:51:05 -0800190
191 if(closedir(dir) < 0) {
192 LOGE("Failed to close directory.");
Koushik K. Duttabcdd0032010-02-21 21:10:25 -0800193 }
194
195 if (total==0) {
Koushik K. Duttabcdd0032010-02-21 21:10:25 -0800196 return NULL;
197 }
198
Koushik K. Dutta001c5b52010-02-25 14:53:57 -0800199 return files;
Koushik K. Dutta49f56892010-02-25 14:51:05 -0800200}
Koushik K. Duttabcdd0032010-02-21 21:10:25 -0800201
Koushik K. Dutta49f56892010-02-25 14:51:05 -0800202void free_string_array(char** array)
203{
Koushik K. Dutta001c5b52010-02-25 14:53:57 -0800204 char* cursor = array[0];
205 int i = 0;
206 while (cursor != NULL)
207 {
208 free(cursor);
209 cursor = array[++i];
210 }
211 free(array);
Koushik K. Dutta49f56892010-02-25 14:51:05 -0800212}
Koushik K. Duttabcdd0032010-02-21 21:10:25 -0800213
Koushik K. Dutta49f56892010-02-25 14:51:05 -0800214// pass in NULL for fileExtensionOrDirectory and you will get a directory chooser
215char* choose_file_menu(const char* directory, const char* fileExtensionOrDirectory, const char* headers[])
216{
217 char path[PATH_MAX] = "";
218 DIR *dir;
219 struct dirent *de;
220 int numFiles = 0;
Koushik K. Dutta001c5b52010-02-25 14:53:57 -0800221 int numDirs = 0;
Koushik K. Dutta49f56892010-02-25 14:51:05 -0800222 int i;
Koushik K. Duttabcdd0032010-02-21 21:10:25 -0800223
Koushik K. Dutta001c5b52010-02-25 14:53:57 -0800224 int dir_len = strlen(directory);
Koushik K. Duttabcdd0032010-02-21 21:10:25 -0800225
Koushik K. Dutta001c5b52010-02-25 14:53:57 -0800226 char** files = gather_files(directory, fileExtensionOrDirectory, &numFiles);
227 char** dirs;
228 if (fileExtensionOrDirectory != NULL)
229 dirs = gather_files(directory, NULL, &numDirs);
230 int total = numDirs + numFiles;
231 if (total == 0)
232 {
233 ui_print("No files found.\n");
234 return NULL;
235 }
236 char** list = (char**) malloc((total + 1) * sizeof(char*));
237 list[total] = NULL;
Koushik K. Duttabcdd0032010-02-21 21:10:25 -0800238
Koushik K. Dutta49f56892010-02-25 14:51:05 -0800239
Koushik K. Dutta001c5b52010-02-25 14:53:57 -0800240 for (i = 0 ; i < numDirs; i++)
241 {
242 list[i] = strdup(dirs[i] + dir_len);
Koushik K. Duttabcdd0032010-02-21 21:10:25 -0800243 }
244
Koushik K. Dutta001c5b52010-02-25 14:53:57 -0800245 for (i = 0 ; i < numFiles; i++)
246 {
247 list[numDirs + i] = strdup(files[i] + dir_len);
Koushik K. Duttabcdd0032010-02-21 21:10:25 -0800248 }
249
Koushik K. Dutta981b0cd2010-02-22 08:53:34 -0800250 for (;;)
251 {
252 int chosen_item = get_menu_selection(headers, list, 0);
253 if (chosen_item == GO_BACK)
254 break;
Koushik K. Dutta001c5b52010-02-25 14:53:57 -0800255 if (chosen_item < numDirs)
256 {
257 char* subret = choose_file_menu(dirs[chosen_item], fileExtensionOrDirectory, headers);
258 if (subret != NULL)
259 return subret;
260 continue;
261 }
Koushik K. Dutta981b0cd2010-02-22 08:53:34 -0800262 static char ret[PATH_MAX];
Koushik K. Dutta49f56892010-02-25 14:51:05 -0800263 strcpy(ret, files[chosen_item - numDirs]);
Koushik K. Dutta001c5b52010-02-25 14:53:57 -0800264 ui_print("File chosen: %s\n", ret);
Koushik K. Dutta981b0cd2010-02-22 08:53:34 -0800265 return ret;
266 }
267 return NULL;
Koushik K. Duttabcdd0032010-02-21 21:10:25 -0800268}
269
270void show_choose_zip_menu()
271{
Koushik K. Duttae9234872010-02-12 00:43:24 -0800272 if (ensure_root_path_mounted("SDCARD:") != 0) {
273 LOGE ("Can't mount /sdcard\n");
274 return;
275 }
276
Koushik K. Duttabcdd0032010-02-21 21:10:25 -0800277 static char* headers[] = { "Choose a zip to apply",
278 "",
279 NULL
280 };
281
282 char* file = choose_file_menu("/sdcard/", ".zip", headers);
283 if (file == NULL)
284 return;
285 char sdcard_package_file[1024];
286 strcpy(sdcard_package_file, "SDCARD:");
287 strcat(sdcard_package_file, file + strlen("/sdcard/"));
288 install_zip(sdcard_package_file);
289}
290
Koushik K. Dutta33370db2010-02-25 11:39:07 -0800291// This was pulled from bionic: The default system command always looks
292// for shell in /system/bin/sh. This is bad.
293#define _PATH_BSHELL "/sbin/sh"
294#define system recovery_system
295extern char **environ;
296int
297system(const char *command)
298{
299 pid_t pid;
Koushik K. Dutta001c5b52010-02-25 14:53:57 -0800300 sig_t intsave, quitsave;
301 sigset_t mask, omask;
302 int pstat;
303 char *argp[] = {"sh", "-c", NULL, NULL};
Koushik K. Dutta33370db2010-02-25 11:39:07 -0800304
Koushik K. Dutta001c5b52010-02-25 14:53:57 -0800305 if (!command) /* just checking... */
306 return(1);
Koushik K. Dutta33370db2010-02-25 11:39:07 -0800307
Koushik K. Dutta001c5b52010-02-25 14:53:57 -0800308 argp[2] = (char *)command;
Koushik K. Dutta33370db2010-02-25 11:39:07 -0800309
Koushik K. Dutta001c5b52010-02-25 14:53:57 -0800310 sigemptyset(&mask);
311 sigaddset(&mask, SIGCHLD);
312 sigprocmask(SIG_BLOCK, &mask, &omask);
313 switch (pid = vfork()) {
314 case -1: /* error */
315 sigprocmask(SIG_SETMASK, &omask, NULL);
316 return(-1);
317 case 0: /* child */
318 sigprocmask(SIG_SETMASK, &omask, NULL);
319 execve(_PATH_BSHELL, argp, environ);
Koushik K. Dutta33370db2010-02-25 11:39:07 -0800320 _exit(127);
321 }
322
Koushik K. Dutta001c5b52010-02-25 14:53:57 -0800323 intsave = (sig_t) bsd_signal(SIGINT, SIG_IGN);
324 quitsave = (sig_t) bsd_signal(SIGQUIT, SIG_IGN);
325 pid = waitpid(pid, (int *)&pstat, 0);
326 sigprocmask(SIG_SETMASK, &omask, NULL);
327 (void)bsd_signal(SIGINT, intsave);
328 (void)bsd_signal(SIGQUIT, quitsave);
329 return (pid == -1 ? -1 : pstat);
Koushik K. Dutta33370db2010-02-25 11:39:07 -0800330}
331
Koushik K. Duttaa85d7cc2010-03-12 17:00:58 -0800332int print_and_error(char* message)
333{
334 ui_print(message);
335 return 1;
336}
337
Koushik K. Duttaa9483082010-03-07 21:47:41 -0800338int do_nandroid_backup(char* backup_name)
Koushik K. Duttabcdd0032010-02-21 21:10:25 -0800339{
Koushik K. Dutta60d7ee02010-03-07 22:16:55 -0800340 if (ensure_root_path_mounted("SDCARD:") != 0) {
341 LOGE ("Can't mount /sdcard\n");
342 return 1;
343 }
Koushik K. Duttaa85d7cc2010-03-12 17:00:58 -0800344 if (ensure_root_path_mounted("SYSTEM:") != 0) {
345 LOGE ("Can't mount /system\n");
346 return 1;
Koushik K. Dutta225c6b42010-02-21 22:02:24 -0800347 }
Koushik K. Duttaa85d7cc2010-03-12 17:00:58 -0800348 if (ensure_root_path_mounted("DATA:") != 0) {
349 LOGE ("Can't mount /data\n");
350 return 1;
351 }
352 if (ensure_root_path_mounted("CACHE:") != 0) {
353 LOGE ("Can't mount /cache\n");
354 return 1;
355 }
356
357 struct timeval tp;
358 gettimeofday(&tp, NULL);
359
360 char backupdir[PATH_MAX];
361 char tmp[PATH_MAX];
362 if (NULL != backup_name)
363 sprintf(backupdir, "/sdcard/clockworkmod/backup/%s", backup_name);
364 else
365 sprintf(backupdir, "/sdcard/clockworkmod/backup/%d", tp.tv_sec);
366
367 sprintf(tmp, "mkdir -p %s", backupdir);
368 system(tmp);
369
370 int ret;
371 ui_print("Backing up boot...\n");
372 sprintf(tmp, "%s/%s", backupdir, "boot.img");
373 ret = dump_image("boot", tmp, NULL);
374 if (0 != ret)
375 return print_and_error("Error while dumping boot image!\n");
376
377 ui_print("Backing up system...\n");
378 sprintf(tmp, "%s/%s", backupdir, "system.img");
379 ret = mkyaffs2image("/system", tmp, 0, NULL);
380 ensure_root_path_unmounted("SYSTEM:");
381 if (0 != ret)
382 return print_and_error("Error while making a yaffs2 image of system!\n");
383
384 ui_print("Backing up data...\n");
385 sprintf(tmp, "%s/%s", backupdir, "data.img");
386 ret = mkyaffs2image("/data", tmp, 0, NULL);
387 ensure_root_path_unmounted("DATA:");
388 if (0 != ret)
389 return print_and_error("Error while making a yaffs2 image of data!\n");
390
391 ui_print("Backing up cache...\n");
392 sprintf(tmp, "%s/%s", backupdir, "cache.img");
393 ret = mkyaffs2image("/cache", tmp, 0, NULL);
394 ensure_root_path_unmounted("CACHE:");
395 if (0 != ret)
396 return print_and_error("Error while making a yaffs2 image of cache!\n");
397
398 sprintf(tmp, "md5sum %s/*img > %s/nandroid.md5", backupdir, backupdir);
399 system(tmp);
400
401 return 0;
Koushik K. Duttaa9483082010-03-07 21:47:41 -0800402}
403
404int do_nandroid_restore(char* backup_path)
405{
Koushik K. Dutta60d7ee02010-03-07 22:16:55 -0800406 if (ensure_root_path_mounted("SDCARD:") != 0) {
407 LOGE ("Can't mount /sdcard\n");
408 return 1;
409 }
410
Koushik K. Duttaa9483082010-03-07 21:47:41 -0800411 char* command[PATH_MAX];
412 sprintf(command, "nandroid-mobile.sh restore %s", backup_path);
413 ui_print("Performing restore...\n");
414 int ret = system(command);
415 if (ret != 0)
416 {
417 ui_print("Error while restoring!\n");
418 return ret;
419 }
420 ui_print("Restore complete.\n");
421 return ret;
Koushik K. Duttabcdd0032010-02-21 21:10:25 -0800422}
423
424void show_nandroid_restore_menu()
425{
Koushik K. Duttabcdd0032010-02-21 21:10:25 -0800426 static char* headers[] = { "Choose an image to restore",
427 "",
428 NULL
429 };
Koushik K. Duttae9234872010-02-12 00:43:24 -0800430
Koushik K. Dutta49f56892010-02-25 14:51:05 -0800431 char* file = choose_file_menu("/sdcard/clockworkmod/backup/", NULL, headers);
Koushik K. Duttabcdd0032010-02-21 21:10:25 -0800432 if (file == NULL)
433 return;
Koushik K. Duttaa9483082010-03-07 21:47:41 -0800434 do_nandroid_restore(file);
Koushik K. Dutta03173782010-02-26 14:14:23 -0800435}
436
437void do_mount_usb_storage()
438{
439 system("echo /dev/block/mmcblk0 > /sys/devices/platform/usb_mass_storage/lun0/file");
440 static char* headers[] = { "USB Mass Storage device",
441 "Leaving this menu unmount",
442 "your SD card from your PC.",
443 "",
444 NULL
445 };
446
447 static char* list[] = { "Unmount", NULL };
448
449 for (;;)
450 {
451 int chosen_item = get_menu_selection(headers, list, 0);
452 if (chosen_item == GO_BACK || chosen_item == 0)
453 break;
454 }
455
Koushik K. Duttae81cb752010-02-26 17:44:33 -0800456 system("echo '' > /sys/devices/platform/usb_mass_storage/lun0/file");
Koushik K. Dutta03173782010-02-26 14:14:23 -0800457 system("echo 0 > /sys/devices/platform/usb_mass_storage/lun0/enable");
Koushik K. Duttae81cb752010-02-26 17:44:33 -0800458}
Koushik K. Duttaf68aaaf2010-03-07 13:39:21 -0800459
Koushik K. Dutta72a1db62010-03-07 14:10:26 -0800460#define EXTENDEDCOMMAND_SCRIPT "/cache/recovery/extendedcommand"
461
462int extendedcommand_file_exists()
Koushik K. Duttaf68aaaf2010-03-07 13:39:21 -0800463{
Koushik K. Duttaf68aaaf2010-03-07 13:39:21 -0800464 struct stat file_info;
Koushik K. Dutta72a1db62010-03-07 14:10:26 -0800465 return 0 == stat(EXTENDEDCOMMAND_SCRIPT, &file_info);
466}
467
Koushik K. Dutta3836f722010-03-11 22:17:43 -0800468int run_script_from_buffer(char* script_data, int script_len, char* filename)
Koushik K. Dutta72a1db62010-03-07 14:10:26 -0800469{
Koushik K. Duttaf68aaaf2010-03-07 13:39:21 -0800470 /* Parse the script. Note that the script and parse tree are never freed.
471 */
472 const AmCommandList *commands = parseAmendScript(script_data, script_len);
473 if (commands == NULL) {
474 printf("Syntax error in update script\n");
475 return 1;
476 } else {
Koushik K. Dutta72a1db62010-03-07 14:10:26 -0800477 printf("Parsed %.*s\n", script_len, filename);
Koushik K. Duttaf68aaaf2010-03-07 13:39:21 -0800478 }
479
480 /* Execute the script.
481 */
482 int ret = execCommandList((ExecContext *)1, commands);
483 if (ret != 0) {
484 int num = ret;
485 char *line, *next = script_data;
486 while (next != NULL && ret-- > 0) {
487 line = next;
488 next = memchr(line, '\n', script_data + script_len - line);
489 if (next != NULL) *next++ = '\0';
490 }
491 printf("Failure at line %d:\n%s\n", num, next ? line : "(not found)");
492 return 1;
493 }
494
495 return 0;
496}
Koushik K. Dutta72a1db62010-03-07 14:10:26 -0800497
Koushik K. Dutta3836f722010-03-11 22:17:43 -0800498int run_script(char* filename, int delete_file)
499{
500 struct stat file_info;
501 if (0 != stat(filename, &file_info)) {
502 printf("Error executing stat on file: %s\n", filename);
503 return 1;
504 }
505
506 int script_len = file_info.st_size;
507 char* script_data = (char*)malloc(script_len);
508 FILE *file = fopen(filename, "rb");
509 fread(script_data, script_len, 1, file);
510 fclose(file);
511 if (delete_file)
512 remove(filename);
513
514 return run_script_from_buffer(script_data, script_len, filename);
515}
516
Koushik K. Dutta72a1db62010-03-07 14:10:26 -0800517int run_and_remove_extendedcommand()
518{
Koushik K. Dutta3a25cf52010-03-08 19:22:41 -0800519 int i = 0;
520 for (i = 20; i > 0; i--) {
521 ui_print("Waiting for SD Card to mount (%ds)\n", i);
522 if (ensure_root_path_mounted("SDCARD:") == 0) {
523 ui_print("SD Card mounted...\n");
524 break;
525 }
526 sleep(1);
527 }
528 if (i == 0) {
529 ui_print("Timed out waiting for SD card... continuing anyways.");
530 }
531
Koushik K. Dutta3836f722010-03-11 22:17:43 -0800532 return run_script(EXTENDEDCOMMAND_SCRIPT, 1);
Koushik K. Dutta72a1db62010-03-07 14:10:26 -0800533}
534
535int amend_main(int argc, char** argv)
536{
537 if (argc != 2)
538 {
539 printf("Usage: amend <script>\n");
540 return 0;
541 }
542
543 RecoveryCommandContext ctx = { NULL };
544 if (register_update_commands(&ctx)) {
545 LOGE("Can't install update commands\n");
546 }
Koushik K. Dutta3836f722010-03-11 22:17:43 -0800547 return run_script(argv[1], 0);
Koushik K. Dutta5306db52010-03-08 14:09:35 -0800548}