From: Valentin Vidic Date: Wed, 13 May 2009 09:05:36 +0000 (+0200) Subject: Prevent package removal during upgrade of libc6 and dpkg. X-Git-Tag: debian/5.0.0~16 X-Git-Url: http://ftp.carnet.hr/pub/carnet-debian/scm?a=commitdiff_plain;h=9742d3662fe74ee8d7f0d510c9198fedeba13f35;p=carnet-upgrade.git Prevent package removal during upgrade of libc6 and dpkg. --- diff --git a/src/functions.sh b/src/functions.sh index f1b284a..8a76e8b 100644 --- a/src/functions.sh +++ b/src/functions.sh @@ -588,7 +588,7 @@ reboot_required () { } upgrade () { - local i to_install packages + local packages case "$1" in first) packages="$packages_first" @@ -600,16 +600,7 @@ upgrade () { return 1 esac - for i in $(echo $packages) - do - pkg $i && to_install="$to_install $i" - done - - if [ -n "$to_install" ];then - eval pkgadd $to_install - else - return 0 - fi + pkgadd_if_installed $packages } # funkcija utrpa ispravan sources.list @@ -976,7 +967,7 @@ apt_listchanges () { # make a silent installation of carnet and srce keyrings install_keyrings () { pkgadd carnet-keyring srce-keyring debian-archive-keyring - pkgadd dpkg apt debconf python-apt + pkgadd_if_installed dpkg apt debconf python-apt dpkg-dev dpkg-reconfigure carnet-keyring srce-keyring debian-archive-keyring apt_update @@ -1040,30 +1031,39 @@ disable_monit () { fi } +# check which of the given packages are installed +grep_installed () { + local package installed + + for package in $*; do + if pkg $package; then + installed="$installed $package" + fi + done + + echo $installed +} + +# only upgrade packages if they are already installed +pkgadd_if_installed () { + local packages + + packages=$( grep_installed $* ) + + if [ "$packages" ]; then + eval pkgadd $packages + fi +} + # make a silent upgrade to new libc6 upgrade_libc () { - DEBIAN_FRONTEND=noninteractive pkgadd libc6 tzdata + DEBIAN_FRONTEND=noninteractive pkgadd_if_installed libc6 libc6-dev tzdata } # upgrade apache2/php5 to lenny upgrade_apache2 () { - local package packages - - for package in \ - libapache2-mod-php5 \ - php5-cli \ - php5-cn \ - apache2-cn \ - php5-odbc \ - php5-suhosin \ - php-suhosin-cn - do - if pkg $package; then - packages="$packages $package" - fi - done - - eval pkgadd $packages + pkgadd_if_installed libapache2-mod-php5 php5-cli php5-cn apache2-cn \ + php5-odbc php5-suhosin php-suhosin-cn } upgrade_amavis () {