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