You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

copy-to-target 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/bin/sh
  2. . gconfig
  3. TUSER=${DISTRO:-ubuntu}
  4. QUIET_FLAG="-vP"
  5. usage() {
  6. echo "Usage: ${0##*/} [OPTION]... <command>"
  7. echo "Run command on build target."
  8. echo
  9. cat << EOF
  10. --help display this help and exit
  11. --user=U run as U instead of ubuntu
  12. EOF
  13. }
  14. if [ $# != 0 ] ; then
  15. while true ; do
  16. case "$1" in
  17. --help|-h)
  18. usage
  19. exit 0
  20. ;;
  21. --user|-u)
  22. TUSER="$2"
  23. shift 2
  24. ;;
  25. --quiet|-q)
  26. QUIET_FLAG="-q"
  27. shift 1
  28. ;;
  29. --*)
  30. echo "unrecognized option $1"
  31. exit 1
  32. ;;
  33. *)
  34. break
  35. ;;
  36. esac
  37. done
  38. fi
  39. if [ $# = 0 ] ; then
  40. usage
  41. exit 1
  42. fi
  43. if [ -n "$USE_DOCKER" ]; then
  44. docker exec -u $TUSER gitian-target mkdir -p "/home/$TUSER/$2"
  45. docker cp "$1" gitian-target:"/home/$TUSER/$2"
  46. # newer docker version is strict about non-default-user working directories
  47. if docker exec -u root -w /root gitian-target true > /dev/null 2>&1
  48. then
  49. docker exec -u root -w /root gitian-target chown -R $TUSER:$TUSER "/home/$TUSER/$2"
  50. else
  51. docker exec -u root gitian-target chown -R $TUSER:$TUSER "/home/$TUSER/$2"
  52. fi
  53. elif [ -z "$USE_LXC" ]; then
  54. src="${1%/}" # remove trailing / which triggers special rsync behaviour
  55. rsync --checksum -a $QUIET_FLAG -e "ssh -oConnectTimeout=30 -oNoHostAuthenticationForLocalhost=yes -i ${GITIAN_BASE:-.}/var/id_rsa -p $VM_SSH_PORT" "${src}" "$TUSER@localhost:$2"
  56. else
  57. config-lxc
  58. tar -C `dirname "$1"` -cf - `basename "$1"` | sudo $LXC_EXECUTE -n gitian -f var/lxc.config -- sudo -i -u $TUSER tar -C "$2" -xf -
  59. fi