[CentOS] Re: Problems with yum/rpm and %pre scriptlet error 255

Wed Nov 8 21:09:25 UTC 2006
James B. Byrne <byrnejb at harte-lyne.ca>

On Wed, November 8, 20:47:33 UTC 2006, Jim Perrin wrote:

> rpm -qp --scripts Adobe_rpm_name_here.rpm
>
> This will query the package and should produce output telling you what
> pre and post scripts it's trying to run. From there we can debug
> further.

This is the output:

# rpm -qp --scripts AdobeReader_enu-7.0.8-1.i386.rpm
preinstall program: /bin/sh
postinstall scriptlet (using /bin/sh):

UpdateOldGnomeFile()
{
    awk '
BEGIN   { state = 0; }

/^application\/pdf$/    {
        state = 1;
        print $0;
        next;
    }

/^[^ \t].*/ {
        state = 0;
        print $0;
        next;
    }

/^[ \t][ \t]*default_application_id=/ && (state == 1) {
        print gensub(/(^[ \t][ \t]*default_application_id=).*$/,
"\\1acroread", "g");
        next;
    }

/.*/    { print $0 }' "$1" > /tmp/acroread.tmp 2>/dev/null

    if [ $? -eq 0 ]; then
        mv -f /tmp/acroread.tmp "$1" 2>/dev/null || rm -f
/tmp/acroread.tmp 2>/dev/null
    fi
}


ReadKDEConfigFile()
{
    awk '
BEGIN     { state = 0; MaxPreference = 0; MaxIndex = 0; }

/^[ \t]*\[([^ ]*)[ \t]*-[ \t]*([0-9][0-9]*)[ \t]*\][ \t]*$/  {
                                        app_type = gensub(/^[ \t]*\[([^
]*)[ \t]*-[ \t]*([0-9][0-9]*)[
\t]*\][ \t]*$/, "\\1", "g");
                                        if ( app_type == "application/pdf" )
                                        {
                                            state = 1;
                                            app_index = gensub(/\[(.*)[
\t]*-[ \t]*([0-9][0-9]*)\]$/,
"\\2", "g");
                                            if ( MaxIndex < app_index )
                                                MaxIndex = app_index;
                                        }
                                        else
                                            state = 0;
                                }

/^[ \t]*Preference[ \t]*=[ \t]*[0-9][0-9]*[ \t]*$/ {
                                        if (state == 1) {
                                           app_pref = gensub(/^[
\t]*Preference=[
\t]*([0-9][0-9]*)[ \t]*$/,
"\\1", "g");
                                           if ( MaxPreference < app_pref )
                                                MaxPreference = app_pref;
                                        }
                                     }
/.*/      { print $0 }

END       { printf("\n[application/pdf -
%d]\nAllowAsDefault=true\nApplication=AdobeReader.desktop\nGenericServiceType=Application\nPreference=%d\nServiceType=application/pdf\n",
MaxIndex + 1, MaxPreference + 1);}' "$1" > /tmp/acroread.tmp 2>/dev/null

    if [ $? -eq 0 ]; then
        mv -f /tmp/acroread.tmp "$1" 2>/dev/null || rm -f
/tmp/acroread.tmp 2>/dev/null
    fi
}


UpdateIcon()
{
    if [ -n "$1" -a -n "$2" ]; then
        rm -f "$2" 2>/dev/null
        ln -s "$1" "$2" 2>/dev/null
    fi
}


# $1 => Directory where Adobe Acrobat is installed

