Packaging: Cleanup Windows Build Scripts.

Do some housekeeping and cleanup on the build scripts for Windows:
- remove Windows 32bit builds as support for this has been removed from
  the mxe container;
- fix some warnings in the smtk2ssrf installer configuration;
- sanitise the output colour of the smtk2ssrf build script;
- add a docker based build script for the Windows installers;
- remove outdated and deprecated documentation and scripts.

Signed-off-by: Michael Keller <mikeller@042.ch>
This commit is contained in:
Michael Keller 2024-04-24 11:27:10 +12:00 committed by Dirk Hohndel
parent e09a134a3f
commit d92777a3ff
10 changed files with 81 additions and 99 deletions

View file

@ -7,12 +7,15 @@ image that has all the build components pre-assembled.
All it takes is this:
```
cd /some/path/windows
export GIT_AUTHOR_NAME=<your name>
export GIT_AUTHOR_EMAIL=<email to be used with github>
cd /some/path
git clone https://github.com/subsurface/subsurface
cd subsurface
git submodule init
git submodule update
docker run -v /some/path/windows:/__w subsurface/mxe-build:3.1.0 /bin/bash /__w/subsurface/packaging/windows/create-win-installer.sh
./packaging/windows/docker-build.sh
```
This will result in subsurface-VERSION.exe and smtk2ssrf-VERSION.exe to be created.
This will result in subsurface-VERSION.exe and smtk2ssrf-VERSION.exe to be created in /some/path/subsurface/output/windows/.

View file

@ -0,0 +1,8 @@
#!/bin/bash
# abstract the prepare commands for the windows build into a script that can be reused
# instead of a yaml file
echo "downloading sources for fresh build"
bash subsurface/scripts/get-dep-lib.sh single . libzip
bash subsurface/scripts/get-dep-lib.sh single . googlemaps
bash subsurface/scripts/get-dep-lib.sh single . libmtp

View file

@ -1,45 +0,0 @@
#!/bin/bash
# this is run inside the docker container
cd /__w
[ -d mxe ] || ln -s /win/mxe .
# grab the version number
cd subsurface
VERSION=$(./scripts/get-version)
cd ..
# prep the container
bash subsurface/.github/workflows/scripts/windows-container-prep.sh
# remove artifact from prior builds
rm -f mdbtools/include/mdbver.h
# build the 64bit installer
rm -rf win64
mkdir win64
cd win64
# build Subsurface and then smtk2ssrf
export MXEBUILDTYPE=x86_64-w64-mingw32.shared
export PATH=/win/mxe/usr/bin:$PATH
bash -ex ../subsurface/packaging/windows/mxe-based-build.sh installer
mv subsurface/subsurface-$VERSION.exe /__w
bash -ex ../subsurface/packaging/windows/smtk2ssrf-mxe-build.sh -a -i
mv smtk-import/smtk2ssrf-$VERSION.exe /__w
if [ "$1" != "-64only" ] ; then
# build the 32bit installer
cd /__w
rm -rf win32
mkdir win32
cd win32
# build Subsurface and then smtk2ssrf
export MXEBUILDTYPE=i686-w64-mingw32.shared
bash -ex ../subsurface/packaging/windows/mxe-based-build.sh installer
mv subsurface/subsurface-$VERSION.exe /__w/subsurface-32bit-$VERSION.exe
fi

View file

