postinst 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. #!/bin/sh -
  2. set -e
  3. dupdaemonhelp () {
  4. cat <<'END'
  5. Some daemons and similar services whose scripts have links in the
  6. /etc/rcN.d directories have both start (S) and stop (K) links in
  7. some runlevels. Thus these services get stopped and immediately
  8. restarted at some runlevel changes, which is probably not what
  9. you want. I can remove the probably-spurious K links if you like.
  10. Type Y to remove then, N to leave them, or L to list them.
  11. If you don't know what to do you can say N now and then delete
  12. them by hand later.
  13. END
  14. }
  15. if [ "x$1" = xconfigure ]; then
  16. case "$2" in
  17. 0.* | 1.0.* | 1.1.0 | 1.1.0[^0-9]* | '' )
  18. for f in 0 1 2 3 4 5 6
  19. do
  20. cd /etc/rc$f.d
  21. for g in K[0-9][0-9]*
  22. do
  23. if [ -n "`echo \"x$g\" | tr -d 0-9A-Za-z_-`" ]
  24. then
  25. continue
  26. fi
  27. h="`echo $g | sed -e 's/^K/S/'`"
  28. if ! [ -L $h -a -L $g ] \
  29. || [ "`ls -Li $g 2>/dev/null | awk '{print $1}'`" != \
  30. "`ls -Li $h 2>/dev/null | awk '{print $1}'`" ]
  31. then
  32. continue
  33. fi
  34. removes="$removes rc$f.d/$g"
  35. done
  36. done
  37. if [ -n "$removes" ]
  38. then
  39. cd /etc
  40. dupdaemonhelp
  41. while [ -n "$removes" ]
  42. do
  43. echo -n 'y=remove, n=leave, l=list, h=help ? '
  44. read response
  45. case "$response" in
  46. [Yy]*)
  47. echo "Removing duplicate K links ..."
  48. rm -v $removes
  49. removes=""
  50. ;;
  51. [Nn]*)
  52. echo -e "OK, leaving them.\n"
  53. removes=""
  54. ;;
  55. [Ll]*)
  56. echo
  57. echo $removes
  58. echo
  59. ;;
  60. [Hh]*)
  61. dupdaemonhelp
  62. ;;
  63. esac
  64. done
  65. fi
  66. ;;
  67. 1.1.6 | 1.1.6elf | 1.2.[0123] | 1.2.[0123]elf )
  68. response=''
  69. while [ -z "$response" ]; do
  70. echo -n '
  71. The version of dpkg you'\''re upgrading from had a problem with the
  72. install-info program used to maintain the /usr/info/dir file. It may
  73. have corrupted the file, for example by placing new entries for the
  74. menu in it before the `* Menu'\'' line (thus making them ineffective) or
  75. by creating several identical sections.
  76. I can try to sort these problems out, but beware that this process is
  77. not guaranteed not to mess up a dir file which has things that look
  78. like menu entries in the introductory paragraphs. The distributed dir
  79. files do not do this, so if you haven'\''t edited /usr/info/dir it'\''s
  80. almost certainly safe to say `yes'\'' to the next question.
  81. If you say `no'\'' you may wish to check and/or edit /usr/info/dir yourself.
  82. Try to check/repair /usr/info/dir automatically ? [y/n] '
  83. read response
  84. case "$response" in
  85. [Yy]* | '') response=yes ;;
  86. [Nn]*) response=no ;;
  87. *) response='' ;;
  88. esac
  89. done
  90. if [ "$response" = yes ]; then
  91. echo "
  92. Checking/repairing /usr/info/dir ..."
  93. cleanup-info --unsafe
  94. echo
  95. else
  96. echo "
  97. OK.
  98. "
  99. fi
  100. ;;
  101. esac
  102. fi
  103. cd /var/lib/dpkg
  104. if ! test -f diversions
  105. then
  106. touch diversions
  107. fi
  108. cd /usr/bin
  109. if test dpkg-deb.dist -ef dpkg-deb; then rm dpkg-deb.dist; fi
  110. if test -f dpkg-deb.dist; then mv dpkg-deb.dist dpkg-deb; fi
  111. if test -d /DEBIAN
  112. then
  113. echo 'Removing /DEBIAN directory which was created by a dpkg bug ...'
  114. rm -r /DEBIAN
  115. fi
  116. if test -d /usr/lib/dpkg/methods/hd -a ! -x /usr/lib/dpkg/methods/hd/install
  117. then
  118. echo \
  119. 'Warning - /usr/lib/dpkg/methods/hd/ exists, but .../hd/install does not.
  120. This is probably left over from some previous manual installation of
  121. now-obsolete dselect-related software. I suggest you remove the whole
  122. /usr/lib/dpkg/methods/hd directory and all its contents; otherwise dselect
  123. is unlikely to function correctly.'
  124. fi
  125. if test -f /var/lib/dpkg/status; then exit 0; fi
  126. cd /var/adm/dpkg
  127. if [ ! -f status ]
  128. then
  129. echo 'Adding "status" file to dpkg system database ...'
  130. rm -f /tmp/dpp.$$ || true
  131. ls -1 deb/*.control >/tmp/dpp.$$
  132. sed -e 's:^deb/::; s:\.control$: Install OK Installed:;' \
  133. </tmp/dpp.$$ >status.new
  134. rm /tmp/dpp.$$
  135. mv status.new status
  136. fi
  137. if grep '{' deb/*.control >/dev/null
  138. then
  139. echo 'Fixing up curly brackets in control files ...'
  140. perl -i~ -pe \
  141. 'y/{}//d if m/^(depends|recommended|optional|conflicts):/i' \
  142. deb/*.control
  143. rm deb/*.control~
  144. fi
  145. if grep 'Optional: idanish ifrench' deb/ispell.control >/dev/null 2>&1
  146. then
  147. echo 'Fixing up broken ispell.control file ...'
  148. perl -i~ -pe 's/ /, /g, s/,// if m/^Optional:/' deb/ispell.control
  149. fi
  150. newdb=/var/lib/dpkg
  151. echo "Moving datatabase /var/adm/dpkg to $newdb and changing format ..."
  152. exec 4>$newdb/status.new
  153. exec 5<status
  154. while read <&5 package status
  155. do
  156. echo " processing $package ..."
  157. if test -f deb/$package.control
  158. then
  159. egrep . deb/$package.control >&4
  160. else
  161. echo >&4 "Package: $package"
  162. fi
  163. echo >&4 "Status: $status"
  164. if test -f deb/$package.conffiles -a -s deb/$package.conffiles
  165. then
  166. echo >&4 "Conffiles:"
  167. exec 6<deb/$package.conffiles
  168. while read <&6 cfile
  169. do
  170. expr match "$cfile" "[^ ]" >/dev/null || continue
  171. if test -f deb/$package.hash
  172. then
  173. hash="`grep \"^$cfile \" <deb/$package.hash || \
  174. test $? = 1`"
  175. else
  176. hash=''
  177. fi
  178. test -n "$hash" || hash="$cfile -"
  179. expr match "$hash" / >/dev/null || hash="/$hash"
  180. echo >&4 " $hash"
  181. done
  182. elif test -f deb/$package.hash -a -s deb/$package.conffiles
  183. then
  184. echo >&4 "Conffiles:"
  185. sed -ne '/^[^\/]/ s:^:/:; s/^/ /; / ./p' >&4 deb/$package.hash
  186. fi
  187. echo >&4
  188. for s in {pre,post}{rm,inst} list
  189. do
  190. if test -f deb/$package.$s
  191. then
  192. mv deb/$package.$s $newdb/info/$package.$s
  193. fi
  194. done
  195. done
  196. if ! test -f $newdb/available
  197. then
  198. if test -f database
  199. then
  200. cp database $newdb/available
  201. else
  202. touch $newdb/available
  203. fi
  204. fi
  205. mv $newdb/status.new $newdb/status