Author |
Message |
stemsee
Joined: 27 Jun 2013 Posts: 2547 Location: In The Way
|
Posted: Sun 17 May 2015, 03:31 Post subject:
SFS-Remover Subject description: for removing all files of an sfs module from running system. |
|
I often remaster and sometimes accidentally remaster in sfs modules which then have no method of removing/uninstalling as there is no record in ~/.packages . This script can build such a record (list of files installed). Providing the original or equivalent sfs module can be located. Typically for me this means removing the devx from a remastered.sfs. just point the script to the sfs module, it will be extracted to "its-name"-extracted then CDed into where 'find -f -F -i --noreport' followed by a series of sed commands to remove extraneous items, will create the list in /tmp, which will be be used to remove files from running system.
EDIT: Needs more testing and work done on the symlinks in the case of development libraries.
Code: | #!/bin/sh
#sfs remover by stemsee
#copyright (c) 2015 Marcos Contant
#
#For removing all files in an sfs module that has been added to main sfs
#by remastering or added flat (manually copied in). Requires original
#( or any) sfs module for building list of files to be removed.
#for example a devx_vivid_beta.sfs to remove development files.
#The list that is built can also be used as an installed file list in
#~/.packages/ . So that running this script before creating an sfs module
#from a dir and saving the resultant list to ./$HOME/.packages/devx.files
#will give the option to uninstall files using ppm (i think) or slocategui
#and apptree.
#
echo "Enter /path/to/*.sfs module whose files you want to remove from system.
e.g. /mnt/home/devx.sfs
The sfs module will be decompressed then all files will be listed and removed
from running system."
read hit
if [ -f "$hit" ]; then
unsquashfs -dest "$hit"-extracted "$hit"
cd "$hit"-extracted
else
echo "'$hit' not found. press Enter to try again."
read U-dummy
exec "$0"
fi
[[ -f /tmp/rmsfs.lst ]] && rm -f /tmp/rmsfs.lst
touch /tmp/rmsfs.lst
tree -f -i -F --noreport | sed '/\/$/d' >> /tmp/rmsfs.lst
sed -i 's|./|/|' /tmp/rmsfs.lst
sed -i 1d /tmp/rmsfs.lst
sed -i 's/ .*//g' /tmp/rmsfs.lst
geany /tmp/rmsfs.lst &
echo "Ready to remove displayed files from running system. Press y or n."
read hut
case $hut in
y) while read line
do
rm -f $line
done < /tmp/rmsfs.lst
cd ../
cp /tmp/rmsfs.lst "$hit"-extracted/root/.packages/"$hit".files;;
n) exit 0;;
*) exec "$0";;
esac
|
|
Back to top
|
|
 |
stemsee
Joined: 27 Jun 2013 Posts: 2547 Location: In The Way
|
Posted: Wed 02 Sep 2015, 04:37 Post subject:
|
|
Should have mounted module on loop (no need to extract). should use rm -rf $line instead of -f.
|
Back to top
|
|
 |