@ -0,0 +1,58 @@
#!/bin/bash
#
# Build the Subsurface Windows installer and the Smtk2ssrf Windows installer in a Docker container
#
# Needs the following environment variables to be set
# GIT_AUTHOR_NAME=<your name>
# GIT_AUTHOR_EMAIL=<email to be used with github>
CONTAINER_NAME=windows-builder-docker
pushd .
cd "$(dirname "$0")/../.."
SUBSURFACE_ROOT="${PWD}"
popd
OUTPUT_DIR=output/windows
CONTAINER_ROOT_DIR=/win
CONTAINER_SUBSURFACE_DIR=${CONTAINER_ROOT_DIR}/subsurface
LOGIN_USER=$(id -u)
LOGIN_GROUP=$(id -g)
FULL_USER=${LOGIN_USER}:${LOGIN_GROUP}
# Check if our container exists
CONTAINER_ID=$(docker container ls -a -q -f name=${CONTAINER_NAME})
# Create the container if it does not exist
if [[ -z "${CONTAINER_ID}" ]]; then
docker create -v ${SUBSURFACE_ROOT}:${CONTAINER_SUBSURFACE_DIR} --name=${CONTAINER_NAME} subsurface/mxe-build:3.1.0 sleep infinity
fi
docker start ${CONTAINER_NAME}
BUILD_PARAMETERS=""
if [[ -z "${CONTAINER_ID}" ]]; then
# Prepare the image for first use
docker exec -t ${CONTAINER_NAME} groupadd $(id -g -n) -o -g ${LOGIN_GROUP}
docker exec -t ${CONTAINER_NAME} useradd $(id -u -n) -o -u ${LOGIN_USER} -g ${LOGIN_GROUP} -d ${CONTAINER_ROOT_DIR}
docker exec -t ${CONTAINER_NAME} find ${CONTAINER_ROOT_DIR} -type d -exec chown ${FULL_USER} {} \;
docker exec -u ${FULL_USER} -t ${CONTAINER_NAME} git config --global --add safe.directory ${CONTAINER_SUBSURFACE_DIR}
docker exec -u ${FULL_USER} -t ${CONTAINER_NAME} git config --global --add safe.directory ${CONTAINER_SUBSURFACE_DIR}/libdivecomputer
docker exec -u ${FULL_USER} -t ${CONTAINER_NAME} git config --global --add safe.directory ${CONTAINER_SUBSURFACE_DIR}/nightly-builds
docker exec -u ${FULL_USER} -t ${CONTAINER_NAME} git config --global user.name "${GIT_AUTHOR_NAME}"
docker exec -u ${FULL_USER} -t ${CONTAINER_NAME} git config --global user.email "${GIT_AUTHOR_EMAIL}"
docker exec -u ${FULL_USER} -t ${CONTAINER_NAME} bash -x subsurface/packaging/windows/container-prep.sh
fi
# Build
mkdir -p "${SUBSURFACE_ROOT}/${OUTPUT_DIR}"
docker exec -u ${FULL_USER} -e OUTPUT_DIR=${CONTAINER_SUBSURFACE_DIR}/${OUTPUT_DIR} -t ${CONTAINER_NAME} bash -x subsurface/packaging/windows/in-container-build.sh
# Stop the container
docker stop ${CONTAINER_NAME}

View file

@ -0,0 +1,32 @@
#!/bin/bash
# this gets executed inside the container when building a Windows
# installer as GitHub Action
#
# working directory is assumed to be the directory including all the
# source directories (subsurface, googlemaps, grantlee, etc)
# in order to be compatible with the assumed layout in the MXE script, we
# need to create the secondary build directory
set -x
set -e
mkdir -p win32
cd win32
# build Subsurface and then smtk2ssrf
export MXEBUILDTYPE=x86_64-w64-mingw32.shared
bash -ex ../subsurface/packaging/windows/mxe-based-build.sh installer
# the strange two step move is in order to get predictable names to use
# in the publish step of the GitHub Action
mv subsurface/subsurface.exe* ${OUTPUT_DIR}/
fullname=$(cd subsurface ; ls subsurface-*.exe)
mv subsurface/"$fullname" ${OUTPUT_DIR}/"${fullname%.exe}-installer.exe"
bash -ex ../subsurface/packaging/windows/smtk2ssrf-mxe-build.sh -a -i
# the strange two step move is in order to get predictable names to use
# in the publish step of the GitHub Action
mv smtk-import/smtk2ssrf.exe ${OUTPUT_DIR}/
fullname=$(cd smtk-import ; ls smtk2ssrf*.exe)
mv smtk-import/smtk2ssrf*.exe ${OUTPUT_DIR}/"${fullname%.exe}-installer.exe"

View file

@ -215,16 +215,16 @@ Section "Uninstall"
Delete "$DESKTOP\Smtk2ssrf.lnk"
# remove the registry entires
${If} $Checkbox_Reg_State == 1
DeleteRegKey HKCU "Software\Smtk2ssrf"
${EndIf}
# ${If} $Checkbox_Reg_State == 1
# DeleteRegKey HKCU "Software\Smtk2ssrf"
# ${EndIf}
# remove the user directory
${If} $Checkbox_UserDir_State == 1
${AndIf} $UserDir != ""
${AndIf} ${FileExists} "$UserDir\*.*"
RMDir /r $UserDir
${EndIf}
# ${If} $Checkbox_UserDir_State == 1
# ${AndIf} $UserDir != ""
# ${AndIf} ${FileExists} "$UserDir\*.*"
# RMDir /r $UserDir
# ${EndIf}
# remove the uninstaller entry
DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Smtk2ssrf"

View file

@ -216,4 +216,4 @@ if [ ! -z "$DATADIR" ]; then
cp -vf "$BUILDDIR"/smtk-import/smtk2ssrf-*.exe "$DATADIR"
fi
echo -e "$RED---> Building smtk2ssrf done$DEFAULT"
echo -e "$BLUE---> Building smtk2ssrf done$DEFAULT"