summaryrefslogtreecommitdiffstats
path: root/rbutil/mknwzboot/main.c
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2017-09-17 22:16:50 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2017-09-17 22:16:50 +0200
commit7de1d8b70ff3e062f394dd4ab23c0bf51e1cc2c9 (patch)
tree5988df37e1cc3b83ecd7f1aa170bc60665ce72d9 /rbutil/mknwzboot/main.c
parentac59669d460397b628f08dfcc7b6df6eec272091 (diff)
downloadrockbox-7de1d8b70ff3e062f394dd4ab23c0bf51e1cc2c9.tar.gz
rockbox-7de1d8b70ff3e062f394dd4ab23c0bf51e1cc2c9.tar.bz2
rockbox-7de1d8b70ff3e062f394dd4ab23c0bf51e1cc2c9.zip
mknwzboot: add support for uninstallation
There is not need for a bootloader file to create an uninstall firmware so one needs to provide a model. Also cleanup the install script a bit by factoring message into a function, also print them to the log so that the user can report what was printed on the screen easily. The uninstall script is quite trivial, it remounts the rootfs and restores the backed up OF to its right place. Change-Id: I1f5c0efeb965fdc7fe17f45c2753c0f52c34f7f1
Diffstat (limited to 'rbutil/mknwzboot/main.c')
-rw-r--r--rbutil/mknwzboot/main.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/rbutil/mknwzboot/main.c b/rbutil/mknwzboot/main.c
index a36c24eaf5..491a18043b 100644
--- a/rbutil/mknwzboot/main.c
+++ b/rbutil/mknwzboot/main.c
@@ -34,6 +34,8 @@ static void usage(void)
printf(" -b <file> Set boot file\n");
printf(" -d/--debug Enable debug output\n");
printf(" -x Dump device informations\n");
+ printf(" -u Create uninstall update\n");
+ printf(" -m <model> Specify model\n");
exit(1);
}
@@ -42,6 +44,8 @@ int main(int argc, char *argv[])
char *outfile = NULL;
char *bootfile = NULL;
bool debug = false;
+ bool install = true;
+ const char *model = NULL;
if(argc == 1)
usage();
@@ -55,10 +59,12 @@ int main(int argc, char *argv[])
{"boot-file", required_argument, 0, 'b'},
{"debug", no_argument, 0, 'd'},
{"dev-info", no_argument, 0, 'x'},
+ {"uninstall", no_argument, 0, 'u'},
+ {"model", required_argument, 0, 'm'},
{0, 0, 0, 0}
};
- int c = getopt_long(argc, argv, "ho:b:dx", long_options, NULL);
+ int c = getopt_long(argc, argv, "ho:b:dxum:", long_options, NULL);
if(c == -1)
break;
switch(c)
@@ -77,6 +83,12 @@ int main(int argc, char *argv[])
break;
case 'x':
dump_nwz_dev_info("");
+ return 0;
+ case 'u':
+ install = false;
+ break;
+ case 'm':
+ model = optarg;
break;
default:
abort();
@@ -88,9 +100,14 @@ int main(int argc, char *argv[])
printf("You must specify an output file\n");
return 1;
}
- if(!bootfile)
+ if(install && !bootfile)
+ {
+ printf("You must specify a boot file for installation\n");
+ return 1;
+ }
+ if(!install && !model)
{
- printf("You must specify a boot file\n");
+ printf("You must provide a model for uninstallation\n");
return 1;
}
if(optind != argc)
@@ -99,7 +116,11 @@ int main(int argc, char *argv[])
return 1;
}
- int err = mknwzboot(bootfile, outfile, debug);
+ int err;
+ if(install)
+ err = mknwzboot(bootfile, outfile, debug);
+ else
+ err = mknwzboot_uninst(model, outfile, debug);
printf("Result: %d\n", err);
return err;
}