#! /bin/sh #---------------------------------------------------------------------------- # del-package - delete package # # Creation: 2001-12-09 ms # Last Update: $Id$ # # Copyright (c) 2001-2002 Michell Schimanski, m.schimanski@tu-bs.de # Copyright (c) 2003-@@YEAR@@ 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. #---------------------------------------------------------------------------- # include eislib . /var/install/include/eislib # include packagelib . /var/install/include/packagelib # --------------------------------------------------------------------------- # usage # --------------------------------------------------------------------------- usage () { cat </dev/null ;; esac done < ${filelist} # make sure the file list is removed too rm -f ${filelist} # log result and exit with success code 0 # this procedure will never fail.. hopefully ;-) log_result "without error" return 0 } deinstall_package() { packagename=${1} # check if update is possible if [ -f /var/install/deinstall/${packagename} \ -o -f /etc/filelist.d/${packagename}-files.txt ] then # execute deinstallation if [ -f /var/install/deinstall/${packagename} ] then if uninstall_by_package_script then rtc=0 fi else uninstall_by_filelist rtc=0 fi # show result on screen if [ ${rtc:-1} -eq 0 ] then if ! ${m_update} then # don't show remove message when processing update echo "Package ${packagename} removed." fi else mecho --warn "Package ${packagename} NOT removed." fi else # missing either file list or deinstall script if ! ${m_update} then echo "Unable to deinstall package ${packagename}!" fi fi return ${rtc:-1} } # --------------------------------------------------------------------------- # main # --------------------------------------------------------------------------- main() { if [ ${#} -eq 0 ] then usage exit 1 fi # parse command line arguments update='' m_update=false m_logger='eis-deinstall' while [ ${#} -gt 0 ] do case "${1}" in -h|--help) usage exit 1 ;; --update|update) update="${1}" m_update=true m_logger='eis-update' shift ;; -p) package="${2}" shift; shift ;; *) package="${1}" shift ;; esac done # first check if package realy exists. If not, we are done if [ ! -f /var/install/packages/${package} ] then # package does not exist exit 0 fi # uninstallation is done in several steps, since some library # packages come with -dev and -dev-static counterparts that # also have to be removed (in case this is not a deinstallation # during an update procedure) # step 1: uninstall the given package if ! deinstall_package ${package} then exit 1 fi # step 2: if we are uninstalling a library, remove -dev package too if [ ${m_update} = "false" -a -f /var/install/packages/${package}-dev ] then if ! deinstall_package ${package}-dev then exit 1 fi fi # step 3: if we are uninstalling a library, remove -dev package too if [ ${m_update} = "false" -a -f /var/install/packages/${package}-dev-static ] then if ! deinstall_package ${package}-dev-static then exit 1 fi fi # step 4: if we only uninstall a lib-dev package, the lib-dev-static # package must be uninstalled to if [ ${m_update} = "false" -a -f /var/install/packages/${package}-static ] then if ! deinstall_package ${package}-static then exit 1 fi fi exit 0 } # --------------------------------------------------------------------------- # call function main # --------------------------------------------------------------------------- main "${@}" # --------------------------------------------------------------------------- # end # ---------------------------------------------------------------------------