update 2.7 KB

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