debian: moved note about lack of sync support to README.Debian
[barry.git] / maintainer / remote.sh
blob7f1de888085bfc538876802da6c323240da752fb
1 #!/bin/bash
3 if [ -z "$1" -o -z "$2" -o -z "$3" -o -z "$4" -o -z "$5" -o -z "$6" ] ; then
4 echo
5 echo "Usage: ./remote.sh user host port files results_from results_to [args...]"
6 echo
7 echo "user is the username on the remote system to use for building"
8 echo
9 echo "host is the ssh hostname to build the packages"
10 echo
11 echo "port is the ssh port on the remote system"
12 echo
13 echo "files is a string of possibly multiple files to copy over"
14 echo "to the remote system. The files will be copied to the"
15 echo "/home/user/barrychroot directory and any arguments will be"
16 echo "run from there. Normally, the tarball and the script"
17 echo "will be included in this list at a minimum."
18 echo
19 echo "results_from is the directory on the remote system where the"
20 echo "results will be found after running the arguments. i.e. if you"
21 echo "run make-deb.sh on the remote system, results_from is the"
22 echo "directory where the resulting binary packages can be found."
23 echo "This path is a remote path and does not include the hostname."
24 echo "For example: /home/user/results"
25 echo
26 echo "results_to is the local directory into which the resulting files"
27 echo "will be copied. The directory will be created if it"
28 echo "does not already exist."
29 echo
30 echo "Expects to be run as a normal user."
31 echo
32 exit 1
35 REMOTEUSER="$1"
36 HOST="$2"
37 HOSTPORT="$3"
38 FILES="$4"
39 RESULTS_FROM="$5"
40 RESULTS_TO="$6"
41 shift 6
43 set -e
45 function RemoteRun() {
46 ssh -x -2 -p $HOSTPORT $REMOTEUSER@$HOST "$1"
49 REMOTEDIR="/home/$REMOTEUSER/barryremote"
51 # create target work directory
52 RemoteRun "rm -rf '$REMOTEDIR'"
53 RemoteRun "mkdir -p '$REMOTEDIR'"
55 # copy source tarball and script to chroot system
56 scp -P $HOSTPORT $FILES "$REMOTEUSER@$HOST:$REMOTEDIR"
58 # create a quoted argument string
59 QUOTEDARGS="$1"
60 shift
61 for arg ; do
62 QUOTEDARGS="$QUOTEDARGS '$arg'"
63 done
65 # run the args
66 RemoteRun "cd '$REMOTEDIR' && $QUOTEDARGS"
68 # copy the results back to the target directory
69 mkdir -p "$RESULTS_TO"
70 scp -P $HOSTPORT "$REMOTEUSER@$HOST:$RESULTS_FROM/*" "$RESULTS_TO"
72 # cleanup source tarball and script
73 RemoteRun "rm -rf '$REMOTEDIR'"