debian.postinst 5.5 KB

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