debian.postinst 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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 case "$2" in 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. ;; esac ; fi
  67. cd /var/lib/dpkg
  68. if ! test -f diversions
  69. then
  70. touch diversions
  71. fi
  72. cd /usr/bin
  73. if test dpkg-deb.dist -ef dpkg-deb; then rm dpkg-deb.dist; fi
  74. if test -f dpkg-deb.dist; then mv dpkg-deb.dist dpkg-deb; fi
  75. if test -d /DEBIAN
  76. then
  77. echo 'Removing /DEBIAN directory which was created by a dpkg bug ...'
  78. rm -r /DEBIAN
  79. fi
  80. if test -d /usr/lib/dpkg/methods/hd -a ! -x /usr/lib/dpkg/methods/hd/install
  81. then
  82. echo \
  83. 'Warning - /usr/lib/dpkg/methods/hd/ exists, but .../hd/install does not.
  84. This is probably left over from some previous manual installation of
  85. now-obsolete dselect-related software. I suggest you remove the whole
  86. /usr/lib/dpkg/methods/hd directory and all its contents; otherwise dselect
  87. is unlikely to function correctly.'
  88. fi
  89. if test -f /var/lib/dpkg/status; then exit 0; fi
  90. cd /var/adm/dpkg
  91. if [ ! -f status ]
  92. then
  93. echo 'Adding "status" file to dpkg system database ...'
  94. rm -f /tmp/dpp.$$ || true
  95. ls -1 deb/*.control >/tmp/dpp.$$
  96. sed -e 's:^deb/::; s:\.control$: Install OK Installed:;' \
  97. </tmp/dpp.$$ >status.new
  98. rm /tmp/dpp.$$
  99. mv status.new status
  100. fi
  101. if grep '{' deb/*.control >/dev/null
  102. then
  103. echo 'Fixing up curly brackets in control files ...'
  104. perl -i~ -pe \
  105. 'y/{}//d if m/^(depends|recommended|optional|conflicts):/i' \
  106. deb/*.control
  107. rm deb/*.control~
  108. fi
  109. if grep 'Optional: idanish ifrench' deb/ispell.control >/dev/null 2>&1
  110. then
  111. echo 'Fixing up broken ispell.control file ...'
  112. perl -i~ -pe 's/ /, /g, s/,// if m/^Optional:/' deb/ispell.control
  113. fi
  114. newdb=/var/lib/dpkg
  115. echo "Moving datatabase /var/adm/dpkg to $newdb and changing format ..."
  116. exec 4>$newdb/status.new
  117. exec 5<status
  118. while read <&5 package status
  119. do
  120. echo " processing $package ..."
  121. if test -f deb/$package.control
  122. then
  123. egrep . deb/$package.control >&4
  124. else
  125. echo >&4 "Package: $package"
  126. fi
  127. echo >&4 "Status: $status"
  128. if test -f deb/$package.conffiles -a -s deb/$package.conffiles
  129. then
  130. echo >&4 "Conffiles:"
  131. exec 6<deb/$package.conffiles
  132. while read <&6 cfile
  133. do
  134. expr match "$cfile" "[^ ]" >/dev/null || continue
  135. if test -f deb/$package.hash
  136. then
  137. hash="`grep \"^$cfile \" <deb/$package.hash || \
  138. test $? = 1`"
  139. else
  140. hash=''
  141. fi
  142. test -n "$hash" || hash="$cfile -"
  143. expr match "$hash" / >/dev/null || hash="/$hash"
  144. echo >&4 " $hash"
  145. done
  146. elif test -f deb/$package.hash -a -s deb/$package.conffiles
  147. then
  148. echo >&4 "Conffiles:"
  149. sed -ne '/^[^\/]/ s:^:/:; s/^/ /; / ./p' >&4 deb/$package.hash
  150. fi
  151. echo >&4
  152. for s in {pre,post}{rm,inst} list
  153. do
  154. if test -f deb/$package.$s
  155. then
  156. mv deb/$package.$s $newdb/info/$package.$s
  157. fi
  158. done
  159. done
  160. if ! test -f $newdb/available
  161. then
  162. if test -f database
  163. then
  164. cp database $newdb/available
  165. else
  166. touch $newdb/available
  167. fi
  168. fi
  169. mv $newdb/status.new $newdb/status