1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232
|
#!/bin/bash
# this is Windows-specific portion of the release script, which should be run
# after making GNU/Linux and regular Windows builds
#
# the script is expected to be run from the root of the repository
#
# configuration:
# * REMOTE_NAME -- ssh-friendly remote Windows machine address
# * REMOTE_DIR -- absolute path on remote Windows machine
# * REMOTE_WIN_DIR -- absolute path on remote Windows machine in Windows format
# * W32_DIR -- root directory where MXE Win32 build happens
# * W64_DIR -- root directory where MXE Win64 build happens
# * MXE_BUILD_SCR -- script that crossbuilds for Windows using MXE
set -eu
if [ $# -ne 1 ]; then
echo "Usage: $(basename $0) version"
exit 1
fi
version="$1"
case "$version" in
[0-9].[0-9][0-9].[0-9]-beta);;
[0-9].[0-9][0-9]-beta);;
[0-9].[0-9]-beta);;
[0-9].[0-9][0-9].[0-9]);;
[0-9].[0-9][0-9]);;
[0-9].[0-9]);;
*)
echo "ERROR: unrecognized version format: $version"
exit 1
esac
tag="v$version"
if ! commit=$(git rev-parse "$tag"); then
echo "ERROR: failed to resolve tag: '$commit'"
exit 1
fi
REMOTE_NAME="${REMOTE_NAME:-win}"
REMOTE_DIR="${REMOTE_DIR:-/c/repos/vifm}"
REMOTE_WIN_DIR="${REMOTE_WIN_DIR:-c:/repos/vifm}"
W32_DIR="${W32_DIR:-../vifm-mxe-w32/}"
W64_DIR="${W64_DIR:-../vifm-mxe-w64}"
MXE_BUILD_SCR="${MXE_BUILD_SCR:-../build-mxe-vifm}"
echo ::: PREPARING WINDOWS REPOSITORY... :::
ssh "$REMOTE_NAME" bash - << EOF
set -eu
cd "$REMOTE_DIR/"
if ! git diff --quiet; then
echo "Windows repository contains changes. Aborting."
exit 1
fi
# pull remote tags discarding any conflicting local ones
git fetch --tags --force
if [ "\$(git rev-parse "$tag")" != "$commit" ]; then
echo "Windows repository resolves tag differently. Aborting."
exit 1
fi
git checkout "$tag"
EOF
echo ::: BUILDING... :::
( cd "$W32_DIR" && "$MXE_BUILD_SCR" --32 "$tag" )
( cd "$W64_DIR" && "$MXE_BUILD_SCR" --64 "$tag" )
echo ::: PREPARING REMOTE DIRECTORIES... :::
ssh "$REMOTE_NAME" bash - << EOF
set -eu
rm -rf "$REMOTE_DIR/w32/" "$REMOTE_DIR/w64/"
mkdir -p "$REMOTE_DIR/w32/" "$REMOTE_DIR/w64/"
EOF
echo ::: COPYING EXECUTABLES TO THE REMOTE... :::
scp "$W32_DIR"/src/*.exe "$REMOTE_NAME:$REMOTE_WIN_DIR/w32/"
scp "$W64_DIR"/src/*.exe "$REMOTE_NAME:$REMOTE_WIN_DIR/w64/"
echo ::: BUILDING AND PACKAGING WINDOWS VERSION... :::
ssh "$REMOTE_NAME" bash - << EOF
set -eu
cd "$REMOTE_DIR/"
scripts/release "$version" archive
EOF
echo ::: PACKAGING SINGLE-EXECUTABLE VERSIONS... :::
win="vifm-w32-$version-binary"
w32="vifm-w32-se-$version-binary"
w64="vifm-w64-se-$version-binary"
ssh "$REMOTE_NAME" bash - << EOF
set -eu
cd "$REMOTE_DIR/"
rm -rf "$w32.zip" "$w32"
cp -r "$win" "$w32"
chmod -R u=rw,go=r,a+X "$w32"
rm "$w32"/*.dll
cp w32/*.exe "$w32"
zip -9 -r "$w32.zip" "$w32"
rm -rf "$w64.zip" "$w64"
cp -r "$win" "$w64"
chmod -R u=rw,go=r,a+X "$w64"
rm "$w64"/*.dll
cp w64/*.exe "$w64"
zip -9 -r "$w64.zip" "$w64"
EOF
echo ::: COPYING WINDOWS VERSIONS LOCALLY... :::
scp "$REMOTE_NAME:$REMOTE_WIN_DIR/$win.zip" \
"$REMOTE_NAME:$REMOTE_WIN_DIR/$w32.zip" \
"$REMOTE_NAME:$REMOTE_WIN_DIR/$w64.zip" .
chmod -x "$win.zip" "$w32.zip" "$w64.zip"
echo ::: VERIFYING PACKAGES... :::
unzip "$win.zip"
unzip "$w32.zip"
unzip "$w64.zip"
x32_exe='Intel i386'
x64_exe='x86-64'
ret=0
if [[ ! "$(file -b "$win/vifm.exe")" =~ "$x32_exe" ]]; then
echo "ERROR: Wrong type of $win/vifm.exe:"
file -b "$win/vifm.exe"
ret=1
fi
if [[ ! "$(file -b "$win/win_helper.exe")" =~ "$x32_exe" ]]; then
echo "ERROR: Wrong type of $win/win_helper.exe:"
file -b "$win/win_helper.exe"
ret=1
fi
if [[ ! "$(file -b "$w32/vifm.exe")" =~ "$x32_exe" ]]; then
echo "ERROR: Wrong type of $w32/vifm.exe:"
file -b "$w32/vifm.exe"
ret=1
fi
if [[ ! "$(file -b "$w32/win_helper.exe")" =~ "$x32_exe" ]]; then
echo "ERROR: Wrong type of $w32/win_helper.exe:"
file -b "$w32/win_helper.exe"
ret=1
fi
if [[ ! "$(file -b "$w64/vifm.exe")" =~ "$x64_exe" ]]; then
echo "ERROR: Wrong type of $w64/vifm.exe:"
file -b "$w64/vifm.exe"
ret=1
fi
if [[ ! "$(file -b "$w64/win_helper.exe")" =~ "$x64_exe" ]]; then
echo "ERROR: Wrong type of $w64/win_helper.exe:"
file -b "$w64/win_helper.exe"
ret=1
fi
rm -rf "$win" "$w32" "$w64"
if [ "$ret" -ne 0 ]; then
exit "$ret"
fi
echo ::: COPYING SE TESTS... :::
rm -r "$W32_DIR/tests/bin/build" "$W64_DIR/tests/bin/build"
scp -r "$W32_DIR/tests/bin" "$W32_DIR/tests/test-data" \
"$REMOTE_NAME:$REMOTE_WIN_DIR/w32/"
scp -r "$W64_DIR/tests/bin" "$W64_DIR/tests/test-data" \
"$REMOTE_NAME:$REMOTE_WIN_DIR/w64/"
echo ::: RUNNING SE TESTS... :::
ssh "$REMOTE_NAME" bash - << EOF
set -eu
cd "$REMOTE_DIR/w32/"
for test in bin/*; do
basename="\${test#*/}"
name="\${basename%.*}"
mkdir -p "sandbox/\$name"
if [ "\$name" = "fuzz" ] || [ "\$name" = "io_tester_app" ] || [ "\$name" = "regs_shmem_app" ]; then
continue
fi
if ! \$test -s; then
echo "FAILED: \$test (32-bit)"
exit 1
fi
done
cd "$REMOTE_DIR/w64/"
for test in bin/*; do
basename="\${test#*/}"
name="\${basename%.*}"
mkdir -p "sandbox/\$name"
if [ "\$name" = "fuzz" ] || [ "\$name" = "io_tester_app" ] || [ "\$name" = "regs_shmem_app" ]; then
continue
fi
if ! \$test -s; then
echo "FAILED: \$test (64-bit)"
exit 1
fi
done
EOF
echo ::: CLEANING UP REMOTE DIRECTORIES... :::
ssh "$REMOTE_NAME" bash - << EOF
set -eu
rm -rf "$REMOTE_DIR/w32/" "$REMOTE_DIR/w64/"
rm -rf "$REMOTE_DIR/$win" "$REMOTE_DIR/$w32" "$REMOTE_DIR/$w64"
EOF
echo SUCCESS: everything is fine
|