1#!/bin/bash 2 3# this is a MXE part of deploy script, which should be run after GNU/Linux and 4# regular Windows builds are done 5# 6# the script is expected to be run from the root of the repository 7# 8# configuration: 9# * REMOTE_NAME -- ssh-friendly remote Windows machine address 10# * REMOTE_DIR -- absolute path on remote Windows machine 11# * REMOTE_WIN_DIR -- absolute path on remote Windows machine in Windows format 12# * W32_DIR -- root directory where Win32 build happens 13# * W64_DIR -- root directory where Win64 build happens 14# * W32_BUILD_SCR -- script that builds Win32 release 15# * W64_BUILD_SCR -- script that builds Win64 release 16 17if [ $# -ne 1 ]; then 18 echo "Usage: $(basename $0) version" 19 exit 1 20fi 21 22version="$1" 23 24REMOTE_NAME="${REMOTE_NAME:-win}" 25REMOTE_DIR="${REMOTE_DIR:-/c/repos/vifm}" 26REMOTE_WIN_DIR="${REMOTE_WIN_DIR:-c:/repos/vifm}" 27W32_DIR="${W32_DIR:-../vifm-mxe-w32/}" 28W64_DIR="${W64_DIR:-../vifm-mxe-w64}" 29W32_BUILD_SCR="${W32_BUILD_SCR:-../build_release_x86}" 30W64_BUILD_SCR="${W64_BUILD_SCR:-../build_release_x64}" 31 32set -e 33 34echo ::: BUILDING... ::: 35 36( cd "$W32_DIR" && "$W32_BUILD_SCR" "$version" ) 37( cd "$W64_DIR" && "$W64_BUILD_SCR" "$version" ) 38 39echo ::: CLEANING UP REMOTE DIRECTORIES... ::: 40 41ssh "$REMOTE_NAME" bash - << EOF 42rm -rf "$REMOTE_DIR/w32/" "$REMOTE_DIR/w64/" 43mkdir -p "$REMOTE_DIR/w32/" "$REMOTE_DIR/w64/" 44EOF 45 46echo ::: COPYING EXECUTABLES TO THE REMOTE... ::: 47 48scp "$W32_DIR"/src/*.exe "$REMOTE_NAME:$REMOTE_WIN_DIR/w32/" 49scp "$W64_DIR"/src/*.exe "$REMOTE_NAME:$REMOTE_WIN_DIR/w64/" 50 51echo ::: PACKAGING SINGLE-EXECUTABLE VERSIONS... ::: 52 53maindir="vifm-w32-$version-binary" 54w32="vifm-w32-se-$version-binary" 55w64="vifm-w64-se-$version-binary" 56 57ssh "$REMOTE_NAME" bash - << EOF 58cd "$REMOTE_DIR/" 59 60rm -rf "$w32.zip" "$w32" 61cp -r "$maindir" "$w32" 62chmod -R u=rw,go=r,a+X "$w32" 63rm "$w32"/*.dll 64cp w32/*.exe "$w32" 65zip -9 -r "$w32.zip" "$w32" 66 67rm -rf "$w64.zip" "$w64" 68cp -r "$maindir" "$w64" 69chmod -R u=rw,go=r,a+X "$w64" 70rm "$w64"/*.dll 71cp w64/*.exe "$w64" 72zip -9 -r "$w64.zip" "$w64" 73EOF 74 75echo ::: COPYING SINGLE-EXECUTABLE VERSIONS LOCALLY... ::: 76 77scp "$REMOTE_NAME:$REMOTE_WIN_DIR/$w32.zip" \ 78 "$REMOTE_NAME:$REMOTE_WIN_DIR/$w64.zip" . 79chmod -x "$w32.zip" "$w64.zip" 80 81echo ::: VERIFYING PACKAGES... ::: 82 83unzip "$w32.zip" 84unzip "$w64.zip" 85 86x32_exe='PE32 executable (console) Intel 80386 (stripped to external PDB), for MS Windows' 87x64_exe='PE32+ executable (console) x86-64 (stripped to external PDB), for MS Windows' 88 89ret=0 90 91if [ "$(file -b "$w32/vifm.exe")" != "$x32_exe" ]; then 92 echo "ERROR: Wrong type of $w32/vifm.exe:" 93 file -b "$w32/vifm.exe" 94 ret=1 95fi 96if [ "$(file -b "$w32/win_helper.exe")" != "$x32_exe" ]; then 97 echo "ERROR: Wrong type of $w32/win_helper.exe:" 98 file -b "$w32/win_helper.exe" 99 ret=1 100fi 101if [ "$(file -b "$w64/vifm.exe")" != "$x64_exe" ]; then 102 echo "ERROR: Wrong type of $w64/vifm.exe:" 103 file -b "$w64/vifm.exe" 104 ret=1 105fi 106if [ "$(file -b "$w64/win_helper.exe")" != "$x64_exe" ]; then 107 echo "ERROR: Wrong type of $w64/win_helper.exe:" 108 file -b "$w64/win_helper.exe" 109 ret=1 110fi 111 112rm -rf "$w32" "$w64" 113 114if [ "$ret" -ne 0 ]; then 115 exit "$ret" 116fi 117 118echo ::: COPYING TESTS... ::: 119 120rm -r "$W32_DIR/tests/bin/build" "$W64_DIR/tests/bin/build" 121 122scp -r "$W32_DIR/tests/bin" "$W32_DIR/tests/test-data" \ 123 "$REMOTE_NAME:$REMOTE_WIN_DIR/w32/" 124scp -r "$W64_DIR/tests/bin" "$W64_DIR/tests/test-data" \ 125 "$REMOTE_NAME:$REMOTE_WIN_DIR/w64/" 126 127echo ::: RUNNING TESTS... ::: 128 129ssh "$REMOTE_NAME" bash - << EOF 130cd "$REMOTE_DIR/w32/" 131for test in bin/*; do 132 basename="\${test#*/}" 133 name="\${basename%.*}" 134 mkdir -p "sandbox/\$name" 135 if [ "\$name" = "fuzz" ] || [ "\$name" = "regs_shmem_app" ]; then 136 continue 137 fi 138 if ! \$test -s; then 139 exit 1 140 fi 141done 142 143cd "$REMOTE_DIR/w64/" 144for test in bin/*; do 145 basename="\${test#*/}" 146 name="\${basename%.*}" 147 mkdir -p "sandbox/\$name" 148 if [ "\$name" = "fuzz" ] || [ "\$name" = "regs_shmem_app" ]; then 149 continue 150 fi 151 if ! \$test -s; then 152 exit 1 153 fi 154done 155EOF 156 157echo SUCCESS: everything is fine 158