123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/bin/bash
  2. . <(ffoom init)
  3. FFOO_INI_PATH="__FFOO_INI_PATH__"
  4. ffoo import core
  5. ffoo import ini
  6. ffoo import yummy
  7. usage() {
  8. usage_is "[-d] [-f] NVRLIST" \
  9. "[-d] -n NVR -t DEST"
  10. }
  11. while true; do case $1 in
  12. -b|--brewroot) brewroot=$2; shift 2; ;;
  13. -f|--file) nvrlist=$2; shift 2; break; ;;
  14. -n|--nvr) nvr=$2; shift 2; ;;
  15. -t|--to) dest=$2; shift 2; ;;
  16. -d|--debug) FFOO_DEBUG=true; shift; ;;
  17. *) nvrlist=$1; shift; break ;;
  18. esac done
  19. test -n "$brewroot" || brewroot=$(iniread -p get.brewroot)
  20. test -n "$brewroot" || die "specify '-b /path/to/brewroot or get.brewroot in get.ini"
  21. test -d "$brewroot" || die "cannot access brewroot: $brewroot"
  22. get_nvr() {
  23. local nvr=$1
  24. local dest=$2
  25. local arch="$(nvc_parse arch $nvr)"
  26. local release="$(nvc_parse release $nvr)"
  27. local version="$(nvc_parse version $nvr)"
  28. local name="$(nvc_parse name $nvr)"
  29. debug -v nvr arch release version name dest
  30. rm -rf $dest
  31. mkdir -p $dest
  32. local pkgroot="$brewroot/packages/$name/$version/$release"
  33. rsync -u "$pkgroot/$arch/"* "$dest"
  34. test -f "$pkgroot/noarch/"* && rsync -u "$pkgroot/noarch/"* "$dest"
  35. $FFOO_VERBOSE && find $dest -type f
  36. }
  37. if test -n "$nvrlist"; # NVR list provided; make up DESTs and call self
  38. then
  39. dirname="rpms.$(basename $nvrlist)"
  40. rm -f rpms
  41. archs=$(iniread -k arch - < $nvrlist | paste -sd,)
  42. if test -z "$archs";
  43. then
  44. warn "archs not specified, using $(which arch)"
  45. archs=$(arch)
  46. fi
  47. for arch in $(tr "," " " <<<"$archs");
  48. do
  49. get_nvr $(iniread -k old - < $nvrlist).$arch "$dirname/old/$arch"
  50. get_nvr $(iniread -k new - < $nvrlist).$arch "$dirname/new/$arch"
  51. done
  52. ln -s $dirname rpms
  53. elif test -n "$nvr" -a -n "$dest"; # NVR and DEST provided -- do your job
  54. then
  55. get_nvr "$nvr" "$dest"
  56. else
  57. usage
  58. fi
  59. # tigervnc-1.2.80/0.23.20130314svn5065.el7$
  60. # |||||
  61. # vvvvv
  62. # /brewroot/packages/tigervnc/1.2.80/0.23.20130314svn5065.el7$