UpdateDefaultIcons()
{
    InstallDir="$1"

    if [ -z "$InstallDir" ]; then
        exit 1
    fi

    for IconSize in 16x16 20x20 24x24 32x32 36x36 48x48 64x64 96x96
128x128 192x192; do
        for gnomeDir in
"$GNOME_BASE_DIR/share/icons/Bluecurve/$IconSize/mimetypes"
"$GNOME_BASE_DIR/share/icons/hicolor/$IconSize/apps"
"$GNOME_BASE_DIR/share/icons/gnome/$IconSize/mimetypes" ; do
            if [ -d "$gnomeDir" ]; then
                UpdateIcon
"$InstallDir/Resource/Icons/$IconSize/AdobeReader.png"
"$gnomeDir/gnome-mime-application-pdf.png" 2>/dev/null
                UpdateIcon
"$InstallDir/Resource/Icons/$IconSize/vnd.fdf.png"
"$gnomeDir/gnome-mime-application-vnd.fdf.png" 2>/dev/null
                UpdateIcon
"$InstallDir/Resource/Icons/$IconSize/vnd.adobe.pdx.png"
"$gnomeDir/gnome-mime-application-vnd.adobe.pdx.png"
2>/dev/null
                UpdateIcon
"$InstallDir/Resource/Icons/$IconSize/vnd.adobe.xdp+xml.png"
"$gnomeDir/gnome-mime-application-vnd.adobe.xdp+xml.png"
2>/dev/null
                UpdateIcon
"$InstallDir/Resource/Icons/$IconSize/vnd.adobe.xfdf.png"
"$gnomeDir/gnome-mime-application-vnd.adobe.xfdf.png"
2>/dev/null
            fi
        done

        for kdeDir in
"$KDE_BASE_DIR/share/icons/Bluecurve/$IconSize/mimetypes"
"$KDE_BASE_DIR/share/icons/default.kde/$IconSize/mimetypes"
"$KDE_BASE_DIR/share/icons/hicolor/$IconSize/apps" ; do
            if [ -d "$kdeDir" ]; then
                UpdateIcon
"$InstallDir/Resource/Icons/$IconSize/AdobeReader.png"
"$kdeDir/pdf.png" 2>/dev/null
                UpdateIcon
"$InstallDir/Resource/Icons/$IconSize/vnd.fdf.png"
"$kdeDir/vnd.fdf.png" 2>/dev/null
                UpdateIcon
"$InstallDir/Resource/Icons/$IconSize/vnd.adobe.pdx.png"
"$kdeDir/vnd.adobe.pdx.png" 2>/dev/null
                UpdateIcon
"$InstallDir/Resource/Icons/$IconSize/vnd.adobe.xdp+xml.png"
"$kdeDir/vnd.adobe.xdp+xml.png" 2>/dev/null
                UpdateIcon
"$InstallDir/Resource/Icons/$IconSize/vnd.adobe.xfdf.png"
"$kdeDir/vnd.adobe.xfdf.png" 2>/dev/null
            fi
        done
    done
}


UpdateConfigurationFiles()
{
    GNOME_CONFIG_FILE="$GNOME_BASE_DIR/share/applications/defaults.list"
    GNOME_OLD_CONFIG_FILE="$GNOME_BASE_DIR/share/mime-info/gnome-vfs.keys"
    KDE_CONFIG_FILE="$KDE_BASE_DIR/share/config/profilerc"

    if [ -f "$GNOME_CONFIG_FILE" ]; then
        ( grep -v "^application\/pdf=." < "$GNOME_CONFIG_FILE" ; echo
'application/pdf=AdobeReader.desktop' ) > /tmp/acroread.tmp
2>/dev/null
        mv -f /tmp/acroread.tmp "$GNOME_CONFIG_FILE" 2>/dev/null || rm -f
/tmp/acroread.tmp 2>/dev/null
    else
        if [ -f "$GNOME_OLD_CONFIG_FILE" ]; then
            UpdateOldGnomeFile  "$GNOME_OLD_CONFIG_FILE"
        fi
    fi

    if [ -f "$KDE_CONFIG_FILE" ]; then
        ReadKDEConfigFile "$KDE_CONFIG_FILE"
    fi

    rm -f /tmp/acroread.tmp 2>/dev/null
}


##SOFT LINK
#remove any leftover

