WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: quick tce-remove  (Read 9510 times)

Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
quick tce-remove
« 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]

Code: [Select]
#!/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
« Last Edit: June 19, 2009, 10:59:57 PM by jpeters »

Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
Re: quick tce-remove
« Reply #1 on: July 17, 2009, 03:36:23 PM »
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.  


Code: [Select]
#!/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

« Last Edit: July 17, 2009, 05:02:26 PM by jpeters »

Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
Re: quick tce-remove
« Reply #2 on: August 24, 2009, 09:10:27 PM »
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.

Code: [Select]
#!/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




 




« Last Edit: September 02, 2009, 02:21:47 AM by jpeters »

Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
Re: quick tce-remove
« Reply #3 on: September 18, 2009, 04:13:12 AM »
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

Code: [Select]
#!/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




 





« Last Edit: September 18, 2009, 09:33:24 PM by jpeters »

Offline jls

  • Hero Member
  • *****
  • Posts: 2135
Re: quick tce-remove
« Reply #4 on: January 20, 2011, 07:11:15 AM »
I modified this script which was not working for tc 3.x.
The file is attached to this post
dCore user