[PATCH openbmc 07/32] update: Add command line parsing to clean or preserve saved files

OpenBMC Patches openbmc-patches at stwcx.xyz
Sat Mar 5 23:29:58 AEDT 2016


From: "Milton D. Miller II" <miltonm at us.ibm.com>

Because update now returns to shutdown for the final halt or
reboot system call it does not need to handle systemd arguments.
Instead update is being invoked from multiple environments, and
further environments will need alternate behaviors.

Add a code to start parsing the command line.  Start wtih a flag
to clean the saved files at the end of the update process.

This will reclaim the space and prevent stale saved files
from being restored without requiring the calling script to
know the location of the saved files directory.

Parse true and complement actions in case we decide to change
the defaults later.

For now keep the user feature of calling update, flashing some
files by hand, then a final call to update with a possibly
empty image file will have the original saved files merged
into the rwfs.

Signed-off-by: Milton Miller <miltonm at us.ibm.com>
---
 .../obmc-phosphor-initfs/files/obmc-update.sh      | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
index 367c302..060073b 100755
--- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
+++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
@@ -59,6 +59,23 @@ rwdir=rw
 upper=$rwdir/cow
 save=save/${upper##*/}
 
+doclean=
+
+while test "$1" != "${1#-}"
+do
+	case "$1" in
+	--no-clean-saved-files)
+		doclean=
+		shift ;;
+	--clean-saved-files)
+		doclean=y
+		shift ;;
+	*)
+		echo 2>&1 "Unknown option $1"
+		exit 1 ;;
+	esac
+done
+
 if test -n "$rwfs" && test -s whitelist
 then
 
@@ -105,6 +122,11 @@ then
 	umount $rwdir
 fi
 
+if test "x$doclean" = xy
+then
+	rm -rf $save
+fi
+
 exit
 
 # NOT REACHED without edit
-- 
2.7.1




More information about the openbmc mailing list