update 2.7 KB

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