Changeset View
Changeset View
Standalone View
Standalone View
contrib/gitian-builder/libexec/copy-to-target
- This file was added.
Property | Old Value | New Value |
---|---|---|
File Mode | null | 100755 |
#!/bin/sh | |||||
. gconfig | |||||
TUSER=${DISTRO:-ubuntu} | |||||
QUIET_FLAG="-vP" | |||||
usage() { | |||||
echo "Usage: ${0##*/} [OPTION]... <command>" | |||||
echo "Run command on build target." | |||||
echo | |||||
cat << EOF | |||||
--help display this help and exit | |||||
--user=U run as U instead of ubuntu | |||||
EOF | |||||
} | |||||
if [ $# != 0 ] ; then | |||||
while true ; do | |||||
case "$1" in | |||||
--help|-h) | |||||
usage | |||||
exit 0 | |||||
;; | |||||
--user|-u) | |||||
TUSER="$2" | |||||
shift 2 | |||||
;; | |||||
--quiet|-q) | |||||
QUIET_FLAG="-q" | |||||
shift 1 | |||||
;; | |||||
--*) | |||||
echo "unrecognized option $1" | |||||
exit 1 | |||||
;; | |||||
*) | |||||
break | |||||
;; | |||||
esac | |||||
done | |||||
fi | |||||
if [ $# = 0 ] ; then | |||||
usage | |||||
exit 1 | |||||
fi | |||||
if [ -n "$USE_DOCKER" ]; then | |||||
docker exec -u $TUSER gitian-target mkdir -p "/home/$TUSER/$2" | |||||
docker cp "$1" gitian-target:"/home/$TUSER/$2" | |||||
docker exec -u root gitian-target chown -R $TUSER:$TUSER "/home/$TUSER/$2" | |||||
elif [ -z "$USE_LXC" ]; then | |||||
src="${1%/}" # remove trailing / which triggers special rsync behaviour | |||||
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" | |||||
else | |||||
config-lxc | |||||
tar -C `dirname "$1"` -cf - `basename "$1"` | sudo $LXC_EXECUTE -n gitian -f var/lxc.config -- sudo -i -u $TUSER tar -C "$2" -xf - | |||||
fi |