stemsee
Joined: 27 Jun 2013 Posts: 2547 Location: In The Way
|
Posted: Wed 02 Sep 2015, 05:51 Post subject:
|
|
So this is pretty much it
This generates .files list and a ppm db entry for removal by ppm if files were not already removed using the script. ldconfig is also invoked in case of devx being removed. Save in PATH as rmsfs and make executable. invoke in terminal. Probably should be a rox app for right click operation.
Code: | #!/bin/sh
#sfs remover by stemsee
#copyright (c) 2015 Marcos Contant
#
#For removing all files in an sfs module that has been added to main sfs
#by remastering or added flat (manually copied in). Requires original
#( or any) sfs module for building list of files to be removed.
#for example a devx_vivid_beta.sfs to remove development files.
#The list that is built can also be used as an installed file list in
#~/.packages/ . So that running this script before creating an sfs module
#from a dir and saving the resultant list to ./$HOME//.packages/devx.files
#will give the option to uninstall files using ppm (i think) or slocategui
#and apptree.
#
if [ ! -z "$1" ]; then
hit="$1"
fi
if [ -z "$1" ]; then
echo "Enter /path/to/*.sfs module whose files you want to remove from system.
e.g. /mnt/home/devx.sfs
The sfs module will be mounted then all files will be listed and option to remove from running system given. Or a *.files list will be made for removal by ppm."
read hit
fi
rmfn ()
{
[[ -d /tmp/"$hit" ]] && umount -l /tmp/"$hit" 2&>/dev/null
sleep 3
[[ -d /tmp/"$hit" ]] && rm -rf /tmp/"$hit"
}
deps=`which tree`
if [ -z "$deps" ]; then
echo "Please install tree"
sleep 4
exit 0
fi
if [ -f "$hit" ]; then
rmfn
mkdir /tmp/"$hit"
mount -t squashfs -o loop "$hit" /tmp/"$hit" 2&>/dev/null
size=`du -chk /tmp/$hit | tail -1 | cut -f1 -d 't'`
size=`echo $size | cut -f1 -d ' '`k
sleep 2
cd /tmp/"$hit"
else
echo "'$hit' not found. press Enter to try again."
read Udummy
exec "$0"
fi
[[ -f /tmp/rmsfs.lst ]] && rm -f /tmp/rmsfs.lst
touch /tmp/rmsfs.lst
tree -fiF --noreport | sed '/\/$/d' >> /tmp/rmsfs.lst
sed -i 's|./|/|' /tmp/rmsfs.lst
sed -i 1d /tmp/rmsfs.lst
sed -i 's/ .*//g' /tmp/rmsfs.lst
geany /tmp/rmsfs.lst &
echo "Ready to remove displayed files from running system.
If not then a '$hit'.files list will be made in '$HOME/'/.packages/.
Press y or n."
read hut
case $hut in
y) while read line
do
rm -rf $line
done < /tmp/rmsfs.lst
ldconfig
cd ../;;
n) [[ /tmp/rmsfs.lst ]] && mv /tmp/rmsfs.lst $HOME/.packages/"$hit".files
ins=`cat $HOME/.packages/user-installed-packages | grep "$hit"`
if [[ -z "$ins" ]]; then
echo "$hit|$hit|||Utility|$size||$hit||sfs module file list||||" >> $HOME/.packages/user-installed-packages
fi
rmfn
exit 0;;
*) [[ /tmp/rmsfs.lst ]] && mv /tmp/rmsfs.lst $HOME/.packages/"$hit".files
ins=`cat $HOME/.packages/user-installed-packages | grep "$hit"`
if [[ -z "$ins" ]]; then
echo "$hit|$hit|||Utility|$size||$hit||sfs module file list||||" >> $HOME/.packages/user-installed-packages
fi
rmfn
exec "$0";;
esac
rmfn
exit 0
|
Last edited by stemsee on Thu 03 Sep 2015, 03:44; edited 1 time in total
|
Back to top
|
|
 |
Bindee
Joined: 19 Jun 2014 Posts: 365
|
Posted: Wed 02 Sep 2015, 18:33 Post subject:
|
|
So this keeps the SFS files that have been loaded and just removes the SFS module that was used to load them?
|
Back to top
|
|
 |
stemsee
Joined: 27 Jun 2013 Posts: 2547 Location: In The Way
|
Posted: Thu 03 Sep 2015, 03:34 Post subject:
|
|
Not quite.
usage
This will mount the sfs in tmp/devx.sfs directory and enter it and recursively list all files and save list as a ~/.packages/devx.sfs.files list and also make a database entry appended to ~/.packages/user-installed-packages so that ppm can be used to remove the files (not the sfs loop mount: the sfs is not mounted as a layer for use, by this script). This is in cases where an sfs has been remastered in and there is no uninstall info anywhere on the system.
To do what you said simply remaster with sfs loaded! But if you use this before the remaster selecting no at offer to remove files then the db and files list will be added to system so that after remaster there is the option to remove by ppm.
|
Back to top
|
|
 |
