get_all_pkgs.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/sh
  2. # Author: thuban <thuban@yeuxdelibad.net>, h3artbl33d
  3. # License: MIT
  4. # Description: Download all packages and theirs dependencies
  5. . ./vars.conf
  6. OUTDIR=site/home/root/pkg_cache
  7. get_deps() {
  8. DEPS=$(pkg_info -f $1 | grep '^@depend' | cut -f 3 -d :)
  9. echo $DEPS
  10. }
  11. dl_pkgs() {
  12. DEPS=$(get_deps $1)
  13. for d in $DEPS; do
  14. if [ ! -f $OUTDIR/$d.tgz ]; then
  15. ftp -C -o $OUTDIR/$d.tgz $PKG_PATH/$d.tgz
  16. dl_pkgs $d
  17. fi
  18. done
  19. p=$(pkg_info $1 | head -n1 | cut -d' ' -f 3)
  20. # test if url in description -> package not installed
  21. if [ -n "$(echo $p |grep $PKG_PATH)" ]; then
  22. if [ ! -f $OUTDIR/$(basename $p) ]; then
  23. ftp -C -o $OUTDIR/$(basename $p) $p
  24. else
  25. echo "$p already downloaded"
  26. fi
  27. else
  28. p=$(echo $p | cut -d':' -f2)
  29. if [ ! -f $OUTDIR/$p.tgz ]; then
  30. ftp -C -o $OUTDIR/$p.tgz $PKG_PATH/$p.tgz
  31. else
  32. echo "$p already downloaded"
  33. fi
  34. fi
  35. if [ $? -ne 0 ]; then
  36. echo "download failed"
  37. exit 1
  38. fi
  39. }
  40. mkdir -p $OUTDIR
  41. # quirks is needed
  42. dl_pkgs "quirks"
  43. for p in $PACKAGES; do
  44. echo ""
  45. echo "*** $p"
  46. dl_pkgs $p
  47. done
  48. exit 0