1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
#!/bin/sh -e
# A string that denotes the current version of the library:
version=5.1.0-4
# The name of the file that comes from Compaq's web site:
archive=cpml_ev6-5.1.0-4.alpha.rpm
############################################################################
# Use debconf.
. /usr/share/debconf/confmodule
db_version 2.0
# Minimalist rpm2cpio in perl.
# Code taken from http://www.eleves.ens.fr:8080/home/espel/rpm2cpio
rpm2cpio() {
perl -e '
undef $/;
$|=1;
$rpm = <>;
($magic, $major, $minor, undef) = unpack("NCC C90", $rpm);
exit "Not an RPM\n" if $magic != 0xedabeedb;
exit "Not a version 3 RPM\n" if $major != 3;
$rpm = substr($rpm, 96);
while ($rpm ne "") {
$rpm =~ s/^\c@*//s;
($magic, undef, $sections, $bytes) = unpack("N4", $rpm);
$smagic = unpack("n", $rpm);
last if $smagic eq 0x1f8b;
die "Error: header not recognized\n" if $magic != 0x8eade801;
$rpm = substr($rpm, 16*(1+$sections) + $bytes);
}
exit "bogus RPM\n" if $rpm eq "";
open(ZCAT, "|gzip -cd") || die "cannot pipe to gzip\n";
print ZCAT $rpm;
close ZCAT;
' $1
}
abort() {
# Give up. This should never happen (unless the disk fills up or
# something).
cd ..
rm -r ${cpmltmpdir}
echo "Couldn't extract the rpm, aborting"
echo "You can set \$TMPDIR if /tmp is not an option"
exit 1
}
cpmltmpdir="${TMPDIR:-/tmp}/cpml-ev6-unpacked.$$"
# Check if external files are already installed.
if [ "$1" = "configure" -a \( ! -e "/usr/lib/compaq/cpml-ev6-version" -o \
"`cat /usr/lib/compaq/cpml-ev6-version 2>/dev/null`" != "$version" \) ]; then
# Check for valid CPU type
cputype=`/usr/sbin/implver`
if [[ "$cputype" < "21264 (EV6)" ]]
then
db_get cpml-ev6/wrongcpu
if [ "$RET" != "true" ]
then
# Wrong CPU, not overridden, so exit
exit 1
fi
fi
# Check and make sure that we're supposed to be doing anything
db_get cpml-ev6/intro
if [ "$RET" != "true" ]
then
# We haven't been configured so exit
exit 0
fi
# The config script should have handled prompting for a file
# and ensuring it exists and can be extracted with cpio.
db_get cpml-ev6/download_dir
DIR="$RET"
mkdir $cpmltmpdir
cd $cpmltmpdir
rpm2cpio $DIR/$archive | cpio --extract --make-directories >/dev/null 2>&1 || abort
# Fix the empty .so file according to Thomas Weyergraf's instructions
cd usr/lib/compaq/cpml-5.1.0
rm -f libcpml_ev6.so
ld -shared -o libcpml_ev6.so -soname libcpml.so.0 -whole-archive libcpml_ev6.a -no-whole-archive
strip libcpml_ev6.so
# Actually install the files, but first, fix permissions.
cd $cpmltmpdir
chown -R root.root *
chmod -R go=rX *
chmod 644 usr/lib/compaq/cpml-5.1.0/*
chmod -R u+rw *
rm -rf /usr/lib/compaq/cpml-* /usr/share/doc/cpml-ev5/R*
install -d /usr/lib/compaq
cp -a usr/lib/compaq/cpml-5.1.0 /usr/lib/compaq/
cp -a usr/doc/cpml-5.1.0/* /usr/share/doc/cpml-ev6/
echo "$version" > /usr/lib/compaq/cpml-ev6-version
cd /
rm -r $cpmltmpdir
db_get cpml-ev6/deletefile
if [ "$RET" = true ]; then
rm -f $DIR/$archive
fi
fi
# Run ldconfig for shared libs
if [ "$1" = "configure" ]; then
ldconfig
fi
#DEBHELPER#
|