]> git.donarmstrong.com Git - debian/debian-policy.git/blob - debian/postinst.in
* Added doc-base support for all of the HTML docs in the package
[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/debian-policy
132         /usr/sbin/install-docs -i /usr/share/doc-base/debian-menu-policy
133         /usr/sbin/install-docs -i /usr/share/doc-base/debian-mime-policy
134         /usr/sbin/install-docs -i /usr/share/doc-base/debian-perl-policy
135         /usr/sbin/install-docs -i /usr/share/doc-base/debian-policy-process
136         /usr/sbin/install-docs -i /usr/share/doc-base/debconf-spec
137     fi
138
139     # There are three sub-cases:
140     if test "${2+set}" != set; then
141       # We're being installed by an ancient dpkg which doesn't remember
142       # which version was most recently configured, or even whether
143       # there is a most recently configured version.
144       :
145
146     elif test -z "$2" -o "$2" = "<unknown>"; then
147       # The package has not ever been configured on this system, or was
148       # purged since it was last configured.
149       :
150
151     else
152       # Version $2 is the most recently configured version of this
153       # package.
154       :
155
156     fi
157
158     # FSSTND compatible symlinks
159     if [ -d /usr/doc -a ! -e /usr/doc/$PACKAGE \
160         -a -d /usr/share/doc/$PACKAGE ]; then
161             ln -sf ../share/doc/$PACKAGE /usr/doc/$PACKAGE
162     fi
163     ;;
164   abort-upgrade)
165     # Back out of an attempt to upgrade this package FROM THIS VERSION
166     # to version $2.  Undo the effects of "prerm upgrade $2".
167     :
168
169     ;;
170   abort-remove)
171     if test "$2" != in-favour; then
172       echo "$0: undocumented call to \`postinst $*'" 1>&2
173       exit 0
174     fi
175     # Back out of an attempt to remove this package, which was due to
176     # a conflict with package $3 (version $4).  Undo the effects of
177     # "prerm remove in-favour $3 $4".
178     :
179
180     ;;
181   abort-deconfigure)
182     if test "$2" != in-favour -o "$5" != removing; then
183       echo "$0: undocumented call to \`postinst $*'" 1>&2
184       exit 0
185     fi
186     # Back out of an attempt to deconfigure this package, which was
187     # due to package $6 (version $7) which we depend on being removed
188     # to make way for package $3 (version $4).  Undo the effects of
189     # "prerm deconfigure in-favour $3 $4 removing $6 $7".
190     :
191
192     ;;
193   *) echo "$0: didn't understand being called with \`$1'" 1>&2
194      exit 0;;
195 esac
196
197 exit 0