#!/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
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"
Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/vifm
Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/vifm
You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a
pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master