#! /bin/sh #---------------------------------------------------------------------------- # /var/install/bin/install-package - install a package # # Creation : 2001-11-04 fm # Last Update: $Id$ # # Copyright (c) 2001-2012 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. #---------------------------------------------------------------------------- # include eislib . /var/install/include/eislib #debug_install_package=true if ${debug_install_package:-false} then exec 2>/tmp/$(basename ${0})-trace$$.log set -x ask_debug=true export ask_debug fi # set default index url default_index_url="http://www.pack-eis.de/index.txt" 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 # check for EISFAIR_SYSTEM is set, or check it once if [ -z "${EISFAIR_SYSTEM}" ] then # get eisfair system-type . /var/install/include/check-eisfair-version # set eisfair system-type system_work=${EISFAIR_SYSTEM} else # set eisfair system-type system_work=${EISFAIR_SYSTEM} fi # check and include outdated-packages if [ -z "${OUTDATED_PACKAGES}" ] then if [ -f /var/install/outdated-packages ] then OUTDATED_PACKAGES="`grep -v "^#" /var/install/outdated-packages`" else mecho --error "'/var/install/outdated-packages' is missing." mecho --error "Please install the recent base again." echo anykey OUTDATED_PACKAGES="" fi export OUTDATED_PACKAGES fi # check for installed base version first and make integer (strip dots) # then the from eis-list.txt can compare directly, # without check-version, it works faster # this will work for version is in this format 1.5.3 # if the version 1.10.1 the funktion musst changed!! if [ -z "${_installed_base}" ] then _installed_base=`grep "version>" /var/install/packages/base | sed 's###g; s#[cvs|svn].*$##; s#\.##g'` export _installed_base 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=`mecho --warn "n"` old_status=`mecho --std "o"` inst_status=`mecho --info "i"` notinst_status=`mecho --warn "-"` unknown_status=`mecho --stdbr "?"` link_status=`mecho --link ">"` 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 usb_mounted=false mount_cdrom () { if ! mount | grep ' /cdrom' >/dev/null then mount /cdrom cdrom_mounted=true echo "DATETIME" >/tmp/cdrom_installer_mounted fi } umount_cdrom () { if "${cdrom_mounted}" then umount /cdrom cdrom_mounted=false fi } mount_usb () { # extract usb/sd.. from $url like # file:///usb/sd??/download/packages/eis-list.txt usb_dev=`echo ${url} | cut -d/ -f3-5` if ! mount | grep "${usb_dev}" >/dev/null then /var/install/bin/system-devices-mount-usb retvar=${?} if [ ${retvar} -eq 0 ] then usb_mounted=true echo "DATETIME" >/tmp/usb_installer_mounted fi fi } umount_usb () { if "${usb_mounted}" then /var/install/bin/system-devices-umount-usb retvar=${?} if [ ${retvar} -eq 0 ] then usb_mounted=false fi fi } check_xml_status () { # any UMTS Provider drop empty lines and/or newlines marker # from package info file, so we musst prepare the info file # new, then we read line by line # in this place we use the libspxml.so, from the spxml package, # to solved that xml_file=${1} if [ `cat ${xml_file} | wc -l` -le 1 ] then /usr/bin/testdom ${xml_file} >/tmp/${xml_file}-$$ cp /tmp/${xml_file}-$$ ${xml_file} rm -f /tmp/${xml_file}-$$ 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'` # activate it when the xml file is broken # check_xml_status ${base_info_url} /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; s# #-#'`" 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 () { _required=${1} do_disp=${2} disp_rtc=0 req=/tmp/required_${_required}_found-$$ rm -f ${req} d_require="require_${_required}" echo "${!d_require}" | while read p do set -- ${p} require_package=${1} require_version=${2} if [ -z "${require_version}" ] then require_version=0.0.0 fi read_info ${require_package} status=$(${basedir}/check-version ${package_name} ${require_version}) case ${_required} in dev_packages) if [ "$status" = "new" ] then display=true fi ;; *) if [ "${status}" = "new" -o "${status}" = "not-installed" ] then display=true fi ;; esac if ${display:-false} then if [ ! -f ${req} ] then >${req} if ${do_disp:-false} then # create check file for require exists echo datetime >/tmp/_have_require case ${_required} in libs) # if package = lib _required=libraries ;; esac echo case ${_required} in dev_packages) mecho --info "The following 'dev' package where also updated:" ;; *) mecho --info "This package requires the following ${_required}:" ;; esac echo fi fi if ${do_disp:-false} then if [ "${require_version}" != "0.0.0" ] then echo " ${package_name} >= ${require_version} - ${package}" else echo " ${package_name} - ${package}" fi fi if [ -z "${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}" # get the default index url if [ -z "${index}" ] then index="${default_index_url}" fi case ${index} in *:*) _index="--index ${index}" ;; *) index_path=`dirname ${current_url}` index="${index_path}/${index}" _index="--index ${index}" ;; esac _clear='' if [ ! -s /tmp/index.txt ] then _clear="--clear" fi # get-index handle multiple index.txt files /var/install/bin/get-index ${_clear} ${_current_url} ${_index} _index_ret=${?} if [ ${_index_ret} -eq 0 ] then index_url=${index} else # run wget in timeout or something went wrong, # create a dummy index that install can work echo "#datetime" >/tmp/index.txt fi } get_packagename_by_index () { # check if /tmp/index.txt given if [ -z "${index_url}" ] then get_index_url fi name="$1" # check for outdated packages if ! `echo "${OUTDATED_PACKAGES}" | grep -q "^${name}:"` then name="$1" version="$2" if [ -n "${version}" ] then # grep first for require Version small_index=$(grep "^${name} " /tmp/index.txt | grep "${version} ") fi if [ -z "${small_index}" ] then # grep to do it a little faster small_index=$(grep "^${name} " /tmp/index.txt) fi # name="$1" # version="$2" ip=`dirname $index_url` if [ -n "${small_index}" ] then echo "${small_index}" | while read line do set -- ${line} packfile=$4 # fetch info file # check for system version base_packfile=`basename "${packfile}"` rm -f ${base_packfile} case "${packfile}" in *:*) ${wget} -q "${packfile}" ;; *) ${wget} -q "${ip}/${packfile}" ;; esac if [ $? -ne 0 ] then return fi # activate it when the xml file is broken # check_xml_status ${base_packfile} /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; s# #-#'` 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 not 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 echo "${line}" >>/tmp/small-index.txt fi done if [ -f /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 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 fi done 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 } " ${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; s#/#-#g'` echo " Date: "$disp_date ;; ""*) disp_system=`echo "$a" | sed 's###g; s# #-#'` if [ -z "${system_required}" ] then system_required=`echo "${disp_system}"` else system_required=`echo "${system_required}"; \ echo "${disp_system}"` 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'` echo " Space: "${space_required} MB required ;; ""*) if [ $display_require = true ] then disp_require=`echo "$a" | sed 's###g'` echo " Require: "$disp_require fi ;; ""*) require_package=`echo "$a" | sed 's###g'` # check first if required package installed ... set -- ${require_package} r_package=$(basename ${1} | sed 's#\.tar.*$##') r_version=${2} if [ -z "${r_version}" ] then r_version=0.0.0 fi r_status=$(${basedir}/check-version ${r_package} ${r_version}) # ... if not, then do more if [ "${r_status}" = "new" -o "${r_status}" = "not-installed" ] then r=`echo $require_package | sed 's# .*##g'` # strip version if `echo ${r} | egrep -qw "[12]?[0-9]?[0-9]\.[12]?[0-9]?[0-9]\.[12]?[0-9]?[0-9]\.[12]?[0-9]?[0-9]"` then ip=`dirname $current_url` require_package="$ip/$require_package" elif ! ` echo ${r} | grep -q ":"` then require_package=`get_packagename_by_index \ $require_package` fi 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 fi ;; ""*) require_lib=`echo "$a" | sed 's###g'` # check first if required lib installed ... set -- ${require_lib} r_package=$(basename ${1} | sed 's#\.tar.*$##') r_version=${2} if [ -z "${r_version}" ] then r_version=0.0.0 fi r_status=$(${basedir}/check-version ${r_package} ${r_version}) # ... if not, then do more if [ "${r_status}" = "new" -o "${r_status}" = "not-installed" ] then r=`echo $require_lib | sed 's# .*##g'` # strip version if `echo ${r} | egrep -qw "[12]?[0-9]?[0-9]\.[12]?[0-9]?[0-9]\.[12]?[0-9]?[0-9]\.[12]?[0-9]?[0-9]"` then ip=`dirname $current_url` require_lib="$ip/$require_lib" elif ! ` echo ${r} | grep -q ":"` then require_lib=`get_packagename_by_index $require_lib` fi 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_lib#*+}" else base_package=`echo "${base_package}"; \ echo "${require_lib#*+}"` fi ;; *) if [ "$require_libs" = "" ] then require_libs="$require_lib" else require_libs=`echo "$require_libs"; \ echo "$require_lib"` fi ;; esac fi ;; ""*) description_active=true ;; ""*) description_active=false ;; ""*) ;; *) if [ "$description_active" = true ] then echo " $a" fi ;; esac done <$base_info_url rm -f $base_info_url if [ -z "${system_required}" ] then system_required="eisfair-1" fi # check if 'dev' package installed dev_status=$(${basedir}/check-version ${disp_name}-dev ${disp_version}) # if old if [ "${dev_status}" = "new" ] then require_dev_package=$(get_packagename_by_index \ ${disp_name}-dev ${disp_version}) case ${require_dev_package} in non+*) # if package is missing in index.txt file # and strip prefix if [ -z "${missing_package}" ] then missing_package="${require_dev_package#*+}" else missing_package=$(echo "${missing_package}"; \ echo "${require_dev_package#*+}") fi ;; *) if [ -z "$require_dev_packages" ] then require_dev_packages="${require_dev_package}" else require_dev_packages=$(echo "${require_dev_packages}"; \ echo "${require_dev_package}") fi ;; esac fi 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 if [ -n "${require_dev_packages}" ] then f_disp_required dev_packages true disp_rtc=$? fi echo return $disp_rtc # end if ! `echo "${display_system}" | grep -q "${system_work}$"` fi } # get compress info to extract the tarball get_compress_info () { compress_file=${1} case ${compress_file} in *.tar.lzma) cmd=lzcat ;; *.tar.xz) cmd=xzcat ;; *.tar.bz2) cmd=bzcat ;; *) cmd=zcat ;; esac } f_install_package () { if [ "$info_url" != "" ] then clrhome mecho --info "Package: $package" 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 mecho --info "The required package cannot be found." mecho --info "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 # check file for 'a=all' action if [ -f /tmp/_do_all ] then anykey fi # clear up missing_package='' fi # list in base or in other packages included if [ -n "${base_package}" ] then mecho --info "The required package is no longer available." echo techo --begin '2 70*' echo "${base_package}" | while read m_package m_version do o_package=`echo "${OUTDATED_PACKAGES}" | grep "^${m_package}:"` _OLD_IFS="${IFS}" IFS=: # like usb:included in the base:1.4.0. set -- ${o_package} case x${m_version} in x) techo --row "" "${m_package} ${2} > since ${3}" ;; *) techo --row "" "${m_package} >= ${m_version} ${2} > since ${3}" ;; esac IFS="${_OLD_IFS}" done techo --end # clear up base_package='' fi # check file for 'a=all' action if [ -f /tmp/_do_all ] then do_ask=false fi _have_all='' echo if ${do_ask} then # check file for require exists if [ -f /tmp/_have_require ] then _have_all='a=all' fi $basedir/ask "Install" "" "y=yes" "n=no"\ ${_have_all} >/tmp/ask.$$ rc=${?} a=`cat /tmp/ask.$$` rm -f /tmp/ask.$$ # if ask break, ask returned 255 if [ ${rc} = 255 ] then a=no fi case ${a} in Y|y|Yes|yes|YES) do_install=true ;; N|n|No|no|NO) do_install=false ;; A|a|All|all|ALL) do_install=true # create check file for 'a=all' action echo datetime >/tmp/_do_all ;; esac else do_install=true fi if ${do_install} then disp_rtc=0 if [ -n "$require_libs" ] then f_disp_required libs false disp_rtc=$? if [ $disp_rtc -ne 0 ] then mecho --warn "This package requires some other libraries which are unknown." mecho --warn "Installation aborted." 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 -n "$require_packages" ] then f_disp_required packages false disp_rtc=$? if [ $disp_rtc -ne 0 ] then mecho --warn "This package requires some other packages which are unknown." mecho --warn "Installation aborted." 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}'." echo anykey # if the a=all option given, then remove it. remove_check_file retval=255 fi if [ "$space_required" -gt "0" ] then space_avail=`df -m / | awk '/\/$/ { print $4 }'` if [ "$space_avail" -lt "$space_required" ] then echo "Space required : $space_required MB" echo "Space available: $space_avail MB" echo mecho --warn "Not enough harddisk space available." echo # if the a=all option given, then remove it. remove_check_file retval=255 fi fi if [ $retval -eq 0 ] then $wget $choice_url retval=$? fi if [ $retval -eq 0 -a ! -f /tmp/$b ] then mecho --warn "Error downloading file. Please try again." echo # if the a=all option given, then remove it. remove_check_file retval=255 fi if [ $retval -eq 0 -a "$sha1sum" != "" ] then echo "$sha1sum /tmp/$b" | $chksum --check --status if [ $? -ne 0 ] then mecho --warn "Error downloading file. Please try again." echo # if the a=all option given, then remove it. remove_check_file retval=255 fi fi if [ $retval -ne 0 ] then mecho --warn "Error occured. Get help." else echo "Please wait ..." cd / rm -f /tmp/preinstall.sh get_compress_info ${b} $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 get_compress_info ${b} $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 # log installation via syslog { echo "package ${disp_name} ($disp_version|${disp_date}|${b})" echo "($choice_url)" } | /usr/bin/logger -t "eis-install" -p "local5.info" fi fi rm -f /tmp/$b fi # update 'dev' package after 'main' package is installed if [ ${disp_rtc} -eq 0 -a -n "${require_dev_packages}" ] then f_disp_required dev_packages false disp_rtc=${?} if [ ${disp_rtc} -ne 0 ] then mecho --warn "This package requires some other packages which are unknown." mecho --warn "Installation aborted." else if [ -f ${req} ] then rm -f ${req} echo echo "${require_dev_packages}" | while read p do set -- ${p} require_package=${1} require_version=${2} if [ -z "${require_version}" ] then require_version=0.0.0 fi ( read_info ${require_package} status=`${basedir}/check-version ${package_name} ${require_version}` if [ "${status}" = "new" ] then ${basedir}/install-package -i ${require_package} <$tty fi ) done fi fi fi else # remove when no install rm -f /tmp/required_{libs,packages,dev_packages}_found-* require_dev_packages="" fi } infotag() { if [ "$info_url" != "" ] then read_info $info_url # check if package = outdated if ! `echo "${OUTDATED_PACKAGES}" | grep -q "^${package_name}:"` then # check if package to list on eis-list on tty if `echo "${system_info}" | grep -q "${system_work}$"` then # if equal # -list is only for list packages from eisler package_status=`$basedir/check-version -list $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 } remove_check_file () { # delete check file for 'a=all' action rm -f /tmp/_do_all # delete check file for require exists rm -f /tmp/_have_require rm -f /tmp/required_{libs,packages,dev_packages}_found-* } #-------------------------------------------------------------------------- # 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 ;; "file:///usb/"*) mount_usb ;; esac do_ask=true else if [ "$1" = "-y" ] then do_ask=false shift else do_ask=true fi if [ "${1}" = "-l" ] then get_index_url "${2}" shift 2 if [ -z "${index_url}" ] then get_index_url 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 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 remove_check_file while [ 1 ] do # set line_count line_count=0 # set echo_count echo_count=0 rc1='' cd /tmp echo mecho --info "Install package" echo echo "Retrieving list ..." base_url=`basename ${url}` # dir_url=`dirname ${url}` rm -f ${base_url} # rm -f ${EISFAIR_SYSTEM}-${base_url} # # get $dir_url/$EISFAIR_SYSTEM-$base_url first # if `echo ${url} | grep -q "${EISFAIR_SYSTEM}" 2>/dev/null` # then $wget $url # base_url=`basename ${url}` # else # ${wget} ${dir_url}/${EISFAIR_SYSTEM}-${base_url} # rc1=${?} # if [ ${rc1} -eq 0 ] # then # base_url=`basename ${dir_url}/${EISFAIR_SYSTEM}-${base_url}` # url=${dir_url}/${base_url} # else # $wget $url # base_url=`basename ${url}` # fi # fi rc1=$? if [ ${rc1} -ne 0 ] then mecho --warn "Error occured. Get help." remove_check_file # umount_cdrom # umount_usb exit 1 fi /usr/local/bin/dtou $base_url rc2=$? if [ $rc2 -ne 0 ] then mecho --warn "Error occured. Get help." remove_check_file # umount_cdrom # umount_usb exit 1 fi clrhome mecho --info "Install package - $url" echo line_count=`expr ${line_count} + 2` redirect=false # index_read=false # set _n _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 -a ${echo_count} -eq 0 ] then echo line_count=`expr ${line_count} + 1` echo_count=1 fi _n=`expr ${_n} + 1` unset IFS set -- $line shift info_url=$1 infotag ;; "#"*) set -- $line shift # from eis-list.txt make integer (strip dots) # then can compare the $installed version directly, # without check-version, it works faster # this will work for version is in this format 1.5.3 # if the version 1.10.1 the funktion musst changed!! req_version=`echo "$1" | sed 's#[\.|>.*]##g'` _installed_version=true # check for require and installed base version if [ ${req_version} -gt ${_installed_base} ] then _installed_version=false fi if ${_installed_version} # the old stuff # req_version=`echo "$1" | sed 's/>.*//g'` # # st=`/var/install/bin/check-version base $req_version` # if [ "$st" != new ] then if [ ${_n} -eq 0 -a ${echo_count} -eq 0 ] then echo line_count=`expr ${line_count} + 1` echo_count=1 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 up to date." ;; esac ;; esac mecho --stdbr " $welcome" 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} + 1` if $basedir/ask "Follow redirection" <$tty then echo $url >/var/install/url current_url=$url redirect=true break fi ;; "#"*) set -- $line shift # check if package = outdated $3 = packages_name if ! `echo "${OUTDATED_PACKAGES}" | grep -q "^${3}:"` then if [ ${_n} -eq 0 -a ${echo_count} -eq 0 ] then echo line_count=`expr ${line_count} + 1` echo_count=1 fi _n=`expr ${_n} + 1` 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 ;; "#"*) set -- $line shift # check if package = outdated $4 = packages_name if ! `echo "${OUTDATED_PACKAGES}" | grep -q "^${4}:"` then # from eis-list.txt make integer (strip dots) # then can compare the $installed_base directly, # without check-version, it works faster # this will work for version is in this format 1.5.3 # if the version 1.10.1 the funktion musst changed!! req_version=`echo "$1" | sed 's#[\.|>.*]##g'` _installed_version=true # check for require and installed base version if [ ${req_version} -gt ${_installed_base} ] then _installed_version=false fi if ${_installed_version} # the old stuff # req_version=`echo "$1" | sed 's/>.*//g'` # # st=`/var/install/bin/check-version base $req_version` # if [ "$st" != new ] then if [ ${_n} -eq 0 -a ${echo_count} -eq 0 ] then echo line_count=`expr ${line_count} + 1` echo_count=1 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 fi ;; "#" | "#"*) read line ;; "#"*) ;; *) if [ ${_n} -eq 0 -a ${echo_count} -eq 0 ] then echo line_count=`expr ${line_count} + 1` echo_count=1 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 fi if [ $redirect = false ] then break fi done # added 4 lines as place holder for the footer echo echo echo echo techo --end gotoyx `expr "${_EISLIB_SCREENSIZE_Y}" - 4` 1 echo echo "$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 echo fi /var/install/bin/ask "Select" "" "1-${_n}" "^$=Return" "0=Exit" >/tmp/ask.$$ rc=${?} a=`cat /tmp/ask.$$` rm -f /tmp/ask.$$ # if ask break, ask returned 255 if [ ${rc} = 255 ] then a=0 fi case "${a}" in '') remove_check_file # umount_cdrom # umount_usb exit 0 ;; 0) remove_check_file # umount_cdrom # umount_usb exit 127 ;; *) 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 remove_check_file # umount_cdrom # umount_usb exit 127 fi ;; esac ;; esac url=$current_url anykey done remove_check_file #umount_cdrom #umount_usb exit 0