dpkg.postinst 5.4 KB

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