dpkg.postinst 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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 [ -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. if [ -z "$2" -a ! -f /etc/dpkg/dpkg.cfg ] ; then
  20. cp /usr/share/doc/dpkg/dpkg.cfg /etc/dpkg
  21. fi
  22. case "$2" in
  23. 0.* | 1.0.* | 1.1.0 | 1.1.0[^0-9]* | '' )
  24. for f in 0 1 2 3 4 5 6
  25. do
  26. cd /etc/rc$f.d
  27. for g in K[0-9][0-9]*
  28. do
  29. if [ -n "`echo \"x$g\" | tr -d 0-9A-Za-z_-`" ]
  30. then
  31. continue
  32. fi
  33. h="`echo $g | sed -e 's/^K/S/'`"
  34. if ! [ -L $h -a -L $g ] \
  35. || [ "`ls -Li $g 2>/dev/null | awk '{print $1}'`" != \
  36. "`ls -Li $h 2>/dev/null | awk '{print $1}'`" ]
  37. then
  38. continue
  39. fi
  40. removes="$removes rc$f.d/$g"
  41. done
  42. done
  43. if [ -n "$removes" ]
  44. then
  45. cd /etc
  46. dupdaemonhelp
  47. while [ -n "$removes" ]
  48. do
  49. echo -n 'y=remove, n=leave, l=list, h=help ? '
  50. read response
  51. case "$response" in
  52. [Yy]*)
  53. echo "Removing duplicate K links ..."
  54. rm -v $removes
  55. removes=""
  56. ;;
  57. [Nn]*)
  58. echo -e "OK, leaving them.\n"
  59. removes=""
  60. ;;
  61. [Ll]*)
  62. echo
  63. echo $removes
  64. echo
  65. ;;
  66. [Hh]*)
  67. dupdaemonhelp
  68. ;;
  69. esac
  70. done
  71. fi
  72. ;;
  73. 1.1.6 | 1.1.6elf | 1.2.[0123] | 1.2.[0123]elf )
  74. response=''
  75. while [ -z "$response" ]; do
  76. echo -n '
  77. The version of dpkg you'\''re upgrading from had a problem with the
  78. install-info program used to maintain the /usr/info/dir file. It may
  79. have corrupted the file, for example by placing new entries for the
  80. menu in it before the `* Menu'\'' line (thus making them ineffective) or
  81. by creating several identical sections.
  82. I can try to sort these problems out, but beware that this process is
  83. not guaranteed not to mess up a dir file which has things that look
  84. like menu entries in the introductory paragraphs. The distributed dir
  85. files do not do this, so if you haven'\''t edited /usr/info/dir it'\''s
  86. almost certainly safe to say `yes'\'' to the next question.
  87. If you say `no'\'' you may wish to check and/or edit /usr/info/dir yourself.
  88. Try to check/repair /usr/info/dir automatically ? [y/n] '
  89. read response
  90. case "$response" in
  91. [Yy]* | '') response=yes ;;
  92. [Nn]*) response=no ;;
  93. *) response='' ;;
  94. esac
  95. done
  96. if [ "$response" = yes ]; then
  97. echo "
  98. Checking/repairing /usr/info/dir ..."
  99. cleanup-info --unsafe
  100. echo
  101. else
  102. echo "
  103. OK.
  104. "
  105. fi
  106. ;;
  107. esac
  108. fi
  109. if [ -d /usr/doc -a ! -e /usr/doc/dpkg -a -d /usr/share/doc/dpkg ] ; then
  110. ln -s ../share/doc/dpkg /usr/doc/dpkg
  111. fi
  112. if [ -d /usr/info -a ! -L /usr/info -a ! -L /usr/info/dir ]; then
  113. echo Moving /usr/info/dir to /usr/share/info/dir.
  114. mv /usr/info/dir /usr/share/info/dir
  115. if [ -f /usr/info/dir.old ]; then
  116. mv /usr/info/dir.old /usr/share/info/dir.old
  117. fi
  118. if [ "`find /usr/info -empty`" = "/usr/info" ]; then
  119. echo Making /usr/info a symlink to /usr/share/info.
  120. rmdir /usr/info
  121. ln -s share/info /usr/info
  122. else
  123. echo Making /usr/info/dir a symlink to /usr/share/info/dir.
  124. ln -sf ../share/info/dir /usr/info/dir
  125. fi
  126. fi
  127. cd /var/lib/dpkg
  128. for f in diversions statoverride status ; do
  129. if [ ! -f "$f" ] ; then
  130. touch "$f"
  131. fi
  132. done