Debian Codegraph @

debian/dist.postinst

raw
1 #! /bin/sh
2 # -*- Mode: Sh -*-
3 # postinst ---
4 # Author : Manoj Srivastava ( [email protected] )
5 # Created On : Fri Nov 14 11:25:07 2003
6 # Created On Node : glaurung.green-gryphon.com
7 # Last Modified By : Manoj Srivastava
8 # Last Modified On : Mon Dec 1 21:50:09 2003
9 # Last Machine Used: glaurung.green-gryphon.com
10 # Update Count : 27
11 # Status : Unknown, Use with caution!
12 # HISTORY :
13 # Description :
14 #
15 # arch-tag: 5401e9ef-39cc-4aee-96a4-61dfb8f32cf7
16 #
17 # This program is free software; you can redistribute it and/or modify
18 # it under the terms of the GNU General Public License as published by
19 # the Free Software Foundation; either version 2 of the License, or
20 # (at your option) any later version.
21 #
22 # This program is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 # GNU General Public License for more details.
26 #
27 # You should have received a copy of the GNU General Public License
28 # along with this program; if not, write to the Free Software
29 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 #
31 #
32
33 # Abort if any command returns an error value
34 set -e
35
36 package_name=dist;
37
38 if [ -z "$package_name" ]; then
39 print >&2 "Internal Error. Please report a bug."
40 exit 1;
41 fi
42
43 # This script is called as the last step of the installation of the
44 # package. All the package's files are in place, dpkg has already done
45 # its automatic conffile handling, and all the packages we depend of
46 # are already fully installed and configured.
47 # summary of how this script can be called:
48 # * <postinst> `configure' <most-recently-configured-version>
49 # * <old-postinst> `abort-upgrade' <new version>
50 # * <conflictor's-postinst> `abort-remove' `in-favour' <package>
51 # <new-version>
52 # * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
53 # <failed-install-package> <version> `removing'
54 # <conflicting-package> <version>
55 # for details, see http://www.debian.org/doc/debian-policy/ or
56 # the debian-policy package
57 #
58 # quoting from the policy:
59 # Any necessary prompting should almost always be confined to the
60 # post-installation script, and should be protected with a conditional
61 # so that unnecessary prompting doesn't happen if a package's
62 # installation fails and the `postinst' is called with `abort-upgrade',
63 # `abort-remove' or `abort-deconfigure'.
64
65 # The following idempotent stuff doesn't generally need protecting
66 # against being run in the abort-* cases.
67
68 # Install info files into the dir file
69 ##: install-info --quiet --section "section pattern" "Section Title" \
70 ##: --description="Name of the document" /usr/info/${package_name}.info
71
72 # Create stub directories under /usr/local
73 ##: if test ! -d /usr/local/lib/${package_name}; then
74 ##: if test ! -d /usr/local/lib; then
75 ##: if mkdir /usr/local/lib; then
76 ##: chown root.staff /usr/local/lib || true
77 ##: chmod 2775 /usr/local/lib || true
78 ##: fi
79 ##: fi
80 ##: if mkdir /usr/local/lib/${package_name}; then
81 ##: chown root.staff /usr/local/lib/${package_name} || true
82 ##: chmod 2775 /usr/local/lib/${package_name} || true
83 ##: fi
84 ##: fi
85
86 # Ensure the menu system is updated
87 ##: [ ! -x /usr/bin/update-menus ] || /usr/bin/update-menus
88
89 # Arrange for a daemon to be started at system boot time
90 ##: update-rc.d ${package_name} default >/dev/null
91
92 ask_organization () {
93 if [ -e /usr/share/debconf/confmodule ]; then
94 . /usr/share/debconf/confmodule
95 db_capb
96 ok=''
97 # See if the old shared question still exists.
98 if db_get share/news/organization; then
99 if [ "X$RET" != "X" ]; then
100 orgname="$RET"
101 db_fget share/news/organization seen
102 if [ "$RET" = true ]; then
103 if [ "$orgname" = "--none--" ]; then
104 orgname=""
105 fi
106 else
107 orgname=""
108 fi
109 # I no longer claim this question.
110 db_unregister share/news/organization
111 fi
112 else
113 # Good. The old question is gone.
114 if ! db_get shared/news/organization; then
115 while [ ! "$ok" ]; do
116 retval=$(db_input low shared/news/organization) || true
117 if [ "$retval" = "30 question skipped" ]; then
118 ok=1
119 fi
120 db_go || true
121 db_get shared/news/organization
122 if [ "X$RET" != "X" ]; then
123 ok=1
124 break
125 fi
126 done
127 fi
128 db_fget shared/news/organization seen
129 if [ "$RET" = true ]; then
130 # The user saw and answered the question using debconf.
131 db_get shared/news/organization
132 if [ "$RET" = "--none--" ]; then
133 orgname=""
134 else
135 orgname="$RET"
136 fi
137 else
138 # Debconf did not display the question to the user.
139 orgname=""
140 fi
141 fi
142 else
143 # Debconf is not available so ask the question by hand.
144 echo ""
145 /bin/cat << 'EOH'
146
147 Please type the name of your organization as you want it to
148 appear on the Organization line of outgoing articles/patches.
149 This information is stored in the configuration file
150 /etc/news/organization. (It is nice if this also specifies
151 your location. Your city name is probably sufficient if well
152 known.) For example:
153
154 University of Southern North Dakota, Hoople
155 type in "--none--" if you do not want to specify one.
156 However, you shall be asked again on the next upgrade if
157 /etc/news/organization does not exist.
158
159 EOH
160
161 orgname=""
162 while test "X$orgname" = "X"; do
163 rp='Organization:'
164 xxxm=$dflt
165 case "$xxxm" in
166 '') echo -n "$rp " ;;
167 *) case "$rp" in
168 '') echo -n "[$xxxm] ";;
169 *)
170 if test `echo "$rp [$xxxm] " | wc -c` -ge 80; then
171 echo "$rp"
172 echo -n "[$xxxm] "
173 else
174 echo -n "$rp [$xxxm] "
175 fi
176 ;;
177 esac;;
178 esac
179 ans='!'
180 while expr "X$ans" : "X!" >/dev/null; do
181 read answ
182 set x $xxxm
183 shift
184 aok=''; eval "ans=\"$answ\"" && aok=y
185 case "$answ" in
186 "$ans")
187 case "$ans" in
188 "!")
189 sh
190 echo " "
191 case "$xxxm" in
192 '') echo -n "$rp " ;;
193 *) case "$rp" in
194 '') echo -n "[$xxxm] ";;
195 *)
196 if test `echo "$rp [$xxxm] " | wc -c` -ge 80; then
197 echo "$rp"
198 echo -n "[$xxxm] "
199 else
200 echo -n "$rp [$xxxm] "
201 fi
202 ;;
203 esac;;
204 esac
205 ;;
206 !*)
207 set x `expr "X$ans" : "X!\(.*\)$"`
208 shift
209 sh -c "$*"
210 echo " "
211 case "$xxxm" in
212 '') echo -n "$rp ";;
213 *) case "$rp" in
214 '') echo -n "[$xxxm] ";;
215 *)
216 if test `echo "$rp [$xxxm] " | wc -c` -ge 80; then
217 echo "$rp"
218 echo -n "[$xxxm] "
219 else
220 echo -n "$rp [$xxxm] "
221 fi
222 ;;
223 esac;;
224 esac
225 ;;
226 esac;;
227 *)
228 case "$aok" in
229 y)
230 echo "*** Substitution done -- please confirm."
231 xxxm="$ans"
232 ans=`echo -n "$ans" | tr '\012' ' '`
233 xxxm="$ans"
234 ans=!
235 ;;
236 *)
237 echo "*** Error -- try again."
238 ans=!
239 ;;
240 esac
241 case "$xxxm" in
242 '') echo -n "$rp " ;;
243 *) case "$rp" in
244 '') echo -n "[$xxxm] ";;
245 *)
246 if test `echo "$rp [$xxxm] " | wc -c` -ge 80; then
247 echo "$rp"
248 echo -n "[$xxxm] "
249 else
250 echo -n "$rp [$xxxm] "
251 fi
252 ;;
253 esac;;
254 esac
255 ;;
256 esac
257 case "$ans$xxxm$nostick" in
258 '')
259 ans=!
260 case "$xxxm" in
261 '') echo -n "$rp " ;;
262 *) case "$rp" in
263 '') echo -n "[$xxxm] ";;
264 *)
265 if test `echo "$rp [$xxxm] " | wc -c` -ge 80; then
266 echo "$rp"
267 echo -n "[$xxxm] "
268 else
269 echo -n "$rp [$xxxm] "
270 fi
271 ;;
272 esac;;
273 esac
274 ;;
275 esac
276 done
277 case "$ans" in
278 '') ans="$xxxm";;
279 esac
280 orgname="$ans"
281 done
282 if [ "$ans" = "--none--" ]; then
283 orgname=""
284 fi
285 fi
286
287 }
288
289 set_org_perms () {
290 chown root /etc/news/organization
291 if grep news /etc/group > /dev/null 2>&1 ; then
292 chgrp news /etc/news/organization
293 else
294 chgrp root /etc/news/organization
295 fi
296 chmod 0644 /etc/news/organization
297 }
298
299 case "$1" in
300 configure)
301 # Configure this package. If the package must prompt the user for
302 # information, do it here.
303 # Install emacs lisp files
304 ##:if [ -x /usr/lib/emacsen-common/emacs-package-install ]; then
305 ##: /usr/lib/emacsen-common/emacs-package-install $package_name
306 ##:fi
307
308
309 # Activate menu-methods script
310 ##: chmod a+x /etc/menu-methods/${package_name}
311
312 # Update ld.so cache
313 ##: ldconfig
314
315 # Make our version of a program available
316 ##: update-alternatives \
317 ##: --install /usr/bin/program program /usr/bin/alternative 50 \
318 ##: --slave /usr/man/man1/program.1.gz program.1.gz \
319 ##: /usr/man/man1/alternative.1.gz
320
321 # Tell ucf that the file in /usr/share/foo is the latest
322 # maintainer version, and let it handle how to manage the real
323 # confuguration file in /etc. This is how a static configuration
324 # file can be handled:
325 ##:if which ucf >/dev/null 2>&1; then
326 ##: ucf /usr/share/${package_name}/configuration /etc/${package_name}.conf
327 ##:fi
328
329 ### We could also do this on the fly. The following is from Tore
330 ### Anderson:
331
332 if [ -e /usr/share/debconf/confmodule ]; then
333 . /usr/share/debconf/confmodule
334 fi
335
336
337 ### find out what the user answered.
338 # db_get foo/run_on_boot
339 # run_on_boot=$RET
340 # db_stop
341
342 ### safely create a temporary file to generate our suggested
343 ### configuration file.
344 # tempfile=`tempfile`
345 # cat << _eof > $tempfile
346 ### Configuration file for Foo.
347
348 ### this was answered by you, the user in a debconf dialogue
349 # RUNONBOOT=$run_on_boot
350
351 ### this was not, as it has a sane default value.
352 # COLOUROFSKY=blue
353
354 #_eof
355
356 ### Note that some versions of debconf do not release stdin, so
357 ### the following invocation of ucf may not work, since the stdin
358 ### is never coneected to ucfr.
359
360 ### now, invoke ucf, which will take care of the rest, and ask
361 ### the user if he wants to update his file, if it is modified.
362 #ucf $tempfile /etc/foo.conf
363
364 ### done! now we'll just clear up our cruft.
365 #rm -f $tempfile
366
367
368
369 # There are three sub-cases:
370 if test "${2+set}" != set; then
371 # We're being installed by an ancient dpkg which doesn't remember
372 # which version was most recently configured, or even whether
373 # there is a most recently configured version.
374 :
375
376 elif test -z "$2" || test "$2" = "<unknown>"; then
377 # The package has not ever been configured on this system, or was
378 # purged since it was last configured.
379 :
380
381 else
382 # Version $2 is the most recently configured version of this
383 # package.
384 :
385
386 fi
387
388 if [ ! -f /etc/news/organization ]; then
389 echo ""
390 echo "Hmmm.. You don't seem to have an /etc/news/organization file."
391 echo "Ususally that contains the name of your organization as "
392 echo "you want it to appear on the Organization line of outgoing"
393 echo "articles/patches."
394 echo ""
395
396 : echo create directory
397 if test ! -d /etc/news ; then
398 mkdir /etc/news
399 chown root /etc/news
400 if grep news /etc/group > /dev/null 2>&1 ; then
401 chgrp news /etc/news
402 else
403 echo "darn, you do not have news in /etc/group"
404 chgrp root /etc/news
405 fi
406 chmod 2755 /etc/news
407 fi
408
409 # if the organization stuff exists, then copy that over
410 if test -f /etc/organization ; then
411 echo "But you do have /etc/organization. I'll Use that."
412 echo "If that is not right, just edit the /etc/news/organization "
413 echo "after the setup is done. (/etc/organization is deprecated. You"
414 echo "might consider removing it if nothing else uses it)."
415 echo ""
416 cp /etc/organization /etc/news/organization
417 set_org_perms
418 else
419 : echo get organization name
420 ask_organization
421 if [ "X$orgname" != "X" ]; then
422 echo "$orgname" > /etc/news/organization
423 set_org_perms
424 fi
425 fi
426 fi
427
428 ;;
429
430 abort-upgrade)
431 # Back out of an attempt to upgrade this package FROM THIS VERSION
432 # to version $2. Undo the effects of "prerm upgrade $2".
433 :
434
435 ;;
436 abort-remove)
437 if test "$2" != in-favour; then
438 echo "$0: undocumented call to \`postinst $*'" 1>&2
439 exit 0
440 fi
441 # Back out of an attempt to remove this package, which was due to
442 # a conflict with package $3 (version $4). Undo the effects of
443 # "prerm remove in-favour $3 $4".
444 :
445
446 ;;
447 abort-deconfigure)
448 if test "$2" != in-favour || test "$5" != removing; then
449 echo "$0: undocumented call to \`postinst $*'" 1>&2
450 exit 0
451 fi
452 # Back out of an attempt to deconfigure this package, which was
453 # due to package $6 (version $7) which we depend on being removed
454 # to make way for package $3 (version $4). Undo the effects of
455 # "prerm deconfigure in-favour $3 $4 removing $6 $7".
456 :
457
458 ;;
459 *) echo "$0: didn't understand being called with \`$1'" 1>&2
460 exit 0;;
461 esac
462
463 # Install doc base documentation
464 ##:if which install-docs >/dev/null 2>&1; then
465 ##: if [ -e /usr/share/doc-base/${package_name} ]; then
466 ##: install-docs -i /usr/share/doc-base/${package_name}
467 ##: fi
468 ##:fi
469
470 #DEBHELPER#
471
472 exit 0