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

@ -44,12 +44,13 @@ jobs:
git config --global --add safe.directory ${SUBSURFACE_REPO_PATH}/libdivecomputer
cd /win
ln -s /__w/subsurface/subsurface .
bash -x subsurface/.github/workflows/scripts/windows-container-prep.sh 2>&1 | tee pre-build.log
bash -x subsurface/packaging/windows/container-prep.sh 2>&1 | tee pre-build.log
- name: run build
run: |
export OUTPUT_DIR="$GITHUB_WORKSPACE"
cd /win
bash -x subsurface/.github/workflows/scripts/windows-in-container-build.sh 2>&1 | tee build.log
bash -x subsurface/packaging/windows/in-container-build.sh 2>&1 | tee build.log
grep "Built target installer" build.log
# only publish a 'release' on push events (those include merging a PR)

1
.gitignore vendored
View file

@ -49,3 +49,4 @@ appdata/subsurface.appdata.xml
android-mobile/Roboto-Regular.ttf
gh_release_notes.md
release_content_title.txt
/output/

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

@ -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

@ -19,14 +19,14 @@ 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* ${GITHUB_WORKSPACE}/
mv subsurface/subsurface.exe* ${OUTPUT_DIR}/
fullname=$(cd subsurface ; ls subsurface-*.exe)
mv subsurface/"$fullname" ${GITHUB_WORKSPACE}/"${fullname%.exe}-installer.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 ${GITHUB_WORKSPACE}/
mv smtk-import/smtk2ssrf.exe ${OUTPUT_DIR}/
fullname=$(cd smtk-import ; ls smtk2ssrf*.exe)
mv smtk-import/smtk2ssrf*.exe ${GITHUB_WORKSPACE}/"${fullname%.exe}-installer.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"

View file

@ -1,36 +0,0 @@
# Instructions for building the container environment and using it to build/package subsurface.
This document assumes you have alreay installed docker and have checked out subsurface according to the instructions in the INSTALL document.
If you just want to build with the current mxe build container then starting from the folder above subsurface run
```bash
docker run -v $PWD/win32:/win/win32 -v $PWD/subsurface:/win/subsurface --name=mybuilder -w /win -d subsurface/mxe-build:x.y /bin/sleep 60m
```
replacing the x.y in the mxe-build tag with the current version e.g. 3.1.0
Next you need to prep the container by installing some prerequisites
```bash
docker exec -t mybuilder bash subsurface/.github/workflows/scripts/windows-container-prep.sh 2>&1 | tee pre-build.log
```
Finaly the actual build is done with
```bash
docker exec -t mybuilder bash subsurface/.github/workflows/scripts/windows-in-container-build.sh 2>&1 | tee build.log
```
To get the built binary out of the container
```
docker exec -t mybuilder bash -c "cp /subsurface-*-installer.exe /win/win32"
```
Which will copy the installer into the win32 folder which will be a sibling of the subsurface folder.
## Modifying the container
If you want to make changes to the build environment used in the conatiner
The script scripts/docker/mxe-build-container/build-container.sh will build the Docker image itself.
The sha of the version of MXE we are using is built into this, so you can update that to whatever version is required, and modify dockerfiles and settings-stage1.mk and settings-stage2.mk to pull in any other prerequisites as required.
If you are working on updating the container then you should incrment the minor version of the variable VERSION in the script as otherwise it will clash with the version used in production