mock-sync.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/bin/bash
  2. dir=$PWD
  3. arch=$1
  4. if [ -z "$arch" ]; then
  5. echo "Specify if 32 or 64 arch sync"
  6. exit 1
  7. fi
  8. shift 1
  9. if [ "$1" = "-n" ]; then
  10. rsync_args=-vvn
  11. shift 1
  12. fi
  13. if [ -r ./mock-config.txt ]; then
  14. . ./mock-config.txt
  15. else
  16. echo "Missing mock-config.txt"
  17. exit 1
  18. fi
  19. if [ -z "$dst_root" ]; then
  20. echo "Specify the dst_root (relative destination root) in the mock-config.txt"
  21. exit 1
  22. fi
  23. if [ ! -z "$parent" ]; then
  24. src_root=$dir/$parent
  25. else
  26. src_root=$dir
  27. fi
  28. if [ $arch -eq 32 ]; then
  29. ROOT=$ROOT32
  30. elif [ $arch -eq 64 ]; then
  31. ROOT=$ROOT64
  32. else
  33. echo "Pick a correct sync arch (32 or 64)"
  34. exit 1
  35. fi
  36. root=`mock -r $ROOT --print-root-path`/builddir
  37. if [ ! -e $dir/mock-sync.txt -a ! -e $dir/mock-rsync.txt ]; then
  38. echo "App has no mock-sync.txt or mock-rsync.txt"
  39. continue
  40. fi
  41. if [ -e $dir/mock-sync.txt ]; then
  42. pushd $src_root
  43. srcpaths=`cat $dir/mock-sync.txt`
  44. for srcpath in $srcpaths; do
  45. if [ -d $srcpath ]; then
  46. mkdir -p $root/$dst_root/$srcpath/
  47. rsync -a --delete-after $srcpath/ $root/$dst_root/$srcpath/ $rsync_args
  48. else
  49. mkdir -p `dirname $root/$dst_root/$srcpath `
  50. rsync -a --delete-after $srcpath $root/$dst_root/$srcpath $rsync_args
  51. fi
  52. done
  53. popd
  54. fi
  55. if [ -e $dir/mock-rsync.txt ]; then
  56. rsync -a -f ". $dir/mock-rsync.txt" $src_root/ $root/$dst_root/ $rsync_args
  57. fi