update 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #!/bin/sh
  2. #
  3. # This program is free software; you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation; either version 2 of the License, or
  6. # (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. set -e
  16. vardir="$1"
  17. method=$2
  18. option=$3
  19. cd "$vardir/methods/disk"
  20. . ./shvar.$option
  21. if [ -z "$p_main_packages" ] && [ -z "$p_ctb_packages" ] && \
  22. [ -z "$p_nf_packages" ] && [ -z "$p_nus_packages " ] && \
  23. [ -z "$p_lcl_packages" ]
  24. then
  25. echo '
  26. No Packages files available, cannot update available packages list.
  27. Hit RETURN to continue. '
  28. read response
  29. exit 0
  30. fi
  31. xit=1
  32. trap '
  33. rm -f packages-main packages-ctb packages-nf packages-nus packages-lcl
  34. if [ -n "$umount" ]
  35. then
  36. umount "$umount" >/dev/null 2>&1
  37. fi
  38. exit $xit
  39. ' 0
  40. if [ -n "$p_blockdev" ]
  41. then
  42. umount="$p_mountpoint"
  43. mount -rt "$p_fstype" -o nosuid,nodev "$p_blockdev" "$p_mountpoint"
  44. fi
  45. if [ -n "$p_nfs" ]
  46. then
  47. umount="$p_mountpoint"
  48. mount -rt nfs "$p_nfs" -o nosuid,nodev "$p_mountpoint"
  49. fi
  50. updatetype=update
  51. for f in main ctb nf nus lcl
  52. do
  53. eval 'this_packages=$p_'$f'_packages'
  54. case "$this_packages" in
  55. '')
  56. continue
  57. ;;
  58. scan)
  59. eval 'this_binary=$p_'$f'_binary'
  60. if [ -z "$this_binary" ]; then continue; fi
  61. if [ "$updatetype" = update ]
  62. then
  63. dpkg --admindir $vardir --clear-avail
  64. updatetype=merge
  65. fi
  66. echo Running dpkg --record-avail -R "$p_mountpoint$this_binary"
  67. dpkg --admindir $vardir --record-avail -R "$p_mountpoint$this_binary"
  68. ;;
  69. *)
  70. packagesfile="$p_mountpoint$this_packages"
  71. case "$packagesfile" in
  72. *.gz | *.Z | *.GZ | *.z)
  73. echo -n "Uncompressing $packagesfile ... "
  74. zcat <"$packagesfile" >packages-$f
  75. echo done.
  76. dpkg --admindir $vardir --$updatetype-avail packages-$f
  77. updatetype=merge
  78. ;;
  79. '')
  80. ;;
  81. *)
  82. dpkg --admindir $vardir --$updatetype-avail "$packagesfile"
  83. updatetype=merge
  84. ;;
  85. esac
  86. ;;
  87. esac
  88. done
  89. echo -n 'Update OK. Hit RETURN. '
  90. read response
  91. xit=0