Tiny Core Linux
General TC => Programming & Scripting - Unofficial => Topic started by: jpeters on June 19, 2009, 10:51:57 PM
-
script: tce-remove
Here's a fast script for removing files on the tce.list. It doesn't remove open directories (in case one happened to be on the app list).
USAGE: tce-remove APP (eg., "tce-remove wine-gl" ) Don't include .tce, just the base name
[TESTING]
#!/bin/ash
MIRROR="$(awk '/Mirror/ {print $2}' /opt/.tcrc)"
TCEDIR="$(cat /opt/.tce_dir)"
APP="$(find $TCEDIR/${1}* | grep -v dep | grep -v txt | sed "s@$TCEDIR@@")"
sudo mkdir /tmp/tce-list
cd /tmp/tce-list
sudo wget ftp://$MIRROR/tce/$APP.list
LIST="$(cat *list)"
cd /
for I in $LIST
do
sudo rm $I
done
sudo rm -R /tmp/tce-list
-
updated to include test & report
note: I didn't delete from the tce directory, in case you want it after rebooting; also you
can use "update" script to restore files without a reboot.
#!/bin/ash
### tce-remove script, jpeters
### useage: "tce-remove APP" (eg, "tce-remove wine-gl") ; do not include ".tce*"
## removes tce.list files
MIRROR="$(awk '/Mirror/ {print $2}' /opt/.tcrc)"
TCEDIR="$(cat /opt/.tce_dir)"
[ -d /tmp/tce-list ] && sudo rm -R /tmp/tce-list
APP="$(find $TCEDIR/${1}* | grep -v dep | grep -v txt | sed "s@$TCEDIR@@")"
sudo mkdir /tmp/tce-list
cd /tmp/tce-list
sudo wget ftp://$MIRROR/tce/$APP.list
LIST="$(cat *list)"
cd /
for I in $LIST
do
sudo rm $I
done
#### REPORT #########
for I in $LIST
do
[ -f $I ] || echo "removed: $I " >>/tmp/report
[ -f $I ] && echo "not removed: $I " >>/tmp/report
done
cat /tmp/report
#### Cleanup #####
[ -f /tmp/report ] && sudo rm /tmp/report
[ -d /tmp/tce-list ] && sudo rm -R /tmp/tce-list
-
Updated to remove both tce and tcz list files that are installed to ram ( as of tc_2.3RC2)
USEAGE: "tce-remove basefilename"
Will only remove tcz's NOT in /tmp/tcloop. Checks tce directory for correct extension.
example: "tce-remove gnumeric"
Does NOT remove directories.
For safety, do not remove files that are in use. This script was written with a PPR system in mind that can be restored with a simple reboot.
#!/bin/ash
####### tce-remove script, by jpeters
###### Updated to remove tce and tcz list files that are installed to ram
###### Comments: use only basefilename.
##### Example: "tce-remove gnumeric"
MIRROR="$(awk '/Mirror/ {print $2}' /opt/.tcrc)"
TCEDIR="$(cat /opt/.tce_dir)"
[ -d /tmp/tce-list ] && sudo rm -R /tmp/tce-list
APP="$(find $TCEDIR/${1}* | grep -v dep | grep -v txt | sed "s@$TCEDIR@@")"
## tcz or tce?
case $APP in
*.tce*) EXT="tce" ;;
*.tcz*) EXT="tcz" ;;
esac
### Only remove tcz if installed to ram
if [ $EXT == "tcz" ]; then
if [ -e /tmp/tcloop/$1 ]; then
echo "tcz not installed to ram"
exit 1
fi
fi
sudo mkdir /tmp/tce-list
cd /tmp/tce-list
sudo wget ftp://$MIRROR/$EXT/$APP.list
LIST="$(cat *list)"
cd /
for I in $LIST
do
sudo rm $I
done
#### REPORT #########
for I in $LIST
do
[ -f $I ] || echo "removed: $I " >>/tmp/report
[ -f $I ] && echo "not removed: $I " >>/tmp/report
done
cat /tmp/report
#### Cleanup #####
[ -f /tmp/report ] && sudo rm /tmp/report
[ -d /tmp/tce-list ] && sudo rm -R /tmp/tce-list
-
Added option "-o" for extensions in /tce/optional folder example: "tce-remove -o oo2"
reminder: it's good practice to only remove files you aren't using
removes only files on .list installed to ram
Example with Open Office oo2.tczl installed to ram:
"tce-load -i -r tce/optional oo2.tczl"
Mem: 509,124K used, 6160K free, 0K shrd, 3372K buff, 348,144K cached
"tce-remove -o oo2"
Mem: 193,568K used, 321716K free, 0K shrd, 4152K buff, 50,840K cached
#!/bin/ash
####### tce-remove script, by jpeters
######## Removes only files on .list
###### Updated to remove tce and tcz list files that are installed to ram
###### Comments: use only basename.
##### Example: "tce-remove gnumeric"
##### Option -o for /tce/optional: "tce-remove -o oo2"
MIRROR="$(awk '/Mirror/ {print $2}' /opt/.tcrc)"
TCEDIR="$(cat /opt/.tce_dir)"
TCEOP="${TCEDIR}/optional"
[ -d /tmp/tce-list ] && sudo rm -R /tmp/tce-list
if [ ${1} == "-o" ] ; then
A=${2}
APP="$(find $TCEOP/${2}* | grep -v dep | grep -v txt | sed "s@$TCEOP@@")"
else
APP="$(find $TCEDIR/${1}* | grep -v dep | grep -v txt | sed "s@$TCEDIR@@")"
A=${1}
fi
## tcz or tce?
case $APP in
*.tce*) EXT="tce" ;;
*.tcz*) EXT="tcz" ;;
esac
### Only remove tcz if installed to ram
if [ $EXT == "tcz" ]; then
if [ -e /tmp/tcloop/${A} ]; then
echo "tcz not installed to ram"
exit 1
fi
fi
sudo mkdir /tmp/tce-list
cd /tmp/tce-list
sudo wget ftp://$MIRROR/$EXT/$APP.list
LIST="$(cat *list)"
cd /
for I in $LIST
do
sudo rm $I
done
#### REPORT #########
for I in $LIST
do
[ -f $I ] || echo "file removed: $I " >>/tmp/report
[ -f $I ] && echo "file not removed: $I " >>/tmp/report
done
cat /tmp/report
#### Cleanup #####
[ -f /tmp/report ] && sudo rm /tmp/report
[ -d /tmp/tce-list ] && sudo rm -R /tmp/tce-list
-
I modified this script which was not working for tc 3.x.
The file is attached to this post