]> git.donarmstrong.com Git - debian/debian-policy.git/blob - debian/postinst.in
d2c6f6f82fdde42f6c130ea0fe897b2166839ac1
[debian/debian-policy.git] / debian / postinst.in
1 #!/bin/sh
2 #                               -*- Mode: Sh -*- 
3 # postinst --- 
4 # Author           : Manoj Srivastava ( srivasta@tiamat.datasync.com ) 
5 # Created On       : Thu Oct 29 15:23:36 1998
6 # Created On Node  : tiamat.datasync.com
7 # Last Modified By : Manoj Srivastava
8 # Last Modified On : Fri Mar 17 17:00:35 2000
9 # Last Machine Used: glaurung.green-gryphon.com
10 # Update Count     : 8
11 # Status           : Unknown, Use with caution!
12 # HISTORY          : 
13 # Description      : 
14
15
16
17
18 # Abort if any command returns an error value
19 set -e
20
21 # This is filled in by debian/rules
22 PACKAGE=#PACKAGE#
23
24 # This script is called as the last step of the installation of the
25 # package.  All the package's files are in place, dpkg has already done
26 # its automatic conffile handling, and all the packages we depend of
27 # are already fully installed and configured.
28
29 package_name=#PACKAGE#
30
31 if [ -z "package_name" ]; then
32     print >&2 "Internal Error. Please report a bug."
33     exit 1;
34 fi
35
36 #perl -e 'print readlink("/usr/doc/'$package_name'"), "\n"; '
37 case "$1" in
38   configure)
39     # Configure this package.  If the package must prompt the user for
40     # information, do it here.
41
42     if [ -d /usr/doc ]; then
43         # Well, we still need to handle this. At this point, /usr/doc
44         # can be a symlink
45         
46         if [  -d /usr/share/doc/$package_name ]; then
47             # So the new doc dir exists, goody
48             
49             # well, either one of these is a symlink, they can be
50             # pointing off _anywhere_
51             cd /usr/doc/;
52             target_dir=$(/bin/pwd);
53             cd /usr/share/doc 
54             starget_dir=$(/bin/pwd);
55             cd /
56
57             link_target="../share/doc/$package_name";
58             cd /usr/doc/;
59             if [ -d ../share/doc/ ]; then
60                 cd ../share/doc/
61                 ltarget=$(/bin/pwd);
62                 if [ "$starget_dir" = "$ltarget" ]; then
63                     link_target="../share/doc/$package_name";
64                 else
65                     link_target="/usr/share/doc/$package_name";
66                 fi
67             else
68                 link_target="/usr/share/doc/$package_name"
69             fi
70
71
72             # Well, make sure that we do not get tripped up by the symlink
73             if [ -L /usr/doc/$package_name ]; then
74                 rm -f /usr/doc/$package_name
75             fi
76
77             if [ "$target_dir" != "$starget_dir" ]; then
78                 # Ok. The directories are in different locations
79                 if [ -d /usr/doc/$package_name ]; then
80                     echo "Yikes! The old directory, /usr/doc/$package_name,"
81                     echo "has not ben removed! This is an error; attempting"
82                     echo "repairs."
83                     find /usr/doc/$package_name/ -type f -name .dhelp \
84                         -exec rm {} \;
85                     find /usr/doc/$package_name/ -type d -depth \
86                          -exec rmdir --ignore-fail-on-non-empty {} \;
87
88                     if [ -d /usr/doc/$package_name ]; then
89                         cat <<EOF 
90 Failed repairs. There are old files in /usr/doc/$package_name/ created
91 by you or another script. I can copy them over to the new location
92 /usr/share/doc/$package_name, if you wish, preserving your versions of
93 the files.  No files shall be over written, instead, backup versions
94 shall be created in /usr/share/doc/$package_name as needed.
95
96 Shall I copy the files over [Yn]?
97 EOF
98                         read answer;
99                         case "$answer" in
100                             [Nn]*)
101                                 echo "Not copying over, aborting";
102                                 exit 1;
103                                 ;;      
104                             *)
105                                 cp -a --backup=t /usr/doc/$package_name  \
106                                     /usr/share/doc/$package_name/.. ;
107                                 rm -rf /usr/doc/$package_name;
108                         esac
109                     fi
110                 fi
111
112                 if [ -e /usr/doc/$package_name ]; then
113                     echo "/usr/doc/$package_name still exists"
114                     if [ -L /usr/doc/$package_name ]; then
115                         echo "it is a symbolic link, overwriting"
116                         ln -sf $link_target /usr/doc/$package_name
117                     else
118                         echo "This is an error. Aborting"
119                         exit 1
120                     fi
121                 fi
122                 # File unexists. Free to go ahead and create link
123                 ln -sf $link_target /usr/doc/$package_name
124
125             fi
126         fi
127     fi
128
129
130     if [ -x /usr/sbin/install-docs ]; then
131         /usr/sbin/install-docs -i /usr/share/doc-base/$PACKAGE
132     fi
133
134     # There are three sub-cases:
135     if test "${2+set}" != set; then
136       # We're being installed by an ancient dpkg which doesn't remember
137       # which version was most recently configured, or even whether
138       # there is a most recently configured version.
139       :
140
141     elif test -z "$2" -o "$2" = "<unknown>"; then
142       # The package has not ever been configured on this system, or was
143       # purged since it was last configured.
144       :
145
146     else
147       # Version $2 is the most recently configured version of this
148       # package.
149       :
150
151     fi
152
153     # FSSTND compatible symlinks
154     if [ -d /usr/doc -a ! -e /usr/doc/$PACKAGE \
155         -a -d /usr/share/doc/$PACKAGE ]; then
156             ln -sf ../share/doc/$PACKAGE /usr/doc/$PACKAGE
157     fi
158     ;;
159   abort-upgrade)
160     # Back out of an attempt to upgrade this package FROM THIS VERSION
161     # to version $2.  Undo the effects of "prerm upgrade $2".
162     :
163
164     ;;
165   abort-remove)
166     if test "$2" != in-favour; then
167       echo "$0: undocumented call to \`postinst $*'" 1>&2
168       exit 0
169     fi
170     # Back out of an attempt to remove this package, which was due to
171     # a conflict with package $3 (version $4).  Undo the effects of
172     # "prerm remove in-favour $3 $4".
173     :
174
175     ;;
176   abort-deconfigure)
177     if test "$2" != in-favour -o "$5" != removing; then
178       echo "$0: undocumented call to \`postinst $*'" 1>&2
179       exit 0
180     fi
181     # Back out of an attempt to deconfigure this package, which was
182     # due to package $6 (version $7) which we depend on being removed
183     # to make way for package $3 (version $4).  Undo the effects of
184     # "prerm deconfigure in-favour $3 $4 removing $6 $7".
185     :
186
187     ;;
188   *) echo "$0: didn't understand being called with \`$1'" 1>&2
189      exit 0;;
190 esac
191
192 exit 0