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 126 127 128 129 130
|
#!/bin/sh -e
# A string that denotes the current version of the library:
version=1.2.0-4
# The name of the file that comes from Compaq's web site:
archive=cfal-1.2.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 ${cfaltmpdir}
echo "Couldn't extract the rpm, aborting"
echo "You can set \$TMPDIR if /tmp is not an option"
exit 1
}
cfaltmpdir="${TMPDIR:-/tmp}/cfal-unpacked.$$"
# Check if external files are already installed.
if [ "$1" = "configure" -a \( ! -e "/usr/lib/compaq/cfal-version" -o \
"`cat /usr/lib/compaq/cfal-version 2>/dev/null`" != "$version" \) ]; then
# Check and make sure that we're supposed to be doing anything
db_get cfal/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 cfal/download_dir
DIR="$RET"
mkdir $cfaltmpdir
cd $cfaltmpdir
rpm2cpio $DIR/$archive | cpio --extract --make-directories >/dev/null 2>&1 || abort
# Note this only allows one version of cfal to be installed. A future
# installer package might not have this limitation.
# Remove all of the old files (should be the same as in prerm)
rm -rf /usr/lib/compaq/cfal-* /usr/share/doc/cfal/README.gz \
/usr/share/doc/cfal/decfortran90.hlp.gz
# Fix permissions.
cd $cfaltmpdir
chown -R root.root *
chmod -R go=rX *
chmod -R u+rw *
# Install the docs
cd usr/doc/cfal-1.2.0
rm fort.man
gzip --best README decfortran90.hlp
cp -p README.gz decfortran90.hlp.gz /usr/share/doc/cfal
cd $cfaltmpdir
# Install the meat of the package, stripping binaries
# (just to make sure).
install -d /usr/lib/compaq/cfal-1.2.0
cd usr/lib/compaq/cfal-1.2.0
strip decfort90
strip f90_split
strip fort
strip fpp
strip fpr
strip fsplit
strip what
gzip --best man/*/*
cp -a * /usr/lib/compaq/cfal-1.2.0
# Finally, create the -version file for comparison in future upgrades.
echo "$version" > /usr/lib/compaq/cfal-version
cd /
rm -r $cfaltmpdir
db_get cfal/deletefile
if [ "$RET" = true ]; then
rm -f $DIR/$archive
fi
fi
# Install f77 alternatives symlink, since we provide fortran-compiler
if [ "$1" = "configure" ]; then
update-alternatives --install /usr/bin/f77 f77 /usr/bin/fort 10 \
--slave /usr/share/man/man1/f77.1.gz f77.1.gz /usr/share/man/man1/fort.1.gz
fi
#DEBHELPER#
|