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 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
|
#! /usr/bin/perl
# -*- Mode: Perl -*-
# debian.postinst ---
# Author : Manoj Srivastava ( srivasta@pilgrim.umass.edu )
# Created On : Sat Apr 27 05:42:43 1996
# Created On Node : melkor.pilgrim.umass.edu
# Last Modified By : Manoj Srivastava
# Last Modified On : Tue Feb 29 00:12:01 2000
# Last Machine Used: glaurung.green-gryphon.com
# Update Count : 33
# Status : Unknown, Use with caution!
# HISTORY :
# Description :
#
#
#
# $Id: include.postinst,v 1.18 2000/03/15 07:14:53 srivasta Exp $
#
$|=1;
# Predefined values:
my $package="=P";
my $version="=V";
# Ignore all invocations uxcept when called on to configure.
exit 0 unless ($ARGV[0] && $ARGV[0] =~ /configure/);
my $architecture;
chomp($architecture = `dpkg --print-installation-architecture`);
$architecture = "ppc" if $architecture eq "powerpc";
my $stop_and_read = 0;
# most of our work is done in /usr/src.
chdir '/usr/src' or die "Could not chdir to /usr/src:$!";
if (-d "$package") {
chdir "/usr/src/$package/include" ||
die "Could not chdir to /usr/src/$package/include:$!";
if (! -d "asm-$architecture") {
warn "/usr/src/$package/include/asm-$architecture does not exist.\n";
}
elsif (-e 'asm') {
if (! -l 'asm') {
warn "/usr/src/$package/include/asm is not a symlink.\n";
$stop_and_read++;
}
else {
my $target=readlink 'asm';
if ("$target" ne "asm-$architecture") {
if (! unlink 'asm') {
warn "could not unlink /usr/src/$package/include/asm: $!\n";
warn "It points to /usr/src/$package/include/$target\n";
warn "rather than at /usr/src/$package/include/asm-$architecture\n";
$stop_and_read++;
}
else {
if (! symlink "asm-$architecture", 'asm') {
warn "Could not link /usr/src/$package/include/asm:$!\n";
warn "to /usr/src/$package/include/asm-$architecture\n";
$stop_and_read++;
}
}
}
}
}
}
chdir '/usr/src' or die "Could not chdir to /usr/src:$!";
if ($stop_and_read) {
my $answer;
print STDERR " Please Hit return to continue.";
$answer = <STDIN>;
}
my $linktarget;
$linktarget = "../share/doc/$package";
if (-d "/usr/doc") {
# Well, we still need to handle this, at least for the time being
if (-d "/usr/share/doc/$package") {
# So the new doc dir exists, goody
# handle faliure to remove symlinks
if (-l "/usr/doc/$package") {
unlink "/usr/doc/$package";
}
my $targetdir;
my $stargetdir;
if (-x '/bin/pwd') {
chdir('/usr/doc/');
$targetdir=`/bin/pwd`;
chdir('/usr/share/doc/');
$stargetdir=`/bin/pwd`;
chdir('/');
chdir('/usr/doc');
if (-f '../share/doc/') {
chdir('../share/doc/');
my $ltarget=`/bin/pwd`;
if ($ltarget ne $stargetdir) {
$linktarget = "/usr/share/doc/$package";
}
}
else {
$linktarget = "/usr/share/doc/$package";
}
}
if ($targetdir ne $stargetdir) {
if (-d "/usr/doc/$package") {
print STDERR "Yikes! The old directory, /usr/doc/$package\n";
print STDERR "has not ben removed! This is an error; attempting\n";
print STDERR "repairs";
if (-f "/usr/doc/$package/.dhelp") {
unlink "/usr/doc/$package/.dhelp";
rmdir "/usr/doc/$package";
}
if (-d "/usr/doc/$package") {
print STDERR <<"EOFERRONE";
Failed repairs. There are old files in /usr/doc/$package_name/ created
by you or another script. I can copy them over to the new location
/usr/share/doc/$package_name, if you wish, preserving your versions of
the files. No files shall be over written, instead, backup versions
shall be created in /usr/share/doc/$package_name as needed.
EOFERRONE
;
my $answer='';
print "Shall I copy the files over [Yn]?";
$answer=<STDIN>;
if ($answer =~ /^n/i) {
print "Not copying over, aborting\n";
exit 1;
}
else {
system "cp", "-a", "--backup=t",
"/usr/doc/$package",
"/usr/share/doc/$package/.." ||
die "Error copying files over: $?";
system "rm", "-rf", "/usr/doc/$package" ||
die "Error removing old directory:$?";
}
}
}
if (-e "/usr/doc/$package") {
print STDERR "/usr/doc/$package exists, but is not a directory\n";
if (-l "/usr/doc/$package") {
print STDERR "It is a symbolic link. Overwriting\n";
unlink "/usr/doc/$package";
symlink "../share/doc/$package",
"/usr/doc/$package";
}
else {
print STDERR "This is an error. Aborting\n";
exit 1;
}
}
# File unexists. Free to go ahead and create link
symlink "../share/doc/$package",
"/usr/doc/$package";
}
}
}
if (-l 'linux') {
if (-e "linux-$version" ){
if (! unlink "linux-$version") {
exit 0;
}
}
}
exit 0;
__END__
|