if ( echo foo > /usr/bin/AcroWriteTest ) 2> /dev/null ; then
      rm -f /usr/bin/AcroWriteTest

        rm -f /usr/bin/acroread  2> /dev/null

        ##install link
        if [ -n "$RPM_INSTALL_PREFIX" ]; then
          ln -s "$RPM_INSTALL_PREFIX"/bin/acroread /usr/bin/acroread
        else
          ln -s /usr/local/Adobe/Acrobat7.0/bin/acroread /usr/bin/acroread
        fi

else
        echo " "
fi

#
# Check a given file in given path
#
check_file_in_named_path()
{
    if [ -x "$2/$1" ] ; then
        return 1
    fi

    return 0
}


#
# Check a given file in $PATH
#
check_file_in_path()
{
    OLD_IFS=$IFS
    IFS=":"

    if [ -n "$PATH" ] ; then
        for i in $PATH; do
            if [ -d "$i" ] ; then
                check_file_in_named_path "$1" "$i"
                if [ $? -eq 1 ]; then
                    IFS=$OLD_IFS
                    echo "$i/$1"
                    return 1
                fi
            fi
        done
    fi

    IFS=$OLD_IFS
    return 0
}

#Make Soft Links To gnome-speech libraries
MakeLibGnomeSpeechLinks()
{
InstallDir="$1/Reader"

TESTSPEECHEXEC=`check_file_in_path "test-speech"`
if [ $? -ne 0 ]
then
        check_file_in_path "ldd" >/dev/null
        if [ $? -ne 0 ]
        then
                check_file_in_path "sed" >/dev/null
                if [ $? -ne 0 ]
                then
                        rm -f "$InstallDir"/intellinux/lib/libORBit-2.so
2>/dev/null
                        rm -f "$InstallDir"/intellinux/lib/libbonobo-2.so
2>/dev/null
                        rm -f
"$InstallDir"/intellinux/lib/libbonobo-activation.so
2>/dev/null
                        rm -f
"$InstallDir"/intellinux/lib/libgnomespeech.so
2>/dev/null

                        TrimCmd="sed -e 's/^[ \t]*\([^ \t]\)\(.*\)\([^
\t]\)[ \t]*$/\1\2\3/g'"
                        LIB_ORBit2="`ldd $TESTSPEECHEXEC 2>/dev/null |
grep -i libORBit-2.* | cut -d '>' -f2 | cut -d '('
-f 1 | sh -c "$TrimCmd" `"
                        LIB_BONOBO="`ldd $TESTSPEECHEXEC 2>/dev/null |
grep -i bonobo-2.* | cut -d '>' -f2 | cut -d '('
-f 1 | sh -c "$TrimCmd" `"
                        LIB_BONOBOACTIVATION="`ldd $TESTSPEECHEXEC
2>/dev/null | grep -i bonobo-activation.* | cut -d
'>' -f2 | cut -d '(' -f 1 | sh -c "$TrimCmd" `"
                        LIB_GNOMESPEECH="`ldd $TESTSPEECHEXEC 2>/dev/null
| grep -i libgnomespeech.* | cut -d '>' -f2 | cut
-d '(' -f 1 | sh -c "$TrimCmd" `"
                        if [ -f "$LIB_ORBit2" -a -f "$LIB_BONOBO" -a -f
"$LIB_BONOBOACTIVATION" -a -f "$LIB_GNOMESPEECH" ]
                        then
                                ln -s "$LIB_ORBit2"
"$InstallDir/intellinux/lib/libORBit-2.so"
                                ln -s "$LIB_BONOBO"
"$InstallDir/intellinux/lib/libbonobo-2.so"
                                ln -s "$LIB_BONOBOACTIVATION"
"$InstallDir/intellinux/lib/libbonobo-activation.so"
                                ln -s "$LIB_GNOMESPEECH"
"$InstallDir/intellinux/lib/libgnomespeech.so"
                        fi
                fi
        fi
fi
}

if [ `uname -s` = "Linux" ] ; then

        InstallDir="$RPM_INSTALL_PREFIX"/Reader

        if [ ! -e /usr/lib/libldap.so ]
        then
                rm -f "$InstallDir"/intellinux/lib/libldap.so 2>/dev/null

                LIB_LDAP=`ls -tr /usr/lib/libldap.so*  2>/dev/null | tail
