From 7de1d8b70ff3e062f394dd4ab23c0bf51e1cc2c9 Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Sun, 17 Sep 2017 22:16:50 +0200 Subject: [PATCH] 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 --- rbutil/mknwzboot/Makefile | 9 +- rbutil/mknwzboot/install_script.sh | 51 +++++++---- rbutil/mknwzboot/main.c | 29 ++++++- rbutil/mknwzboot/mknwzboot.c | 60 +++++++++++++ rbutil/mknwzboot/mknwzboot.h | 1 + rbutil/mknwzboot/uninstall_script.sh | 122 +++++++++++++++++++++++++++ 6 files changed, 247 insertions(+), 25 deletions(-) create mode 100644 rbutil/mknwzboot/uninstall_script.sh diff --git a/rbutil/mknwzboot/Makefile b/rbutil/mknwzboot/Makefile index 9530ac369e..fd80106b83 100644 --- a/rbutil/mknwzboot/Makefile +++ b/rbutil/mknwzboot/Makefile @@ -18,7 +18,7 @@ OUTPUT = mknwzboot # inputs for lib UPGTOOLS_SOURCES = misc.c upg.c fwp.c mg.cpp md5.cpp -LIBSOURCES := mknwzboot.c install_script.c \ +LIBSOURCES := mknwzboot.c install_script.c uninstall_script.c \ $(addprefix $(UPGTOOLS_DIR),$(UPGTOOLS_SOURCES)) # inputs for binary only SOURCES := $(LIBSOURCES) main.c @@ -30,6 +30,9 @@ include ../libtools.make install_script.c install_script.h: install_script.sh $(BIN2C) $(BIN2C) install_script.sh install_script +uninstall_script.c uninstall_script.h: uninstall_script.sh $(BIN2C) + $(BIN2C) uninstall_script.sh uninstall_script + # explicit dependencies on install_script.{c,h} and mknwzboot.h -$(OBJDIR)mknwzboot.o: install_script.h install_script.c mknwzboot.h -$(OBJDIR)main.o: install_script.h install_script.c main.c mknwzboot.h +$(OBJDIR)mknwzboot.o: install_script.h install_script.c uninstall_script.h uninstall_script.c mknwzboot.h +$(OBJDIR)main.o: main.c mknwzboot.h diff --git a/rbutil/mknwzboot/install_script.sh b/rbutil/mknwzboot/install_script.sh index 18296d257e..76bd12c4d5 100644 --- a/rbutil/mknwzboot/install_script.sh +++ b/rbutil/mknwzboot/install_script.sh @@ -1,5 +1,11 @@ #!/bin/sh +# NOTE: busybox is using ash, a very posix and very pedantic shell, make sure +# you test your scripts with +# busybox sh -n