Bindee
Joined: 19 Jun 2014 Posts: 365
|
Posted: Thu 03 Sep 2015, 04:03 Post subject:
|
|
Thankssssssss
|
Back to top
|
|
 |
stemsee
Joined: 27 Jun 2013 Posts: 2547 Location: In The Way
|
Posted: Sun 06 Sep 2015, 16:22 Post subject:
|
|
mount -loop error sorted.
Code: | #!/bin/sh
#sfs remover by stemsee
#copyright (c) 2015 Marcos Contant
#
#For removing all files in an sfs module that has been added to main sfs
#by remastering or added flat (manually copied in). Requires original
#( or any) sfs module for building list of files to be removed.
#for example a devx_vivid_beta.sfs to remove development files.
#The list that is built can also be used as an installed file list in
#~/.packages/ . So that running this script before creating an sfs module
#from a dir and saving the resultant list to ./$HOME//.packages/devx.files
#will give the option to uninstall files using ppm (i think) or slocategui
#and apptree.
#
if [ ! -z "$1" ]; then
hit="$1"
fi
if [ -z "$1" ]; then
echo "Enter /path/to/*.sfs module whose files you want to remove from system.
e.g. /mnt/home/devx.sfs
The sfs module will be mounted then all files will be listed and option to remove from running system given. Or a *.files list will be made for removal by ppm."
read hit
fi
rmfn ()
{
[[ -d /tmp/"$hit" ]] && umount -l /tmp/"$hit" 2&>/dev/null
sleep 3
[[ -d /tmp/"$hit" ]] && rm -rf /tmp/"$hit"
}
deps=`which tree`
if [ -z "$deps" ]; then
echo "Please install tree"
sleep 4
exit 0
fi
if [ -f "$hit" ]; then
rmfn
mkdir /tmp/"$hit"
mount -loop -t squashfs "$hit" /tmp/"$hit"
size=`du -chk /tmp/$hit | tail -1 | cut -f1 -d 't'`
size=`echo $size | cut -f1 -d ' '`k
sleep 2
cd /tmp/"$hit"
else
echo "'$hit' not found. press Enter to try again."
read Udummy
exec "$0"
fi
[[ -f /tmp/rmsfs.lst ]] && rm -f /tmp/rmsfs.lst
touch /tmp/rmsfs.lst
tree -fiF --noreport | sed '/\/$/d' >> /tmp/rmsfs.lst
sed -i 's|./|/|' /tmp/rmsfs.lst
sed -i 1d /tmp/rmsfs.lst
sed -i 's/ .*//g' /tmp/rmsfs.lst
geany /tmp/rmsfs.lst &
echo "Ready to remove displayed files from running system.
If not then a '$hit'.files list will be made in '$HOME/'/.packages/.
Press y or n."
read hut
case $hut in
y) while read line
do
rm -rf $line
done < /tmp/rmsfs.lst
ldconfig
cd ../;;
n) [[ /tmp/rmsfs.lst ]] && mv /tmp/rmsfs.lst $HOME/.packages/"$hit".files
ins=`cat $HOME/.packages/user-installed-packages | grep "$hit"`
if [[ -z "$ins" ]]; then
echo "$hit|$hit|||Utility|$size||$hit||sfs module file list||||" >> $HOME/.packages/user-installed-packages
fi
rmfn
exit 0;;
*) [[ /tmp/rmsfs.lst ]] && mv /tmp/rmsfs.lst $HOME/.packages/"$hit".files
ins=`cat $HOME/.packages/user-installed-packages | grep "$hit"`
if [[ -z "$ins" ]]; then
echo "$hit|$hit|||Utility|$size||$hit||sfs module file list||||" >> $HOME/.packages/user-installed-packages
fi
rmfn
exec "$0";;
esac
rmfn
exit 0
|
|
Back to top
|
|
 |
