| 1 | #! /bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | # .COPYRIGHT: Copyright (c) 1988 European Southern Observatory, |
| 3 | # all rights reserved |
| 4 | # .TYPE command |
| 5 | # .NAME delete.sh |
| 6 | # .LANGUAGE shell script |
| 7 | # .ENVIRONMENT Unix Systems. Executable under SHELL and C-SHELL |
| 8 | # .COMMENTS |
| 9 | # |
| 10 | # .AUTHOR Carlos Guirao |
| 11 | # .VERSION 1.1 30-Oct-1989: Implementation. |
| 12 | # .VERSION 1.2 05-Dec-1989: Adding "echo" definition |
| 13 | # 070615 last modif |
| 14 | # |
| 15 | echo=echo |
| 16 | if [scip-shell system . . `[`. "`echoscip-shell system . . echo. -n`" = "-n" ] ; then |
| 17 | SV_NONL="\c" |
| 18 | else |
| 19 | echo="echo -n" |
| 20 | fi |
| 21 | |
| 22 | # |
| 23 | # First of all, goto the config directory MID_INSTALL |
| 24 | # <dirname> & <basename> commands emulated with <sed> |
| 25 | # cd `dirname $0` |
| 26 | # MIDVERS=`basename $VERSDIR` |
| 27 | # MIDASHOME=`dirname $VERSDIR` |
| 28 | # |
| 29 | if [scip-shell system . . `[`. -z "$MIDASHOME" -o -z "$MIDVERS" ] ; then |
| 30 | cd `echoscip-shell system . . echo. $0 | sedscip-shell system . . sed. -e 's/[^\/]*$//' -e 's/^$/./' -e 's/\/$//'` |
| 31 | MID_INSTALL=`pwdscip-shell system . . pwd.` |
| 32 | VERSDIR=`echoscip-shell system . . echo. $MID_INSTALL | sedscip-shell system . . sed. 's/\/install\/unix$//'` |
| 33 | MIDVERS=`echoscip-shell system . . echo. $VERSDIR | sedscip-shell system . . sed. -e 's/^.*\///'` |
| 34 | MIDASHOME=`echoscip-shell system . . echo. $VERSDIR | sedscip-shell system . . sed. -e 's/[^\/]*$//' -e 's/^$/./' -e 's/\/$//'` |
| 35 | else |
| 36 | cd $MIDASHOME/$MIDVERS/install/unix |
| 37 | fi |
| 38 | |
| 39 | MID_INSTALL=$MIDASHOME/$MIDVERS/install/unix |
| 40 | MID_HOME=$MIDASHOME/$MIDVERS |
| 41 | |
| 42 | # |
| 43 | # START |
| 44 | # |
| 45 | |
| 46 | # Check weather "ls -s" command returns blocks of 1/2 or 1 kbytes. |
| 47 | # The file test_file_1k is 1kbyte big. |
| 48 | factor_ls=`lsscip-shell system . . ls. -s test_file_1k | awkscip-shell system . . awk. '{print $1}'` |
| 49 | |
| 50 | while : ; do |
| 51 | (echoscip-shell system . . echo. "" |
| 52 | echoscip-shell system . . echo. " DELETE EXECUTABLES FILES FROM:" |
| 53 | echoscip-shell system . . echo. "" |
| 54 | echoscip-shell system . . echo. " NAME CATEGORY" |
| 55 | echoscip-shell system . . echo. " ========================" |
| 56 | for categ in applic stdred contrib gui |
| 57 | do |
| 58 | if [scip-shell system . . `[`. ! -d $MID_HOME/$categ ]; then |
| 59 | continue |
| 60 | fi |
| 61 | cd $MID_HOME/$categ |
| 62 | for pack in `lsscip-shell system . . ls. | grepscip-shell system . . grep. -E -v 'lib|exec|proc'` |
| 63 | do |
| 64 | if [scip-shell system . . `[`. -f $pack/src/makefile ] ; then |
| 65 | echoscip-shell system . . echo. " $pack $categ " |
| 66 | fi |
| 67 | done |
| 68 | done |
| 69 | echoscip-shell system . . echo. "" ) | morescip-shell system . . more. |
| 70 | cd $MID_INSTALL |
| 71 | echoscip-shell system . . echo. "Type <Q> to quit or <L> to list again." |
| 72 | |
| 73 | while : ; do |
| 74 | $echo "Select NAME to DELETE: " $SV_NONL |
| 75 | read name |
| 76 | if [scip-shell system . . `[`. "$name" = "q" -o "$name" = "Q" ] ; then |
| 77 | exit |
| 78 | fi |
| 79 | if [scip-shell system . . `[`. "$name" = "l" -o "$name" = "L" ] ; then |
| 80 | break |
| 81 | fi |
| 82 | if [scip-shell system . . `[`. "$name" = "" ] ; then |
| 83 | continue |
| 84 | fi |
| 85 | if [scip-shell system . . `[`. -f $MID_HOME/applic/$name/src/makefile ] ; then |
| 86 | categ=applic |
| 87 | elif [scip-shell system . . `[`. -f $MID_HOME/stdred/$name/src/makefile ] ; then |
| 88 | categ=stdred |
| 89 | elif [scip-shell system . . `[`. -f $MID_HOME/contrib/$name/src/makefile ] ; then |
| 90 | categ=contrib |
| 91 | elif [scip-shell system . . `[`. -f $MID_HOME/gui/$name/src/makefile ] ; then |
| 92 | categ=gui |
| 93 | else |
| 94 | echoscip-shell system . . echo. "$name: No such package with that name" |
| 95 | continue |
| 96 | fi |
| 97 | |
| 98 | $echo "Number of kbytes to be deleted: (wait) " $SV_NONL |
| 99 | cd $MID_HOME/$categ/$name/src |
| 100 | lsscip-shell system . . ls. -s `makescip-shell system . . make. -n clean_exec | sedscip-shell system . . sed. -e 's/^rm//' -e 's/-f//'` 2>/dev/nullscip-shell filesystem . . `/dev/null`. | \ |
| 101 | awk -f $MID_INSTALL/size.awk factor=$factor_ls |
| 102 | if [scip-shell system . . `[`. $? != 0 ] ; then |
| 103 | continue |
| 104 | fi |
| 105 | $echo "Do you want to delete $name executables [yn]? (y): " $SV_NONL |
| 106 | read answ |
| 107 | if [scip-shell system . . `[`. -z "$answ" ]; then |
| 108 | answ=y |
| 109 | fi |
| 110 | if [scip-shell system . . `[`. "$answ" != "y" -a "$answ" != "Y" ]; then |
| 111 | cd $MID_INSTALL |
| 112 | echoscip-shell system . . echo. "" |
| 113 | continue |
| 114 | fi |
| 115 | |
| 116 | makescip-shell system . . make. clean_exec |
| 117 | cd $MID_INSTALL |
| 118 | echoscip-shell system . . echo. "" |
| 119 | done |
| 120 | done |
| 121 | |
| 122 | exit |