dpkg.postinst 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. #!/bin/sh
  2. set -e
  3. dupdaemonhelp () {
  4. cat <<EOF
  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. EOF
  14. }
  15. if [ "x$1" = xconfigure ]; then
  16. if [ -z "$2" -a ! -f /etc/dpkg/dpkg.cfg ] ; then
  17. cp /usr/share/doc/dpkg/dpkg.cfg /etc/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. if [ -d /usr/info -a ! -L /usr/info -a ! -L /usr/info/dir ]; then
  107. echo Moving /usr/info/dir to /usr/share/info/dir.
  108. mv /usr/info/dir /usr/share/info/dir
  109. if [ -f /usr/info/dir.old ]; then
  110. mv /usr/info/dir.old /usr/share/info/dir.old
  111. fi
  112. if [ "`find /usr/info -empty`" = "/usr/info" ]; then
  113. echo Making /usr/info a symlink to /usr/share/info.
  114. rmdir /usr/info
  115. ln -s share/info /usr/info
  116. else
  117. echo Making /usr/info/dir a symlink to /usr/share/info/dir.
  118. ln -sf ../share/info/dir /usr/info/dir
  119. fi
  120. fi
  121. cd /var/lib/dpkg
  122. for f in diversions statoverride status ; do
  123. if [ ! -f "$f" ] ; then
  124. touch "$f"
  125. fi
  126. done