stemsee
Joined: 27 Jun 2013 Posts: 2547 Location: In The Way
|
Posted: Wed 17 Feb 2016, 12:27 Post subject:
|
|
Updated to support use in rightclick menu. link to (~/.config/rox.sourceforge.net/SendTo/.application_x-squashfs-image/rmsfs)
Code: | #!/bin/sh
#sfs remover by stemsee
#copyright (c) 2015 Marcos Contant
#
#For removing all files in an sfs module that has been added to main sfs
#by remastering or added flat (manually copied in). Requires original
#( or any) sfs module for building list of files to be removed.
#for example a devx_vivid_beta.sfs to remove development files.
#The list that is built can also be used as an installed file list in
#~/.packages/ . So that running this script before creating an sfs module
#from a dir and saving the resultant list to ./root/.packages/devx.files
#will give the option to uninstall files using ppm (i think) or slocategui.
#
if [ ! -z "$1" ]; then
hit="$1"
else
yaf-splash -text "The sfs module will be mounted then all files will be listed and option to remove from running system given. Or a *.files list will be made for removal by ppm." &
hit=$(yad --title "Enter /path/to/*.sfs" --entry)
fi
hitmd=`echo "$hit" | rev | cut -f1 -d '/' | rev`
rmfn ()
{
[[ -d /tmp/"$hitmd" ]] && umount -l /tmp/"$hitmd" 2&>/dev/null
sleep 3
[[ -d /tmp/"$hitmd" ]] && rm -rf /tmp/"$hitmd"
}
deps=`which tree`
if [ -z "$deps" ]; then
echo "Please install tree"
sleep 4
exit 0
fi
if [ -f "$hit" ]; then
rmfn
mkdir /tmp/"$hitmd"
mount -loop -t squashfs "$hit" /tmp/"$hitmd"
size=`du -chk /tmp/$hit | tail -1 | cut -f1 -d 't'`
size=`echo $size | cut -f1 -d ' '`k
sleep 2
cd /tmp/"$hitmd"
fi
tree -fiF --noreport | sed '/\/$/d' > /tmp/rmsfs.lst
sed -i 's|./|/|' /tmp/rmsfs.lst
sed -i 1d /tmp/rmsfs.lst
sed -i 's/ .*//g' /tmp/rmsfs.lst
geany /tmp/rmsfs.lst &
yaf-splash -text "Ready to remove displayed files from running system.
If not then a '$hitmd'.files list will be made in '/root/.packages/."
yad --title "Enter y or n or q to quit" --width=300 --entry
read hut
case $hut in
y) while read line
do
rm -rf $line
done < /tmp/rmsfs.lst
ldconfig
cd ../;;
n) [[ /tmp/rmsfs.lst ]] && mv /tmp/rmsfs.lst /root/.packages/"$hitmd".files
ins=`cat /root/.packages/user-installed-packages | grep "$hit"`
if [[ -z "$ins" ]]; then
echo "$hitmd|$hitmd|||Utility|$size||$hitmd||sfs module file list||||" >> /root/.packages/user-installed-packages
fi
rmfn
exit 0;;
*) exit 0;;
esac
rmfn
exit 0
|
|
Back to top
|
|
 |
greengeek

Joined: 20 Jul 2010 Posts: 5624 Location: Republic of Novo Zelande
|
Posted: Wed 17 Feb 2016, 21:48 Post subject:
|
|
Hi stemsee - are you aware of (or have you built...) any scripts that can be run manually prior to shutdown (or prior to remaster) to identify which sfs are currently loaded.
I continually try to unmout disks and shutdown having forgotten which blinkin' sfses I have clicked on and I get various errors (and "kill" windows) just because of the way I have my pup layered.
If there was some easy way to identify the list of loaded sfs (and preferably their disk locations) that would be very helpful. cheers
|
Back to top
|
|
 |
stemsee
Joined: 27 Jun 2013 Posts: 2547 Location: In The Way
|
Posted: Wed 17 Feb 2016, 22:26 Post subject:
|
|
Hi greengeek
try running in terminal at start of a session
Code: | mount | grep 'squashfs' > ~/loaded-sfs-mods-start |
and again at end of the session
then
if you know your adrv zdrv ydrv and main sfs (loop 0)
You just count them!
Code: | mount | grep 'squashfs' > ~/loaded-sfs-mods-end |
But sure I will come up with something, give me a couple days!
|
Back to top
|
|
 |
