#! /bin/sh #---------------------------------------------------------------------------- # list-packages - list packages # # Copyright (c) 2001-2003 Frank Meyer # # Creation: 04.11.2001 fm # Last Update: 19.07.2003 fm # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------- echoyx () { echo -e "\033[$1;$2H\c"; shift; shift; echo -e "$*\c"; } gotoyx () { echo -e "\033[$1;$2H\c"; } read_old_package_info () { file=$1 while read line do case "$line" in ""*) set -- $line package="$2" ;; ""*) set -- $line shift description="$*" ;; ""*) set -- $line version="$2" ;; ""*) set -- $line date="$2" ;; ""*) set -- $line shift author="$*" ;; *) ;; esac done < $file } read_package_info () { file=$1 while read a do case "$a" in ""*) package=`echo "$a" | sed 's###g'` ;; ""*) version=`echo "$a" | sed 's###g'` ;; ""*) date=`echo "$a" | sed 's###g'` ;; esac done <$file } display_package_info () { file=$1 while read a do case "$a" in ""*) ;; ""*) name=`echo "$a" | sed 's###g'` echo " Name: "$name ;; ""*) package=`echo "$a" | sed 's###g'` echo " Package: "$package ;; ""*) version=`echo "$a" | sed 's###g'` normalize_version $version echo " Version: "$version ;; ""*) date=`echo "$a" | sed 's###g'` echo " Date: "$date ;; ""*) author=`echo "$a" | sed 's###g'` echo " Author: "$author ;; ""*) status=`echo "$a" | sed 's###g'` echo " Status: "$status ;; "
"*) section=`echo "$a" | sed 's###g'` echo " Section: "$section ;; ""*) source=`echo "$a" | sed 's###g'` echo " Source: "$source ;; ""*) require=`echo "$a" | sed 's###g'` echo " Require: "$require ;; ""*) description_active=true ;; ""*) description_active=false ;; ""*) ;; *) if [ "$description_active" = true ] then echo " $a" fi ;; esac done <$file } normalize_version () { v=$1 case $v in 1.0beta) v=0.90.0 ;; 1.0beta-patch-*) IFS='-' set -- $v unset IFS v=0.90.$3 ;; esac case "$v" in [0-9]*.[0-9]*.[0-9]*) IFS='.' set -- $v unset IFS major=$1 minor=$2 revision=$3 ;; [0-9]*.[0-9]*) IFS='.' set -- $v unset IFS major=$1 minor=$2 revision=0 ;; *) major=0 minor=0 revision=0 ;; esac version=$major.$minor.$revision } while [ 1 ] do clrhome colecho "List installed packages" gn row=3 n=0 for j in /var/install/packages/* do n=`expr $n + 1` grep '' $j >/dev/null if [ $? = 0 ] then read_package_info $j else read_old_package_info $j fi normalize_version $version echoyx $row 5 "$n. $package" echoyx $row 40 "$version" echoyx $row 68 "$date" eval package_$n='"$j"' row=`expr $row + 1` if [ $row = 21 ] then echo echo /var/install/bin/anykey clrhome colecho "List installed packages" gn row=3 fi done echoyx 23 1 "More infos of package (1-$n, 0=Exit) " read a if [ "$a" != "" -a "$a" != 0 ] then eval file='$package_'$a clrhome colecho "Package information" gn echo grep '' $file >/dev/null if [ $? = 0 ] then echo; echo display_package_info $file echo; echo else read_old_package_info $file normalize_version $version echo; echo; echo; echo; echo; echo echo " Package: $package" echo echo " Description: $description" echo echo " Version: $version" echo echo " Date: $date" echo echo " Author: $author" echo; echo; echo; echo; echo fi gotoyx 23 1 /var/install/bin/anykey else break fi done