update 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #!/bin/sh
  2. # Copyright (C) 1995-98 Ian Jackson <ian@chiark.greenend.org.uk>
  3. # Copyright (C) 1998 Heiko Schlittermann <heiko@lotte.sax.de>
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; version 2 dated June, 1991.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. set -e
  17. vardir="$1"
  18. method=$2
  19. option=$3
  20. iarch=`dpkg --print-architecture`
  21. cd "$vardir/methods/$method"
  22. . ./shvar.$option
  23. #debug() { echo "DEBUG: $@"; }
  24. debug() { true; }
  25. ismulti() { debug $1 $2; test -e "$1/.disk/info" || test -e "$1$2/.disk/info"; }
  26. packages=0
  27. for f in main ctb nf nonus nonusctb nonusnf lcl
  28. do
  29. eval 'this_packages=$p_'$f'_packages'
  30. if [ -n "$this_packages" ]
  31. then
  32. packages=1
  33. fi
  34. done
  35. if [ $packages eq 0 ]
  36. then
  37. echo '
  38. No Packages files available, cannot update available packages list.
  39. Hit RETURN to continue. '
  40. read response
  41. exit 0
  42. fi
  43. xit=1
  44. trap '
  45. rm -f packages-{main,ctb,nf,nonus,nonusctb,nonusnf,lcl}
  46. if [ -n "$umount" ]
  47. then
  48. umount "$umount" >/dev/null 2>&1
  49. fi
  50. exit $xit
  51. ' 0
  52. if [ ! -b "$p_blockdev" ]
  53. then
  54. loop=",loop"
  55. fi
  56. if [ -n "$p_blockdev" ]
  57. then
  58. umount="$p_mountpoint"
  59. mount -rt "$p_fstype" -o nosuid,nodev${loop} "$p_blockdev" "$p_mountpoint"
  60. fi
  61. if [ -n "$p_nfs" ]
  62. then
  63. umount="$p_mountpoint"
  64. mount -rt nfs "$p_nfs" -o nosuid,nodev "$p_mountpoint"
  65. fi
  66. updatetype=update
  67. if [ -z "$p_multi" ]; then
  68. exit 1
  69. fi
  70. for f in main ctb nf nonus nonusctb nonusnf lcl
  71. do
  72. eval 'this_packages=$p_'$f'_packages'
  73. case "$this_packages" in
  74. '')
  75. continue
  76. ;;
  77. scan)
  78. eval 'this_binary=$p_'$f'_binary'
  79. if [ -z "$this_binary" ]; then continue; fi
  80. if [ "$updatetype" = update ]
  81. then
  82. dpkg --clear-avail
  83. updatetype=merge
  84. fi
  85. echo Running dpkg --record-avail -R "$p_mountpoint$this_binary"
  86. dpkg --record-avail -R "$p_mountpoint$this_binary"
  87. ;;
  88. *)
  89. packagesfile="$p_mountpoint$this_packages"
  90. case "$packagesfile" in
  91. *.gz | *.Z | *.GZ | *.z)
  92. echo -n "Uncompressing $packagesfile ... "
  93. zcat <"$packagesfile" >packages-$f
  94. echo done.
  95. dpkg --$updatetype-avail packages-$f
  96. updatetype=merge
  97. ;;
  98. '')
  99. ;;
  100. *)
  101. dpkg --$updatetype-avail "$packagesfile"
  102. updatetype=merge
  103. ;;
  104. esac
  105. ;;
  106. esac
  107. done
  108. cp -f $vardir/available $vardir/methods/$method
  109. echo -n 'Update OK. Hit RETURN. '
  110. read response
  111. xit=0