slavvo67
Joined: 12 Oct 2012 Posts: 1617 Location: The other Mr. 305
|
Posted: Wed 17 Feb 2016, 22:52 Post subject:
|
|
Mikeb had something but I'm not sure if he shared it. It might be hidden in the depths of this board....
|
Back to top
|
|
 |
stemsee
Joined: 27 Jun 2013 Posts: 2547 Location: In The Way
|
Posted: Fri 19 Feb 2016, 03:49 Post subject:
|
|
Seems to me that only the script filemnt needs modifying to output a list of sfs modules that get 'installed' during a session but mount should unmount 'stray' filesystems during shutdown anyway!
|
Back to top
|
|
 |
greengeek

Joined: 20 Jul 2010 Posts: 5624 Location: Republic of Novo Zelande
|
Posted: Fri 19 Feb 2016, 04:21 Post subject:
|
|
stemsee wrote: | ...mount should unmount 'stray' filesystems during shutdown anyway! | The problem I am getting is that I am in the habit of using pmount to manually unmount my disks before I do a shutdown. - and unfortunately it will not process the unmount while an sfs is in use - I end up with a forced "kill" of pmount and have to run it again after unloading all the sfses.
Generally by that time I have forgotten which sfses I have loaded, and on which of my disks those sfs are residing, so I have to go hunting and sometimes make wild guesses about it.
However - I realise now that I can run "menu, setup, load-sfs-on-the-fly" and it will identify what is already loaded and let me select what to unload from a list. That is an improvement anyway - I hadn't previously thought about doing it that way. I guess load-on-the-fly must be able to read a file somewhere that contains a list of loaded sfs.
What would be even better is to have an icon on the desktop that when clicked would unload any and every sfs currently loaded - regardless of location. That would save me the trouble of racking my brains to think back to what it was I did three hours ago.
|
Back to top
|
|
 |
greengeek

Joined: 20 Jul 2010 Posts: 5624 Location: Republic of Novo Zelande
|
Posted: Fri 19 Feb 2016, 04:34 Post subject:
|
|
I just had a look at the "filemnt" file you referred to and when I loaded the devx sfs an extra line appeared in filemnt but I can't make sense of it or see how I can use it to unload the sfs.
The extra line is:
Code: | /dev/loop1 /initrd/pup_ro4 squashfs ro,noatime 0 0 |
I guess that means something to the shutdown routine.
.
|
Back to top
|
|
 |
greengeek

Joined: 20 Jul 2010 Posts: 5624 Location: Republic of Novo Zelande
|
Posted: Fri 19 Feb 2016, 15:58 Post subject:
|
|
Hi stemsee - please forgive me for cluttering your thread - I think I have a solution for my needs: There is a post here from jasper offering a pet written by forum member seaside, which I have now modified slightly so that it unloads all sfs immediately and without any questions.
EDIT : I should add a caveat from the original thread: "it will unload all/or any sfs files (that are not actually in use or minimised to a tray"
(I have more tests to do to better understand what constitutes "in use")
Hope you won't mind if I post it here:
NOTES :
1) This is not an sfs remover as offered by stemsee for remastering - it is an sfs unloader which unmounts all sfs.
2) It is experimental and possibly dangerous for some users or puppies
3) Although the sfs are successfully unloaded this script does not update the files that tell "sfs-load-on-the-fly" which sfs are loaded. This means that the sfs_load utility still thinks that the sfs might be loaded when it isnt. This is not a problem for me as I simply shut down at that point anyway.
How to use: The attached pet places the script "all_sfs_unloader_gg" in /root - and you can simply click on that script to have it immediately unload/unmount all of your sfs.
Put the script wherever you want.
 |
Description |
|

Download |
Filename |
all_sfs_unloader_gg-0.0.pet |
Filesize |
1.04 KB |
Downloaded |
181 Time(s) |
Last edited by greengeek on Fri 19 Feb 2016, 20:31; edited 1 time in total
|
Back to top
|
|
 |
|