#!/bin/bash # # this is a little tool to handle to information provided by the install-patch # written in 2001 by Joern Merkel. # # Yeah, this is all GPL, of course... # # some parameters : # # -l : list (all) installed packs # -d packname : delete # -g pattern : grep # -t packname : make a tar of the installed files function dolistfiles { # -d -> delete # -t -> tar LIST="$(grep ".* $OPTARG:" $LOGPLACE | cut -d " " -f 3-5)" [ ! "$LIST" ] && echo "Nothing to do with $OPTARG" && exit 0 oldIFS="$IFS" IFS=$'\n' for LINE in $LIST; do FILE="$(echo "$LINE" | cut -d " " -f 3)" [ -d $FILE ] && FILE="${FILE%/}/$(echo "$LINE" | cut -d " " -f 1)" if [ -f $FILE ]; then [ "$1" == "-d" ] && rm $FILE && echo "$FILE removed" [ "$1" == "-t" ] && tar -r $FILE -f $HOME/$OPTARG-$HOSTNAME.tar 2>/dev/null fi done IFS="$oldIFS" } OPTERR=0 LOGPLACE=$ILOGFILE if [ $# -eq 0 ]; then echo "sorting $LOGPLACE..." (sort -r -k 2 $LOGPLACE | uniq -f 1 | sort > $LOGPLACE.2) && mv $LOGPLACE.2 $LOGPLACE echo "for a list of options use -h" [ "$DIALOG" ] || exit 0 fi while : ; do getopts "hld:g:t:" OPTNAME || exit 0 case "$OPTNAME" in h) echo "-l : list (all) installed packs" echo "-d packname : delete" echo "-g pattern : grep" echo "-t packname : make a tar of the installed files" ;; l) grep ":" $LOGPLACE | sort -k 2 | cut -d " " -f 2 | uniq ;; d) grep "$OPTARG:" $LOGPLACE echo "Maybe you want to tar this files first ? (Do packtool -t $OPTARG)" echo "Warning ! Removing those files !" echo -n "Are you absolutely sure (y/n) ? "; read INPUT [ "$INPUT" != "y" ] && exit 0 dolistfiles -d (grep -v ".* $OPTARG:" $LOGPLACE > $LOGPLACE.2) && mv $LOGPLACE.2 $LOGPLACE ;; g) grep "$OPTARG" $LOGPLACE ;; t) dolistfiles -t gzip $HOME/$OPTARG-$HOSTNAME.tar && echo "$OPTARG tarred to $HOME/$OPTARG-$HOSTNAME.tar.gz" ;; esac done