On Sun, 19 Jul 2009, Szymon Janc wrote:
> I've seen this bug report and at the begining I thought the same, but there 
> is 
> no directory in my /var/lib/dpkg/alternatives..

Can you run "sh -e -x dpkg.preinst upgrade 1.15.2" with the attached script
and send me the output? Also send me the content of the last alternatives
file read by the script (will be visible in the log).

I expect one of the files to be broken and have an inconsistent number
of lines... which could lead to a read call failing. I'll fix that
shortly.

> -rw-r--r-- 1 root root    31 2008-02-26  java-rmi.cgi    
> -rw-r--r-- 1 root root    26 2008-07-21  java_vm         
> -rw-r--r-- 1 root root    27 2008-07-21  jcontrol        

One of those very short files could be at fault maybe.

Cheers,
-- 
Raphaël Hertzog

Contribuez à Debian et gagnez un cahier de l'admin Debian Lenny :
http://www.ouaza.com/wp/2009/03/02/contribuer-a-debian-gagner-un-livre/
#!/bin/sh -e
# This script can be called in the following ways:
#
# Before the package is installed:
#       <new-preinst> install
#
# Before removed package is upgraded:
#       <new-preinst> install <old-version>
#
# Before the package is upgraded:
#       <new-preinst> upgrade <old-version>
#
#
# If postrm fails during upgrade or fails on failed upgrade:
#       <old-preinst> abort-upgrade <new-version>

# Handle upgrades from pre-conffile dpkg.cfg
upgrade_dpkg_non_conffile()
{
    if [ -r /etc/dpkg/dpkg.cfg ]; then
        dpkg_cfg_md5="535552ad5ee9145dbc7a34c264df4e59  /etc/dpkg/dpkg.cfg"
        if echo "$dpkg_cfg_md5" | md5sum -c >/dev/null 2>&1; then
            echo "Removing non-modified dpkg.cfg to be replaced by a conffile 
..."
            rm -f /etc/dpkg/dpkg.cfg
        fi
    fi
}

kill_bad_alternatives () {
    local IFS=""
    ALTDIR="/var/lib/dpkg/alternatives"
    for alt in $ALTDIR/*; do
        if [ ! -f $alt ]; then
            # In case it's been removed by the code below, or in case
            # it's not a real file
            continue
        fi
        {
            read mode
            read mainlink
            while true; do
                read slave
                if [ "$slave" = "" ]; then
                    break
                fi
                if [ -e "$ALTDIR/$slave" ]; then
                    echo "Removing conflicting master alternative $slave (it is 
slave of $(basename $alt))..."
                    rm -f "$ALTDIR/$slave"
                fi
                read slavelink
            done
        } <$alt
    done
}

case "$1" in
    install)
        ;;

    upgrade)
        # Cleanup bad alternatives that would choke with new
        # update-alternatives (see #530633, #531611, #532739, #521760)
        if dpkg --compare-versions "$2" lt 1.15.3; then
            kill_bad_alternatives
        fi

        case "$2" in
            # Upgrade from pre-conffile dpkg.cfg
            1.9.21 | 1.10.* )
                upgrade_dpkg_non_conffile
                ;;
        esac
        ;;

    abort-upgrade)
        ;;


    *)
        echo "$0 called with unknown argument \`$1'" 1>&2
        exit 1
        ;;
esac

#DEBHELPER#
exit 0

Reply via email to