#! /bin/sh #---------------------------------------------------------------------------- # /var/install/bin/install-package - install a package # # Creation : 2001-11-04 fm # Last Update: $Id$ # # Copyright (c) 2001-2007 the eisfair team, team(at)eisfair(dot)org # # usage: # install-package # or: # install-package url-of-eis-list.txt # or: # install-package [-y] -l [index_url] -i [package choice_url] info_url # # 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. #---------------------------------------------------------------------------- #exec 2> /tmp/install-package-trace$$.log #set -x # include eislib . /var/install/include/eislib export index_url # fm: recursive calls of install-package if tar --help | grep -q 'no-overwrite-dir' then taroption='--no-overwrite-dir' else taroption='' fi #---------------------------------------------------------------------------- # select system version #---------------------------------------------------------------------------- # list systems to select systems="eisfair-1 eisfair-2 eisxen-1" etc_system_file=/etc/eisfair-system check_system () { clrhome # display systems to select on tty mecho mecho -info "Can't detect the system type," mecho -info "please select one first." mecho techo begin 3 2r 2 32 techo row "" -info No "" -info System mecho " -----------------------" idx=1 echo "${systems}" | while read line do techo row "" "${idx}" "" "${line}" idx=`/usr/bin/expr ${idx} + 1` done mecho " -----------------------" techo end # get number of system to select the max number systems_lines=`echo "${systems}" | wc -l` mecho system_to_work=`/var/install/bin/ask "Select" "${system_to_work}" "1-${systems_lines}" "0=Exit"` case ${system_to_work} in 0) exit 0 ;; *) # set working system system_work="`echo "$systems" | sed -n "${system_to_work}p" | sed 's/^ *//'`" # write ${etc_system_file} echo "${system_work}" >${etc_system_file} ;; esac } # check ${etc_system_file} exists if [ ! -f ${etc_system_file} ] then # if not exists check_system else # if exists, read entry system_work="`cat ${etc_system_file} | sed 's/^ *//'`" # check if ${etc_system_file} entry broken if `echo "${systems}" | grep -q "${system_work}$"` then # if not broken system_work="${system_work}" else # if broken check_system fi fi #---------------------------------------------------------------------------- # set -f # disable pathname expansion if [ "$0" = "/var/install/update/install-package" ] then wget=/var/install/update/wget.sh chksum=/var/install/update/sha1sum new_status='n' old_status='o' inst_status='i' notinst_status='-' unknown_status='?' link_status='>' else new_status=`colecho -tty "n" br b br` old_status=`echo "o"` inst_status=`colecho -tty "i" gn x br` notinst_status=`colecho -tty "-" br b br` unknown_status=`colecho -tty "?" x x br` link_status=`colecho -tty ">" cy` wget=/usr/local/bin/wget.sh chksum=/usr/bin/sha1sum fi basedir=`dirname $0` if [ "$basedir" = "." ] then basedir=`pwd` fi gotoyx () { echo -e "\033[$1;$2H\c"; } cdrom_mounted=false mount_cdrom () { if ! mount | grep ' /cdrom' >/dev/null then mount /cdrom cdrom_mounted=true fi } umount_cdrom () { if [ "$cdrom_mounted" = "true" ] then umount /cdrom cdrom_mounted=false fi } read_info () { info_url=$1 case $info_url in *:*) ;; *) info_path=`dirname $current_url` info_url="$info_path/$info_url" ;; esac base_info_url=`basename $info_url` rm -f $base_info_url $wget -q $info_url if [ $? -ne 0 ] then package_name="" package_version="0.0.0" package="" download_url=`echo "$info_url" | sed 's/\.info$//g'` rm -f $base_info_url return fi package_name= package_version= package= package_system= system_info= download_url=`echo "$info_url" | sed 's/\.info$//g'` /usr/local/bin/dtou $base_info_url while read a do case "$a" in ""*) package_name=`echo "$a" | sed 's###g'` ;; ""*) package=`echo "$a" | sed 's###g'` # get string length package_length="${#package}" ;; ""*) package_version=`echo "$a" | sed 's###g'` # get string length package_version_length="${#package_version}" ;; ""*) package_stat=`echo "$a" | sed 's###g'` case ${package_stat} in "stable") package_stat="S:" ;; "testing") package_stat="T:" ;; "unstable") package_stat="U:" ;; *) package_stat="?:" ;; esac ;; ""*) # select the system to install package_system="`echo "${a}" | sed 's###g'`" if `echo "${package_system}" | grep -Eq "^eisfair [1|2]$|^eisxen 1$"` then package_system=`echo "${package_system}" | sed 's/ /-/'` fi if [ -z "${system_info}" ] then system_info=`echo "${package_system}"` else system_info=`echo "${system_info}"; echo "${package_system}"` fi ;; esac done <$base_info_url rm -f $base_info_url # set the default 'eisfair 1' if [ -z "${system_info}" ] then system_info="eisfair-1" fi } f_disp_required_libs () { do_disp=$1 disp_rtc=0 req=/tmp/required_libs_found-$$ rm -f $req echo "$require_libs" | while read p do set -- $p require_package=$1 require_version=$2 if [ "$require_version" = "" ] then require_version=0.0.0 fi read_info $require_package status=`$basedir/check-version $package_name $require_version` if [ "$status" = "new" -o "$status" = "not-installed" ] then if [ ! -f $req ] then >$req if [ $do_disp = true ] then echo echo "This package requires the following libraries:" echo fi fi if [ $do_disp = true ] then if [ "$require_version" != "0.0.0" ] then echo " $package_name >= $require_version - $package" else echo " $package_name - $package" fi fi if [ "$package_name" = "" -o "$package_name" = "" ] then disp_rtc=1 fi fi done return $disp_rtc } f_disp_required_packages () { do_disp=$1 disp_rtc=0 req=/tmp/required_packages_found-$$ rm -f $req echo "$require_packages" | while read p do set -- $p require_package=$1 require_version=$2 if [ "$require_version" = "" ] then require_version=0.0.0 fi read_info $require_package status=`$basedir/check-version $package_name $require_version` if [ "$status" = "new" -o "$status" = "not-installed" ] then if [ ! -f $req ] then >$req if [ $do_disp = true ] then echo echo "This package requires the following packages:" echo fi fi if [ $do_disp = true ] then if [ "$require_version" != "0.0.0" ] then echo " $package_name >= $require_version - $package" else echo " $package_name - $package" fi fi if [ "$package_name" = "" -o "$package_name" = "" ] then disp_rtc=1 fi fi done return $disp_rtc } # function to get the index_url get_index_url () { index="${1}" case ${index} in *:*) ;; *) index_path=`dirname ${current_url}` index="${index_path}/${index}" ;; esac base_index=`basename ${index}` rm -f ${base_index} ${wget} -q ${index} index_url=${index} index_read=true } get_packagename_by_index () { # check if /tmp/index.txt given if [ -z "${index_url}" ] then get_index_url "http://www.pack-eis.de/index.txt" fi name="$1" # check for usb packages if [ ! ${name} = usb ] then # grep to do it a little faster if grep "^${name} " /tmp/index.txt > /tmp/small-index.txt then { name="$1" version="$2" ip=`dirname $index_url` stable_url='' unstable_url='' highest_stable_version='' highest_unstable_version='' while read line do set -- $line packname=$1 packversion=$2 packstatus=$3 packfile=$4 if [ "$packname" = "$name" ] then # check for system version base_packfile=`basename "${packfile}"` rm -f ${base_packfile} case "${packfile}" in *:*) ${wget} -q "${packfile}" ;; *) ${wget} -q "${ip}/${packfile}" ;; esac /usr/local/bin/dtou ${base_packfile} # clear up req_system= system_req= non_system=0 # read info file while read a do case "${a}" in ""*) req_system=`echo "${a}" | sed 's###g'` if `echo "${req_system}" | grep -Eq "^eisfair [1|2]$|^eisxen 1$"` then req_system=`echo "${req_system}" | sed 's/ /-/'` fi if [ -z "${system_req}" ] then system_req=`echo "${req_system}"` else system_req=`echo "${system_req}"; echo "${req_system}"` fi ;; esac done <${base_packfile} rm -f ${base_packfile} # if system nort set if [ -z "${system_req}" ] then system_req="eisfair-1" fi # if system required = system work if `echo "${system_req}" | grep -q "${system_work}"` then if [ "$packstatus" = "stable" ] then stat=`/var/install/bin/check-version -diff "$packversion" "$highest_stable_version"` if [ $stat != "old" ] then case "$packfile" in *:*) stable_url="$packfile $version";; *) stable_url="$ip/$packfile $version";; esac highest_stable_version=$packversion fi else stat=`/var/install/bin/check-version -diff "$packversion" "$highest_unstable_version"` if [ $stat != "old" ] then case "$packfile" in *:*) unstable_url="$packfile $version";; *) unstable_url="$ip/$packfile $version";; esac highest_unstable_version=$packversion fi fi else #if non system packages non_system=1 break # end if system required = system work fi fi done if [ "${non_system}" -eq 0 ] then if [ -n "$version" ] then if [ "$stable_url" != "" ] then stat=`/var/install/bin/check-version -diff "$highest_stable_version" "$version"` if [ $stat != "old" ] then echo "$stable_url" $version else echo "$unstable_url" $version fi else echo "$unstable_url" $version fi else if [ "$stable_url" != "" ] then echo "$stable_url" $version else echo "$unstable_url" $version fi fi fi } " ${base_info_url} | sed 's###g; s/ /-/'`" if [ -z "${display_system}" ] then display_system="eisfair-1" fi if ! `echo "${display_system}" | grep -q "${system_work}$"` then rm -f ${base_info_url} else # check, if new tag given: if grep "" $base_info_url >/dev/null || grep "" $base_info_url >/dev/null then display_require=false # display old require: false else display_require=true # display old require: true fi require_packages= require_libs= sha1sum= space_required=1 disp_system= system_required= while read a do case "$a" in ""*) ;; ""*) disp_name=`echo "$a" | sed 's###g'` echo " Name: "$disp_name ;; ""*) disp_package=`echo "$a" | sed 's###g'` echo " Package: "$disp_package ;; ""*) disp_version=`echo "$a" | sed 's###g'` echo " Version: "$disp_version ;; ""*) disp_date=`echo "$a" | sed 's###g'` echo " Date: "$disp_date ;; ""*) disp_system=`echo "$a" | sed 's###g'` if `echo "${disp_system}" | grep -Eq "^eisfair [1|2]$|^eisxen 1$"` then disp_system=`echo "${disp_system}" | sed 's/ /-/'` fi if [ -z "${system_required}" ] then system_required=`echo "${disp_system}"` else system_required=`echo "${system_required}"; echo "${disp_system}"` fi if [ -z "${system_required}" ] then system_required="eisfar-1" fi ;; ""*) disp_author=`echo "$a" | sed 's###g'` echo " Author: "$disp_author ;; ""*) disp_status=`echo "$a" | sed 's###g'` echo " Status: "$disp_status ;; "
"*) disp_section=`echo "$a" | sed 's###g'` echo " Section: "$disp_section ;; ""*) disp_source=`echo "$a" | sed 's###g'` echo " Source: "$disp_source ;; ""*) sha1sum=`echo "$a" | sed 's###g'` ;; ""*) space_required=`echo "$a" | sed 's###g'` ;; ""*) if [ $display_require = true ] then disp_require=`echo "$a" | sed 's###g'` echo " Require: "$disp_require fi ;; ""*) require_package=`echo "$a" | sed 's###g'` r=`echo $require_package | sed 's# .*##g'` # strip version case $r in *:*) ;; *.*) ip=`dirname $current_url` require_package="$ip/$require_package" ;; *) require_package=`get_packagename_by_index $require_package` ;; esac case ${require_package} in non+*) # if package is missing in index.txt file and strip prefix if [ -z "${missing_package}" ] then missing_package="${require_package#*+}" else missing_package=`echo "${missing_package}"; echo "${require_package#*+}"` fi ;; old+*) # if package is old and included in base and strip prefix if [ -z "${base_package}" ] then base_package="${require_package#*+}" else base_package=`echo "${base_package}"; echo "${require_package#*+}"` fi ;; *) if [ -z "$require_packages" ] then require_packages="$require_package" else require_packages=`echo "$require_packages"; echo "$require_package"` fi ;; esac ;; ""*) require_lib=`echo "$a" | sed 's###g'` r=`echo $require_lib | sed 's# .*##g'` # strip version case $r in *:*) ;; *.*) ip=`dirname $current_url` require_lib="$ip/$require_lib" ;; *) require_lib=`get_packagename_by_index $require_lib` ;; esac case ${require_lib} in non+*) # if lib is missing in index.txt file and strip prefix if [ -z "${missing_package}" ] then missing_package="${require_lib#*+}" else missing_package=`echo "${missing_package}"; echo "${require_lib#*+}"` fi ;; old+*) # if package is old and included in base and strip prefix if [ -z "${base_package}" ] then base_package="${require_package#*+}" else base_package=`echo "${base_package}"; echo "${require_package#*+}"` fi ;; *) if [ "$require_libs" = "" ] then require_libs="$require_lib" else require_libs=`echo "$require_libs"; echo "$require_lib"` fi ;; esac ;; ""*) description_active=true ;; ""*) description_active=false ;; ""*) ;; *) if [ "$description_active" = true ] then echo " $a" fi ;; esac done <$base_info_url rm -f $base_info_url disp_rtc=0 if [ "$require_libs" != "" ] then f_disp_required_libs true disp_rtc=$? fi if [ "$require_packages" != "" ] then f_disp_required_packages true disp_rtc=$? fi echo return $disp_rtc # end if ! `echo "${display_system}" | grep -q "${system_work}$"` fi } f_install_package () { if [ "$info_url" != "" ] then clrhome colecho "Package: $package" gn echo echo " URL: $choice_url" echo display_info $info_url else echo echo "Package: $package" echo "URL : $choice_url" fi # list missing packages in index.txt if [ -n "${missing_package}" ] then echo "The required package cannot be found." echo "Please use Pack-Eis to search and install it." echo techo begin 2 70 echo "${missing_package}" | while read m_package m_version do case x${m_version} in x) techo row "" "${m_package}" ;; *) techo row "" "${m_package} >= ${m_version}" ;; esac done techo end # clear up missing_package='' fi # list base packages includet if [ -n "${base_package}" ] then echo "The required package is included in the base package since 1.4.0." echo techo begin 2 70 echo "${base_package}" | while read m_package m_version do case x${m_version} in x) techo row "" "${m_package}" ;; *) techo row "" "${m_package} >= ${m_version}" ;; esac done techo end # clear up base_package='' fi echo if [ $do_ask = yes ] then if $basedir/ask "Install" then do_install=yes else do_install=no fi else do_install=yes fi if [ $do_install = yes ] then disp_rtc=0 if [ "$require_libs" != "" ] then f_disp_required_libs false disp_rtc=$? if [ $disp_rtc -ne 0 ] then colecho "This package requires some other libraries which are unknown." br b br colecho "Installation aborted." br b br else if [ -f $req ] then rm -f $req echo echo "$require_libs" | while read p do set -- $p require_lib=$1 require_version=$2 if [ "$require_version" = "" ] then require_version=0.0.0 fi ( read_info $require_lib status=`$basedir/check-version $package_name $require_version` if [ "$status" = "new" -o "$status" = "not-installed" ] then $basedir/install-package -i $require_lib <$tty fi ) done fi fi fi if [ $disp_rtc -eq 0 -a "$require_packages" != "" ] then f_disp_required_packages false disp_rtc=$? if [ $disp_rtc -ne 0 ] then colecho "This package requires some other packages which are unknown." br b br colecho "Installation aborted." br b br else if [ -f $req ] then rm -f $req echo echo "$require_packages" | while read p do set -- $p require_package=$1 require_version=$2 if [ "$require_version" = "" ] then require_version=0.0.0 fi ( read_info $require_package status=`$basedir/check-version $package_name $require_version` if [ "$status" = "new" -o "$status" = "not-installed" ] then $basedir/install-package -i $require_package <$tty fi ) done fi fi fi if [ $disp_rtc -eq 0 ] then b=`basename $choice_url` rm -f $b retval=0 system_required=`echo "${system_required}" | grep "${system_work}$"` system_info=`echo "${system_info}" | grep "${system_work}$"` if [ -z "${system_required}" -a -z "${system_info}" ] then mecho -error "This package is not compatible with '${system_work}'" mecho anykey retval=255 fi if [ "$space_required" -gt "0" ] then space_avail=`df -m / | grep "/$" | tr -s ' ' | cut -d' ' -f4` if [ "$space_avail" -lt "$space_required" ] then echo "Space required: $space_required MB" echo "Space available: $space_avail MB" echo colecho "Not enough harddisk space available." br b br echo retval=255 fi fi if [ $retval -eq 0 ] then $wget $choice_url retval=$? fi if [ $retval -eq 0 -a ! -f /tmp/$b ] then colecho "Error downloading file. Please try again." br b br echo retval=255 fi if [ $retval -eq 0 -a "$sha1sum" != "" ] then echo "$sha1sum /tmp/$b" | $chksum --check --status if [ $? -ne 0 ] then colecho "Error downloading file. Please try again." br b br echo retval=255 fi fi if [ $retval -ne 0 ] then colecho "Error occured. Get help." br b br else echo "Please wait..." cd / rm -f /tmp/preinstall.sh case $b in *.tar.bz2) cmd=bzcat ;; *) cmd=zcat ;; esac $cmd /tmp/$b | tar $taroption -x -f - tmp/preinstall.sh 2>/dev/null chown root.root /tmp chmod 1777 /tmp # some packages destroy it if [ -f /tmp/preinstall.sh ] then sh /tmp/preinstall.sh $choice_url pre_rtc=$? rm /tmp/preinstall.sh else pre_rtc=0 fi if [ $pre_rtc -ne 0 ] then echo "Installation aborted due to previous error" else rm -f /tmp/install.sh case $b in *.tar.bz2) cmd=bzcat ;; *) cmd=zcat ;; esac $cmd /tmp/$b | tar $taroption -x -f - 2>/tmp/install.log if [ ! -s /tmp/install.log ] # empty? then # yes... rm -f /tmp/install.log # remove it fi chown root.root /tmp chmod 1777 /tmp # some packages destroy it rm -f /tmp/preinstall.sh # fm 19.07.2003: remove again if [ -f /tmp/install.sh ] then sh /tmp/install.sh $choice_url rm -f /tmp/install.sh fi fi fi rm -f /tmp/$b fi else # remove when no install test -f $req && rm -f $req fi } infotag() { if [ "$info_url" != "" ] then read_info $info_url # check if package = usb if [ ! ${package_name} = usb ] then # check if package to list on eis-list on tty if `echo "${system_info}" | grep -q "${system_work}$"` then # if equal package_status=`$basedir/check-version $package_name $package_version` case "$package_status" in new) package_status="$new_status" ;; old) package_status="$old_status" ;; installed) package_status="$inst_status" ;; not-installed) package_status="$notinst_status" ;; *) package_status="$unknown_status" ;; esac # set the output string # check first the $package_version_length if [ "${package_version_length}" -le 7 ] then # like -> 1.20.90 = 7 # get COLUMNS - 3 from screen to set $package string # to make a controlled line break text_len=`expr "${_EISLIB_SCREENSIZE_X}" - 30` # check is $package_length - $text_len -le 3 # then print the full $package string in one line if [ `expr "${package_length}" - "${text_len}"` -le 3 ] then text_len=${package_length} fi printf " %3s. %1s %s %-8s %.${text_len}s \n" ${n} ${package_status} ${package_stat} ${package_version} "${package}" line_count=`expr ${line_count} + 1` # if $pckage string -gt then $text_len then print second line if [ ${package_length} -gt ${text_len} ] then text_len=`expr "${text_len}" + 1` second_len=`echo "${package}" | cut -c${text_len}-` printf " %s \n" "${second_len}" line_count=`expr ${line_count} + 1` fi else # like -> 1.20.90svn2007-01-29 = >7 text_len=`expr "${_EISLIB_SCREENSIZE_X}" - 40` if [ `expr "${package_length}" - "${text_len}"` -le 3 ] then text_len=${package_length} fi printf " %3s. %1s %-21s %.${text_len}s \n" ${n} ${package_status} ${package_version} "${package}" line_count=`expr ${line_count} + 1` if [ ${package_length} -gt ${text_len} ] then text_len=`expr "${text_len}" + 1` second_len=`echo "${package}" | cut -c${text_len}-` printf " %s \n" "${second_len}" line_count=`expr ${line_count} + 1` fi fi eval package_$n='"$package"' eval info_url_$n='"$info_url"' eval url_$n='"$download_url"' eval type_$n='package' package_status="$unknown_status" else # if not equal # set $n -1 if package is not to list on tty n=`expr $n - 1` fi else # if package = usb n=`expr $n - 1` fi else printf " %3s. \n" ${n} fi } #---------------------------------------------------------------------------- # main #---------------------------------------------------------------------------- pgmname=$0 dir=`dirname $pgmname` case "$dir" in /*) ;; .) pgmname=`pwd`/`basename $pgmname`;; *) pgmname=`pwd`/$pgmname;; esac cd /tmp tty=`tty` if [ "$1" = "" ] then url=`cat /var/install/url` case "$url" in "file:///cdrom/"*) mount_cdrom ;; esac do_ask=yes else if [ "$1" = "-y" ] then do_ask=no shift else do_ask=yes fi delete_index=false if [ "${1}" = "-l" ] then get_index_url "${2}" delete_index=true shift; shift else if [ -z "${index_url}" ] then get_index_url "http://www.pack-eis.de/index.txt" delete_index=true fi fi if [ "$1" = "-i" ] then if [ $# -eq 4 ] then package=$2 choice_url=$3 info_url=$4 else info_url=$2 read_info $info_url package=$package_name choice_url=$download_url current_url=$download_url fi f_install_package if [ -s /tmp/install.log ] then echo "Some warnings/errors have been logged." if $basedir/ask "Show them?" then pager=$PAGER if [ "$pager" = "" ] then pager=less fi $pager /tmp/install.log fi fi umount_cdrom if [ ${delete_index} = true ] then rm -f /tmp/index.txt delete_index=false fi exit 0 else url=$1 fi fi current_url=$url package_status='?' while [ 1 ] do # check if console minium 80x24 check_screensize case ${?} in 0) # nothing to do ;; *) exit 1 ;; esac while [ 1 ] do # set line_count line_count=0 # set echo_count echo_count=0 cd /tmp echo colecho "Install package" gn echo echo "Retrieving list ..." base_url=`basename $url` rm -f $base_url $wget $url rc1=$? /usr/local/bin/dtou $base_url rc2=$? if [ $rc1 -ne 0 -o $rc2 -ne 0 ] then colecho "Error occured. Get help." br b br umount_cdrom exit 1 fi clrhome colecho "Install package - $url" gn echo line_count=`expr ${line_count} + 2` redirect=false index_read=false n=0 while read line do refresh_screensize case "$line" in "#"*) set -- $line version="$2" echo " Version $version" line_count=`expr ${line_count} + 1` ;; "#"*) set -- $line index="$2" get_index_url "${index}" ;; "#"*) if [ $n -eq 0 ] then if [ ${echo_count} -eq 0 ] then echo line_count=`expr ${line_count} + 1` echo_count=1 fi fi n=`expr $n + 1` unset IFS set -- $line shift info_url=$1 infotag ;; "#"*) set -- $line shift req_version=`echo "$1" | sed 's/>.*//g'` st=`/var/install/bin/check-version base $req_version` if [ "$st" != new ] then if [ $n -eq 0 ] then if [ ${echo_count} -eq 0 ] then echo line_count=`expr ${line_count} + 1` echo_count=1 fi fi n=`expr $n + 1` unset IFS shift info_url=$1 infotag fi ;; "#"*) set -- $line shift message="$*" echo " $message" line_count=`expr ${line_count} + 1` ;; "#"*) set -- $line shift welcome="$*" # check for welcome message case "${*}" in "It is strongly recommended to upgrade"*) pack_eis_version=`echo "${*}" | sed 's/^.* //g'` installed_version=`${basedir}/check-version "base" ${pack_eis_version}` # if update is done then print this message case ${installed_version} in installed|old) welcome="Your eisfair server, base version, is uptodate" ;; esac ;; esac colecho " $welcome" x x br line_count=`expr ${line_count} + 1` ;; "#" | "#"*) echo line_count=`expr ${line_count} + 1` ;; "#"*) set -- $line shift url="$1" echo "Got redirection:" echo "$url" echo line_count=`expr ${line_count} + 3` if $basedir/ask "Follow redirection" <$tty then echo $url >/var/install/url current_url=$url redirect=true break fi ;; "#"*) if [ $n = 0 ] then if [ ${echo_count} -eq 0 ] then echo line_count=`expr ${line_count} + 1` echo_count=1 fi fi n=`expr $n + 1` set -- $line shift link_url="$1" shift link_length=`expr length "${*}"` # get COLUMNS - 3 from screen to set $link string # to make a controlled line break text_len=`expr "${_EISLIB_SCREENSIZE_X}" - 20` # check is $link_length - $text_len -le 3 # then print the full $link string in one line if [ `expr "${link_length}" - "${text_len}"` -le 3 ] then text_len=${link_length} fi printf " %3s. %1s %.${text_len}s \n" ${n} ${link_status} "${*}" line_count=`expr ${line_count} + 1` # if $link string -gt then $text_len then print second line if [ ${link_length} -gt ${text_len} ] then text_len=`expr "${text_len}" + 1` second_len=`echo "${*}" | cut -c${text_len}-` printf " %s \n" "${second_len}" line_count=`expr ${line_count} + 1` fi eval info_url_$n='' eval url_$n='"$link_url"' eval type_$n='link' ;; "#"*) set -- $line shift req_version=`echo "$1" | sed 's/>.*//g'` st=`/var/install/bin/check-version base $req_version` if [ "$st" != new ] then if [ $n = 0 ] then if [ ${echo_count} -eq 0 ] then echo line_count=`expr ${line_count} + 1` echo_count=1 fi fi n=`expr $n + 1` shift link_url="$1" shift link_length=`expr length "${*}"` # get COLUMNS - 3 from screen to set $link string # to make a controlled line break text_len=`expr "${_EISLIB_SCREENSIZE_X}" - 20` # check is $link_length - $text_len -le 3 # then print the full $link string in one line if [ `expr "${link_length}" - "${text_len}"` -le 3 ] then text_len=${link_length} fi printf " %3s. %1s %.${text_len}s \n" ${n} ${link_status} "${*}" line_count=`expr ${line_count} + 1` # if $link string -gt then $text_len then print second line if [ ${link_length} -gt ${text_len} ] then text_len=`expr "${text_len}" + 1` second_len=`echo "${*}" | cut -c${text_len}-` printf " %s \n" "${second_len}" line_count=`expr ${line_count} + 1` fi eval info_url_$n='' eval url_$n='"$link_url"' eval type_$n='link' fi ;; "#" | "#"*) read line ;; "#"*) ;; *) if [ $n = 0 ] then if [ ${echo_count} -eq 0 ] then echo line_count=`expr ${line_count} + 1` echo_count=1 fi fi n=`expr $n + 1` set -- $line download_url="$1" shift package="$*" if [ $n -le 9 ] then echo " $n. $package_status $package" line_count=`expr ${line_count} + 1` else echo " $n. $package_status $package" line_count=`expr ${line_count} + 1` fi eval package_$n='"$package"' eval info_url_$n='' eval url_$n='"$download_url"' eval type_$n='package' package_status='?' ;; esac done < $base_url rm -f $base_url if [ -z "${index_url}" ] then get_index_url "http://www.pack-eis.de/index.txt" fi if [ $redirect = false ] then break fi done # added 4 lines as place holder for the footer mecho mecho mecho mecho gotoyx `expr "${_EISLIB_SCREENSIZE_Y}" - 4` 1 mecho mecho "$unknown_status = unknown $notinst_status = not installed $new_status = New $old_status = Old $inst_status = Installed $link_status = Link" # set info line to screen is $line_count + 6 -gt $LINES if [ ${_EISLIB_SCREENSIZE_Y} -lt `expr "${line_count}" + 6` ] then mecho -info "Use SHIFT + PAGE-UP to scroll up" else mecho fi # use ask now base 1.4.1 a=`/var/install/bin/ask "Package to install" "" "1-$n" "^$=Return" "0=Exit"` #echo -e "Package to install (1-$n, ENTER=Return, 0=Exit) \c" #read a if [ "$a" = "0" ] then umount_cdrom if [ $index_read = true ] then rm -f /tmp/index.txt index_read=false fi exit 127 fi if [ "$a" = "" ] then umount_cdrom if [ $index_read = true ] then rm -f /tmp/index.txt index_read=false fi exit 0 fi case "$a" in [0-9]*) is_numeric=true;; *) is_numeric=false; a=0;; esac if [ $is_numeric = true -a $a -ge 1 -a $a -le $n ] then eval info_url='$info_url_'$a eval choice_url='$url_'$a eval package='$package_'$a eval type='$type_'$a case $choice_url in *:*) ;; *) path=`dirname $current_url` choice_url=$path/$choice_url ;; esac case $type in package) f_install_package ;; link) sh $pgmname $choice_url if [ $? = 127 ] # Exit then umount_cdrom exit 127 fi ;; esac fi url=$current_url if [ $index_read = true ] then rm -f /tmp/index.txt index_read=false fi anykey done umount_cdrom exit 0