Skip to contentSkip to conversation

wipe-sysroot: explain what is being deleted and require confirmation

PATCH In review Ross Burton 2 participants 4 messages Nov 1, 2013 – Nov 2, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wipe-sysroot: explain what is being deleted and require confirmation

Instead of rushing into deleting entire directory trees without any warning, print the directories and files that will be deleted and require confirmation from the user (via --force) that they want files to be deleted.

[ YOCTO #5423 ]

---
 scripts/wipe-sysroot |   27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)
scripts/wipe-sysroot +18 -9
index 7ca26fe..306c877 100755
@@ -33,14 +33,23 @@ if [ -z "$SSTATE_MANIFESTS" -o -z "$STAGING_DIR" -o -z "$STAMPS_DIR" ]; then
     exit 1
 fi
 
-# The sysroots themselves
-rm -rf $STAGING_DIR
+echo "Will delete $STAGING_DIR."
+echo "Will also delete selected stamps from $SSTATE_MANIFESTS and $STAMPS_DIR."
 
-# The stamps that said the sysroot was populated
-rm -rf $STAMPS_DIR/*/*/*.do_populate_sysroot.*
-rm -rf $STAMPS_DIR/*/*/*.do_populate_sysroot_setscene.*
-rm -rf $STAMPS_DIR/*/*/*.do_packagedata.*
-rm -rf $STAMPS_DIR/*/*/*.do_packagedata_setscene.*
+if [ "$1" = "--force" ]; then
+    echo "Deleting..."
 
-# The sstate manifests
-rm -rf $SSTATE_MANIFESTS/manifest-*.populate-sysroot
+    # The sysroots themselves
+    rm -rf $STAGING_DIR
+
+    # The stamps that said the sysroot was populated
+    rm -rf $STAMPS_DIR/*/*/*.do_populate_sysroot.*
+    rm -rf $STAMPS_DIR/*/*/*.do_populate_sysroot_setscene.*
+    rm -rf $STAMPS_DIR/*/*/*.do_packagedata.*
+    rm -rf $STAMPS_DIR/*/*/*.do_packagedata_setscene.*
+
+    # The sstate manifests
+    rm -rf $SSTATE_MANIFESTS/manifest-*.populate-sysroot
+else
+    echo "\nThis was a dry-run.  Run with --force to delete the files."
+fi
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 3 lines · Ross Burton

Instead of rushing into deleting entire directory trees without any warning, print the directories and files that will be deleted and require confirmation from the user (via --force) that they want files to be deleted.

"--force" seems like a bit of an odd name for an argument that you have to supply in order for the script to do anything useful. Why would the user be running a script named "wipe-sysroot" if they didn't want the sysroot to be deleted?

p.

#2 lore raw
Quoted 9 lines · Phil Blundell
Quoted 3 lines · Ross Burton

Instead of rushing into deleting entire directory trees without any warning, print the directories and files that will be deleted and require confirmation from the user (via --force) that they want files to be deleted.

"--force" seems like a bit of an odd name for an argument that you have to supply in order for the script to do anything useful. Why would the user be running a script named "wipe-sysroot" if they didn't want the sysroot to be deleted?

I'm open to alternative wording but the essence is "don't delete stuff if the user does something like wipe-sysroot --help".

Ross

#3 lore raw
Quoted 6 lines · Ross
Quoted 5 lines · Phil Blundell
Quoted 3 lines · Ross Burton

Instead of rushing into deleting entire directory trees without any warning, print the directories and files that will be deleted and require confirmation from the user (via --force) that they want files to be deleted.

Quoted 7 lines
Quoted 4 lines

"--force" seems like a bit of an odd name for an argument that you have to supply in order for the script to do anything useful. Why would the user be running a script named "wipe-sysroot" if they didn't want the sysroot to be deleted?

I'm open to alternative wording but the essence is "don't delete stuff if the user does something like wipe-sysroot --help".

How about:

if [ $# -gt 0 ]; then
echo "Usage: $0" >&2
exit 1
fi

p.