#!/bin/bash syntax() { echo "usage: $0 { --help | -? | -h | platform | option value | switch }+ " echo "platform: all | cygwin | linux | macosx | mingw | mingw32 | msvc" echo "switch: --2015 | --2017 | --publish | --status | --clone | --test" echo "option: --branch x | --server x | --user x | --builds x" } announce() { if [ "$status" != "1" ]; then echo ++++++++++++++++++++++++++++++++ echo $* echo ++++++++++++++++++++++++++++++++ fi } bomb() { echo "*** $1 requires an argument ***" >&2 exit 1 } # write tag into the build directory (in Unix format without \r) writeTag() { # $1 = server name (eg rmillsmm-w7) # $2 = command for ssh (eg msys64 or bash) # $3 = destination of tag echo "echo tag=$tag > $3" | ssh ${user}@$1 $2 } # if we're asked to clone, we remove the old build directory prepareToClone() { # $1 = server name (eg rmillsmm-w7) # $2 = command to remove directory 'buildserver' ("rmdir/s/q ${cd}buildserver") if [ $clone == 1 ]; then echo "$2" | ssh ${user}@$1 2>/dev/null fi } # list the current build reportStatus() { # $1 = server (eg rmillsmm-w7) # $2 = program to run (eg msys64 or bash) # $3 = string to execute (eg cd .../buildserver/build ; ls -alt *.tar *.zip) echo "$3" | ssh ${user}@$1 $2 } unixBuild() { # $1 = server (eg rmillsmm-w7) # $2 = string for announcement (eg 'MinGW 64' ) announce $1 $2 if [ "$status" == "1" ]; then reportStatus $1 $command "cd ${cd}/buildserver/build; ls -alt *.tar.gz | sed -E -e 's/\+ / /g'" else # remove the buildserver directory if we are to clone prepareToClone $1 "rm -rf ${cd}/buildserver" ! ssh ${user}@$1 ${command} <&2; help=1; ;; esac done if [ $help == 1 ]; then syntax; exit 0; fi if [ "$all" == "1" ]; then cygwin=1; linux=1; macosx=1; mingw=1; mingw32=1;msvc=1; fi publishBundle() { # $1 = server (eg rmillsmm-w7) # $2 = path (eg /c/msys32/home/rmills/gnu/github/exiv2/buildserver/build) # $3 = extension (eg tar.gz or zip) # find the build tag left during the build tag_saved=$tag if [ -e tag ]; then rm -rf tag ; fi scp -q "$user@$1:$2/tag" . 2>/dev/null # silently collect build tag file if [ -e tag ]; then source tag; fi # and read it! files=$(ssh $user@$1 "ls -1 $2/*$3" 2>/dev/null) # find the names of the bundles for file in $files; do if [ ! -z $file ]; then # copy to builds/all and merge the tag into the filename scp -pq "$user@$1:$file" $builds/all/$(basename $file $3)-$tag$3 echo $(basename $file $3)-$tag$3 fi done tag=$tag_saved } if [ $publish == 1 ]; then ## create the source package publishBundle $server-ubuntu /home/$user/gnu/github/exiv2/buildserver/build '.tar.gz' publishBundle $server-w7 /c/msys32/home/$user/gnu/github/exiv2/buildserver/build '.tar.gz' publishBundle $server-w7 /c/msys64/home/$user/gnu/github/exiv2/buildserver/build '.tar.gz' publishBundle $server-w7 /c/cygwin64/home/$user/gnu/github/exiv2/buildserver/build '.tar.gz' publishBundle $server-w7 /c/users/$user/gnu/github/exiv2/buildserver/build '.zip' echo "+++++++++++++++++++++++++++++++++++++++++" echo "+++ build Source in exiv2/exiv2 +++" pushd ~/gnu/github/exiv2/exiv2/build >/dev/null make package_source ls -alt *Source.tar.gz|sed -E -e 's/\+ / /g' cp *Source.tar.gz ~/gnu/github/exiv2/buildserver/build popd >/dev/null echo "+++++++++++++++++++++++++++++++++++++++++" publishBundle $server /Users/$user/gnu/github/exiv2/buildserver/build '.tar.gz' cygwin=0; linux=0; macosx=0; mingw=0; mingw32=0;msvc=0; # don't build anything $(dirname $0)/categorize.py $builds fi ## # perform builds if [ $cygwin == 1 ]; then cd=/home/rmills/gnu/github/exiv2/ command='c:\\cygwin64\\bin\\bash.exe' unixBuild ${server}-w7 Cygwin fi if [ $linux == 1 ]; then cd=/home/rmills/gnu/github/exiv2/ command='bash' unixBuild ${server}-ubuntu Linux fi if [ $macosx == 1 ]; then cd=/Users/rmills/gnu/github/exiv2/ command='bash' unixBuild ${server} MacOSX fi if [ $mingw == 1 ]; then cd=/home/rmills/gnu/github/exiv2/ command='msys64' unixBuild ${server}-w7 MinGW/64 fi if [ $mingw32 == 1 ]; then cd=/home/rmills/gnu/github/exiv2/ command='msys32' unixBuild ${server}-w7 MinGW/32 fi if [ $msvc == 1 ]; then command='bash' msvcBuild ${server}-w7 fi # That's all Folks ##