-n 1`

                if [ "$LIB_LDAP" = "" ]
                then
                        LIB_LDAP=`ls -tr /usr/lib/libldap* 2>/dev/null |
grep -v libldap_r | grep -v libldapcpp | grep
'\.so' | tail -n 1`
                fi

                if [ "$LIB_LDAP" != "" ]
                then
                        ln -s $LIB_LDAP
"$InstallDir"/intellinux/lib/libldap.so
                fi
        fi

        if [ ! -e /usr/lib/liblber.so ]
        then
                rm -f "$InstallDir"/intellinux/lib/liblber.so 2>/dev/null

                LIB_LBER=`ls -tr /usr/lib/liblber.so* 2>/dev/null | tail
-n 1`

                if [ "$LIB_LBER" = "" ]
                then
                        LIB_LBER=`ls -tr /usr/lib/liblber* 2>/dev/null |
grep -v liblber_r | grep '\.so' | tail -n 1`
                fi

                if [ "$LIB_LBER" != "" ]
                then
                        ln -s $LIB_LBER
"$InstallDir"/intellinux/lib/liblber.so
                fi
        fi

        #Make Soft Links To gnome-speech libraries
        MakeLibGnomeSpeechLinks "$RPM_INSTALL_PREFIX"
fi

check_file_in_path kde-config >/dev/null

if [ $? -ne 0 ]; then
    KDE_BASE_DIR="`kde-config --prefix`"
elif [ -x /opt/kde3/bin/kde-config ]; then
    KDE_BASE_DIR="/opt/kde3"
elif [ -x /opt/kde/bin/kde-config ]; then
    KDE_BASE_DIR="/opt/kde"
else
    KDE_BASE_DIR="/usr"
fi

GNOME_BASE_DIR=`check_file_in_path gnome-open`

if [ $? -ne 0 ]; then
    GNOME_BASE_DIR=`dirname "$GNOME_BASE_DIR"`
    GNOME_BASE_DIR=`dirname "$GNOME_BASE_DIR"`
elif [ -x /opt/gnome/bin/gnome-open ]; then
    GNOME_BASE_DIR="/opt/gnome"
else
    GNOME_BASE_DIR="/usr"
fi

if [ "$GNOME_BASE_DIR" != "/usr" ]; then
    UpdateIcon /usr/share/applications/AdobeReader.desktop
"$GNOME_BASE_DIR/share/applications/AdobeReader.desktop"
fi

if [ "$KDE_BASE_DIR" != "/usr" ]; then
    UpdateIcon /usr/share/applnk/Applications/AdobeReader.desktop
"$KDE_BASE_DIR/share/applnk/Applications/AdobeReader.desktop"
fi

UpdateIcon /usr/share/applnk/Applications/AdobeReader.desktop
"$KDE_BASE_DIR/share/applications/kde/AdobeReader.desktop"

UpdateDefaultIcons "$RPM_INSTALL_PREFIX"
UpdateConfigurationFiles

if [ -d "$GNOME_BASE_DIR/share/mime/packages" ]; then
    UpdateIcon "$RPM_INSTALL_PREFIX/Resource/Support/AdobeReader.xml"
"$GNOME_BASE_DIR/share/mime/packages/AdobeReader.xml"
fi

if [ -d "$KDE_BASE_DIR/share/mimelnk/application" ]; then
    UpdateIcon "$RPM_INSTALL_PREFIX/Resource/Support/vnd.fdf.desktop"
"$KDE_BASE_DIR/share/mimelnk/application/vnd.fdf.desktop"
    UpdateIcon
"$RPM_INSTALL_PREFIX/Resource/Support/vnd.adobe.pdx.desktop"
"$KDE_BASE_DIR/share/mimelnk/application/vnd.adobe.pdx.desktop"
    UpdateIcon
"$RPM_INSTALL_PREFIX/Resource/Support/vnd.adobe.xdp+xml.desktop"
"$KDE_BASE_DIR/share/mimelnk/application/vnd.adobe.xdp+xml.desktop"
    UpdateIcon
"$RPM_INSTALL_PREFIX/Resource/Support/vnd.adobe.xfdf.desktop"
"$KDE_BASE_DIR/share/mimelnk/application/vnd.adobe.xfdf.desktop"
fi

if [ `which update-mime-database 2>/dev/null` ]; then
    update-mime-database "$GNOME_BASE_DIR/share/mime" >/dev/null 2>&1
fi

if [ `which update-desktop-database 2>/dev/null` ]; then
        update-desktop-database >/dev/null 2>&1
fi


exit 0
preuninstall program: /bin/sh
postuninstall scriptlet (using /bin/sh):



if [ -d "$RPM_INSTALL_PREFIX" -o -d `dirname "$RPM_INSTALL_PREFIX" 2>
/dev/null` ]; then

        CAN_BASE_DIR_BE_DELETED="YES"
        OLD_IFS="$IFS"
        IFS="
"

        for i in `find "$RPM_INSTALL_PREFIX" -type f 2> /dev/null `; do
                if [ -n "$i" ]; then
                                CAN_BASE_DIR_BE_DELETED="NO"

                fi
        done

        IFS="$OLD_IFS"



##Remove the Acrobat7.0 directory
BASENAME_RPM_INSTALL=`basename "$RPM_INSTALL_PREFIX" 2> /dev/null`
DIRNAME_RPM_INSTALL=`dirname "$RPM_INSTALL_PREFIX" 2> /dev/null`

        if [ "$BASENAME_RPM_INSTALL" = "Acrobat7.0" -a
"$DIRNAME_RPM_INSTALL" = "/usr/local/Adobe" -a
$CAN_BASE_DIR_BE_DELETED = "YES" ]; then
                #Try removing Acrobat 7 directory
                rm -rf  "$RPM_INSTALL_PREFIX" 2> /dev/null
                #Try removing Adobe directory as well
                if [ $? -eq 0 ]; then

                        if [ -z `find "$DIRNAME_RPM_INSTALL" -type f 2>
