update 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #!/bin/sh
  2. set -e
  3. vardir="$1"
  4. method=$2
  5. option=$3
  6. iarch=`dpkg --print-installation-architecture`
  7. cd "$vardir/methods/$method"
  8. . ./shvar.$option
  9. #debug() { echo "DEBUG: $@"; }
  10. debug() { true; }
  11. ismulti() { debug $1 $2; test -e "$1/.disk/info" || test -e "$1$2/.disk/info"; }
  12. packages=0
  13. for f in main ctb nf nonus nonusctb nonusnf lcl
  14. do
  15. eval 'this_packages=$p_'$f'_packages'
  16. if [ -n "$this_packages" ]
  17. then
  18. packages=1
  19. fi
  20. done
  21. if [ $packages eq 0 ]
  22. then
  23. echo '
  24. No Packages files available, cannot update available packages list.
  25. Hit RETURN to continue. '
  26. read response
  27. exit 0
  28. fi
  29. xit=1
  30. trap '
  31. rm -f packages-{main,ctb,nf,nonus,nonusctb,nonusnf,lcl}
  32. if [ -n "$umount" ]
  33. then
  34. umount "$umount" >/dev/null 2>&1
  35. fi
  36. exit $xit
  37. ' 0
  38. if [ ! -b "$p_blockdev" ]
  39. then
  40. loop=",loop"
  41. fi
  42. if [ -n "$p_blockdev" ]
  43. then
  44. umount="$p_mountpoint"
  45. mount -rt "$p_fstype" -o nosuid,nodev${loop} "$p_blockdev" "$p_mountpoint"
  46. fi
  47. if [ -n "$p_nfs" ]
  48. then
  49. umount="$p_mountpoint"
  50. mount -rt nfs "$p_nfs" -o nosuid,nodev "$p_mountpoint"
  51. fi
  52. updatetype=update
  53. if [ -z "$p_multi" ]; then
  54. exit 1
  55. fi
  56. for f in main ctb nf nonus nonusctb nonusnf lcl
  57. do
  58. eval 'this_packages=$p_'$f'_packages'
  59. case "$this_packages" in
  60. '')
  61. continue
  62. ;;
  63. scan)
  64. eval 'this_binary=$p_'$f'_binary'
  65. if [ -z "$this_binary" ]; then continue; fi
  66. if [ "$updatetype" = update ]
  67. then
  68. dpkg --clear-avail
  69. updatetype=merge
  70. fi
  71. echo Running dpkg --record-avail -R "$p_mountpoint$this_binary"
  72. dpkg --record-avail -R "$p_mountpoint$this_binary"
  73. ;;
  74. *)
  75. packagesfile="$p_mountpoint$this_packages"
  76. case "$packagesfile" in
  77. *.gz | *.Z | *.GZ | *.z)
  78. echo -n "Uncompressing $packagesfile ... "
  79. zcat <"$packagesfile" >packages-$f
  80. echo done.
  81. dpkg --$updatetype-avail packages-$f
  82. updatetype=merge
  83. ;;
  84. '')
  85. ;;
  86. *)
  87. dpkg --$updatetype-avail "$packagesfile"
  88. updatetype=merge
  89. ;;
  90. esac
  91. ;;
  92. esac
  93. done
  94. cp -f $vardir/available $vardir/methods/$method
  95. dpkg --forget-old-unavail
  96. echo -n 'Update OK. Hit RETURN. '
  97. read response
  98. xit=0