Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Fri 22 May 2015, 07:48
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Utilities
whiteout file utilities - 'lswhiteout' and 'rmdeadwhiteout'
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [3 Posts]  
Author Message
gyro

Joined: 28 Oct 2008
Posts: 724
Location: Brisbane, Australia

PostPosted: Tue 21 Apr 2015, 03:04    Post subject:  whiteout file utilities - 'lswhiteout' and 'rmdeadwhiteout'  

Here are a couple of scripts to help with whiteout files:

Edit: Uploaded new version of scripts. Changed output format to cope better with long lines (mavrothal ). See post below.

1) 'lswhiteout'
This script lists all ordinary ".wh." files, along with the file they cover (if it exists), and the layer in which the hidden file was found.
Example output:
Code:
# ./lswhiteout
Whiteout files in  /initrd/mnt/dev_save/puppy/tahr/tahrsave
/.wh.pinstall.sh
    covers  /pinstall.sh
    in  devx_tahr_6.0.2.sfs
It accepts a "-q" parameter which suppresses the heading line(s).
Code:
# ./lswhiteout -q
/.wh.pinstall.sh
    covers  /pinstall.sh
    in  devx_tahr_6.0.2.sfs

2) 'rmdeadwhiteout'
This is a clean-up script that removes all ordinary ".wh." files that don't cover any file in a lower layer. So they don't actually do anything in the current system, but can cause problems in the future if the file they are supposed to cover gets re-introduced into a lower layer.
Example output:
Code:
# ./rmdeadwhiteout
Searching whiteout files...
/root/.wh.zxzx.txt
    removed from  /initrd/mnt/dev_save/puppy/tahr/tahrsave
It accepts a "-q" parameter which suppresses all output.

Note: Both these scripts contain a 'find' command which can take a while to complete, so they each output a header line before the 'find' starts, to reassure the user that the script is functioning.

To use:
Dwonload the appropriate ".gz" file and move it to the directory you want to contain the utility.
Then gunzip the downloaded file.

gyro
lswhiteout.gz
Description  gunzip to produce the script file
gz

 Download 
Filename  lswhiteout.gz 
Filesize  904 Bytes 
Downloaded  22 Time(s) 
rmdeadwhiteout.gz
Description  gunzip to produce the script file
gz

 Download 
Filename  rmdeadwhiteout.gz 
Filesize  819 Bytes 
Downloaded  24 Time(s) 

Last edited by gyro on Tue 21 Apr 2015, 06:24; edited 2 times in total
Back to top
View user's profile Send private message 
mavrothal


Joined: 24 Aug 2009
Posts: 2259

PostPosted: Tue 21 Apr 2015, 04:30    Post subject:  

Very handy!
You might want to consider these changes
Code:
--- a/lswhiteout   2015-04-21
+++ b/lswhiteout   2015-04-21
@@ -45,15 +45,15 @@
                [ "${BP: -3}" = "sfs" ] && BP="${BP##*/}"
             fi
             if [ $BP ]; then
-               echo "\"${W:1}\" covers \"${D:1}/${B:4}\" in \"${BP}\""
+               echo -e "\"${W:1}\" \n  covers \"${D:1}/${B:4}\" \n  in \"${BP}\"\n" >> /tmp/whiteouts
             else
-               echo "\"${W:1}\" covers \"${D:1}/${B:4}\" in \"${BD}\""
+               echo -e "\"${W:1}\" \n  covers \"${D:1}/${B:4}\" \n  in \"${BD}\"\n" >> /tmp/whiteouts
             fi
             break
          fi
       done
       if [ "$XFFND" != "yes" ]; then
-         echo "\"${W:1}\" covers nothing."
+         echo -e "\"${W:1}\" covers nothing.\n" >> /tmp/whiteouts
       fi
    done
    # return delimiter to previous value
@@ -83,4 +83,8 @@
    check_branch
 fi
 
+[ -f /tmp/whiteouts ] && nohup defaulttextviewer /tmp/whiteouts &
+sleep 0.5
+rm -f /tmp/whiteouts 2>/dev/null
+
 exit


Code:
--- a/rmdeadwhiteout   2015-04-21
+++ b/rmdeadwhiteout   2015-04-21
@@ -40,7 +40,8 @@
       if [ "$XFFND" != "yes" ]; then
          rm -f "$W"
          XFDEL="yes"
-         [ "$XQU" != "yes" ] && echo "\"${W:1}\" removed from \"${BASEDIR}\"."
+         [ "$XQU" != "yes" ] && echo -e "\"${W:1}\" removed from \n \"${BASEDIR}\".\n" \
+          >> /tmp/removed_whiteouts
       fi
    done
    # return delimiter to previous value
@@ -74,4 +75,8 @@
    check_branch
 fi
 
+[ -f /tmp/removed_whiteouts ] && nohup defaulttextviewer /tmp/removed_whiteouts &
+sleep 0.5
+rm -f /tmp/removed_whiteouts 2>/dev/null
+
 exit

_________________
Kids all over the world go around with an XO laptop. They deserve one puppy (or many) too Very Happy
Back to top
View user's profile Send private message 
gyro

Joined: 28 Oct 2008
Posts: 724
Location: Brisbane, Australia

PostPosted: Tue 21 Apr 2015, 06:23    Post subject:  

mavrothal wrote:
Very handy!
You might want to consider these changes
Thanks.
I've incorporated the idea of breaking up the long lines. But I still just write to standard output.

The previous single line of output is broken into several lines with subsequent lines for the same whiteout file being indented.
Also removed quotes, file names now continue until the end of the current line.

New versions of scripts available from first post.

gyro
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [3 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Utilities
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0626s ][ Queries: 12 (0.0057s) ][ GZIP on ]