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
|
#! /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: doc.postinst,v 1.1.2.1 2000/04/30 21:38: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 $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";
}
}
}
exit 0;
__END__
|