/dev/null` ]; then
                                rm -rf "$DIRNAME_RPM_INSTALL" 2> /dev/null
                        else
                                CAN_BASE_DIR_BE_DELETED="NO"

                        fi

                else
                        CAN_BASE_DIR_BE_DELETED="NO"

                fi

        fi
fi

GNOME_BASE_DIR=`which gnome-open 2>/dev/null`

if [ $? -eq 0 ]; then
    GNOME_BASE_DIR=`dirname "$GNOME_BASE_DIR"`
    GNOME_BASE_DIR=`dirname "$GNOME_BASE_DIR"`
elif [ -x /opt/gnome/bin/gnome-open ]; then
    GNOME_BASE_DIR="/opt/gnome"
else
    GNOME_BASE_DIR="/usr"
fi

if [ `which update-mime-database 2>/dev/null` ]; then
    update-mime-database "$GNOME_BASE_DIR/share/mime" >/dev/null 2>&1
fi

if [ `which update-desktop-database 2>/dev/null` ]; then
        update-desktop-database 2>/dev/null
fi

exit


-- 
James B. Byrne                mailto:ByrneJB at Harte-Lyne.ca
Harte & Lyne Limited          http://www.harte-lyne.ca
9 Brockley Drive              vox: +1 905 561 1241
Hamilton, Ontario             fax: +1 905 561 0757
Canada  L8E 3C3