#!/bin/sh #--------------------------------------------------------------------------- # /var/install/bin/check-package check and search with pack-eis for a package # # Creation: 2006-10-17 hbfl # Last Update: $Id$ # # Copyright (c) 2006-2007 the eisfair team, team(at)eisfair(dot)org # # 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. #--------------------------------------------------------------------------- #--------------------------------------------------------------------------- # usage # check-package # -p, --setpackage packages_name # -v, --setversion packages_version # msg_do_now write a message do now # # Example: check-package -p perl -v 1.2.0 "SUBVERSION_TOOLS_USE_PERL" # #--------------------------------------------------------------------------- #exec 2> /tmp/versuch-trace$$.log #set -x # include eislib . /var/install/include/eislib # set ask ask=/var/install/bin/ask #--------------------------------------------------------------------------- # check package #--------------------------------------------------------------------------- check_package () { create_package="${1}" msg_do_now="${2}" check_version="${3}" # check for version installed_version=`/var/install/bin/check-version "${create_package}" "${check_version}"` case ${installed_version} in not-installed) # is not installed echo mecho -info "${msg_do_now}" mecho -warn "Package '${create_package}' is missing." echo ask_for_install ;; new) # is to old echo mecho -info "${msg_do_now}" mecho -info "'${create_package}' package version must be ${check_version} or higher." echo ask_for_install ;; old|installed) # is good exit 0 ;; esac } #--------------------------------------------------------------------------- # ask for install #--------------------------------------------------------------------------- ask_for_install () { # ask for install mecho "OK, lets go to install it now," ${ask} "Is that right, OK?" 'y' case ${?} in 0) # when yes search_for_package ;; *) # when no echo mecho -info "${msg_do_now}" mecho -warn "OK, your answer is no, solve that first." echo anykey exit 1 ;; esac } #--------------------------------------------------------------------------- # search for package #--------------------------------------------------------------------------- search_for_package () { server=www.pack-eis.de # check if pack-eis is online or the internet connect is down /usr/local/bin/wget.sh ${server} >/dev/null 2>&1 case ${?} in 0) # when OK # do install /var/install/bin/install-package "http://${server}/index.php?q=${create_package}&type=eis-list" # check, is the right version installed now check_package "${package}" "${msg}" "${version}" ;; *) # when not OK echo mecho -info "${msg_do_now}" mecho -warn "No connect to '${server}'." mecho -warn "Please solve that first." echo anykey exit 1 ;; esac } #--------------------------------------------------------------------------- # main #--------------------------------------------------------------------------- package='' version='0.0.1' msg='' # check for cmd line input case ${#} in 0|1|2) # print usage cat <