Skip to content

Commit 5471587

Browse files
committed
windows-msi: Replace build.wsf and build-and-package.ps1 with CMake
The JavaScript code had a limited implementation of a make system. So instead replace it by using an actual make system. File dependencies are downloaded in the configuration phase. Also replace version.m4 with a version.cmake since I could find no indication that it was used with m4 currently (maybe it was useful in the distant past, but not today). Github: Closes #1111 Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
1 parent 502fa73 commit 5471587

25 files changed

+758
-1904
lines changed

.github/workflows/build.yaml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
SigningKeyStore: ${{ secrets.GOOGLE_CLOUD_KMS_KEYRING }}
2323
SigningStoreKeyName: ${{ secrets.GOOGLE_CLOUD_KMS_KEY }}
2424
SigningCertificateFile: ${{ github.workspace }}/certificate.pem
25+
ManifestTimestampRFC3161Url: http://timestamp.digicert.com
2526
VCPKG_BINARY_SOURCES: clear;files,${{ github.workspace }}/vcpkg_cache,readwrite
2627

2728
name: 'openvpn-build'
@@ -83,9 +84,9 @@ jobs:
8384
$BuildVersion = 10000 + [int]$env:GITHUB_RUN_NUMBER
8485
$NewProductVersion = "2.7.$BuildVersion"
8586
echo $NewProductCode $NewProductVersion
86-
$version_m4 = (Get-Content version.m4)
87-
$version_m4 -replace '^define\(\[PRODUCT_CODE\], \[\{(?<ProductCode>.*)\}]\)', "define([PRODUCT_CODE], [{${NewProductCode}}])" `
88-
-replace '^define\(\[PRODUCT_VERSION\], \[(.*?)\]\)', "define([PRODUCT_VERSION], [${NewProductVersion}])" | Out-File -Encoding ASCII version.m4
87+
$version_cmake = (Get-Content version.cmake)
88+
$version_cmake -replace '^set\(PRODUCT_CODE\s+"\{.*?\}"\)', "set(PRODUCT_CODE `"{${NewProductCode}}`")" `
89+
-replace '^set\(PRODUCT_VERSION\s+".*?"\)', "set(PRODUCT_VERSION `"${NewProductVersion}`")" | Out-File -Encoding ASCII version.cmake
8990
9091
- name: Authenticate to Google Cloud
9192
id: 'auth'
@@ -105,26 +106,28 @@ jobs:
105106
if: ${{ env.SigningKeyStore != '' }}
106107
run: |
107108
echo "${{ secrets.SIGNING_CERTIFICATE }}" >${{ github.workspace }}/certificate.pem
108-
./build-and-package.ps1 -sign -arch ${{ matrix.arch }}
109+
cmake -B build -DOPENVPN_ARCH=${{ matrix.arch }} -DSIGN_BINARIES=ON
110+
cmake --build build
109111
110112
- name: Build
111113
working-directory: windows-msi
112114
if: ${{ env.SigningKeyStore == '' }}
113115
run: |
114-
./build-and-package.ps1 -arch ${{ matrix.arch }}
116+
cmake -B build -DOPENVPN_ARCH=${{ matrix.arch }}
117+
cmake --build build
115118
116119
- name: Rename MSI
117120
run: |
118121
$commit = git -C ./src/openvpn rev-parse --short HEAD
119122
$dt = Get-Date -Format "yyyyMMddThhmm"
120-
$orig_msi_name = (Get-Item .\windows-msi\image\*-${{ matrix.arch }}.msi).Name
123+
$orig_msi_name = (Get-Item .\windows-msi\build\image\*-${{ matrix.arch }}.msi).Name
121124
$msi_name = $orig_msi_name -replace '^(OpenVPN-.*?)-(${{ matrix.arch }}\.msi)', "`$1+${dt}-${commit}-`$2"
122-
mv .\windows-msi\image\$orig_msi_name .\windows-msi\image\$msi_name
125+
mv .\windows-msi\build\image\$orig_msi_name .\windows-msi\build\image\$msi_name
123126
124127
- name: Archive MSI
125128
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
126129
with:
127-
path: ${{ github.workspace }}\windows-msi\image\*-${{ matrix.arch }}.msi
130+
path: ${{ github.workspace }}\windows-msi\build\image\*-${{ matrix.arch }}.msi
128131
archive: false
129132

130133
- name: Save vcpkg cache

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ tmp
1010
*.cer
1111
*.crt
1212
release/vars.infrastructure
13-
windows-msi/build-and-package-env.ps1
13+
windows-msi/build-env.bat

release/version-and-tags.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ popd
8888

8989
pushd "$MSI"
9090
# Update user-visible version
91-
sed -E -i s/"define\(\[PACKAGE_VERSION\], \[(.+)\]\)"/"define\(\[PACKAGE_VERSION\], \[$BUILD_VERSION\]\)"/1 version.m4
92-
# if version.m4 was already updated, assume everything is fine as is
91+
sed -E -i s/'set\(PACKAGE_VERSION "(.+)"\)'/"set(PACKAGE_VERSION \"$BUILD_VERSION\")"/1 version.cmake
92+
# if version.cmake was already updated, assume everything is fine as is
9393
if ! git diff --exit-code; then
94-
PRODUCT_VERSION_NEW="$PRODUCT_VERSION" ./bump-version.m4.sh
95-
git add ./version.m4
94+
PRODUCT_VERSION_NEW="$PRODUCT_VERSION" ./bump-version.sh
95+
git add ./version.cmake
9696
fi
9797

9898
popd

release/windows-installer-build.sh

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,26 @@ pushd "$TOP_DIR"
2121
. "$SCRIPT_DIR/vars"
2222
. "$SCRIPT_DIR/vars.infrastructure"
2323

24-
cat >build-and-package-env.ps1 <<EOF
25-
\$Env:JsignJar="$WINDOWS_MSI_WORKDIR/../jsign.jar"
26-
\$Env:SigningStoreType="GOOGLECLOUD"
27-
\$Env:SigningKeyStore="$GOOGLE_CLOUD_KMS_KEYRING"
28-
\$Env:SigningStoreKeyName="$GOOGLE_CLOUD_KMS_KEY"
29-
\$Env:SigningCertificateFile="$WINDOWS_MSI_WORKDIR/../signingCert.pem"
24+
cat >windows-msi/build-env.bat <<EOF
25+
@echo off
26+
set JsignJar=$WINDOWS_MSI_WORKDIR/../jsign.jar
27+
set SigningStoreType=GOOGLECLOUD
28+
set SigningKeyStore=$GOOGLE_CLOUD_KMS_KEYRING
29+
set SigningStoreKeyName=$GOOGLE_CLOUD_KMS_KEY
30+
set SigningCertificateFile=$WINDOWS_MSI_WORKDIR/../signingCert.pem
31+
set ManifestTimestampRFC3161Url=http://timestamp.digicert.com
3032
EOF
3133
if [ -n "${VCPKG_CACHE:-}" ]; then
32-
echo "\$Env:VCPKG_BINARY_SOURCES=\"$VCPKG_CACHE\"" >>build-and-package-env.ps1
34+
echo "set VCPKG_BINARY_SOURCES=$VCPKG_CACHE" >>windows-msi/build-env.bat
3335
fi
3436

3537
ssh $WINDOWS_MSI_BUILDHOST "gcloud auth login --quiet --cred-file=$WINDOWS_MSI_WORKDIR\..\clientLibraryConfig.json"
3638
set +x
3739
ACCESS_TOKEN=$(ssh $WINDOWS_MSI_BUILDHOST "cd $WINDOWS_MSI_WORKDIR/windows-msi && gcloud auth print-access-token")
38-
echo "\$Env:SigningStorePass=\"$ACCESS_TOKEN\"" >>build-and-package-env.ps1
40+
echo "set SigningStorePass=$ACCESS_TOKEN" >>windows-msi/build-env.bat
3941
set -x
4042

41-
scp build-and-package-env.ps1 "$WINDOWS_MSI_BUILDHOST":"$WINDOWS_MSI_WORKDIR/windows-msi/"
43+
scp windows-msi/build-env.bat "$WINDOWS_MSI_BUILDHOST":"$WINDOWS_MSI_WORKDIR/windows-msi/"
4244

4345
ssh $WINDOWS_MSI_BUILDHOST git -C "$WINDOWS_MSI_WORKDIR" submodule update --init
4446
ssh $WINDOWS_MSI_BUILDHOST git -C "$WINDOWS_MSI_WORKDIR/src/openvpn" remote remove internal || true
@@ -47,10 +49,10 @@ ssh $WINDOWS_MSI_BUILDHOST git -C "$WINDOWS_MSI_WORKDIR" remote remove internal
4749
ssh $WINDOWS_MSI_BUILDHOST git -C "$WINDOWS_MSI_WORKDIR" tag -d "OpenVPN-$BUILD_VERSION" || true
4850
ssh $WINDOWS_MSI_BUILDHOST git -C "$WINDOWS_MSI_WORKDIR" remote add -f --tags internal "$INTERNAL_GIT_REPO_BUILD_RO"
4951
ssh $WINDOWS_MSI_BUILDHOST git -C "$WINDOWS_MSI_WORKDIR" checkout --recurse-submodules -f "OpenVPN-$BUILD_VERSION"
50-
ssh $WINDOWS_MSI_BUILDHOST "cd $WINDOWS_MSI_WORKDIR/windows-msi && \"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvarsall.bat\" x64 && powershell ./build-and-package.ps1 -sign"
52+
ssh $WINDOWS_MSI_BUILDHOST "cd $WINDOWS_MSI_WORKDIR/windows-msi && \"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvarsall.bat\" x64 && build-env.bat && cmake -B build -DSIGN_BINARIES=ON && cmake --build build"
5153

5254
mkdir -p "$OUTPUT/upload/"
53-
scp "$WINDOWS_MSI_BUILDHOST":"$WINDOWS_MSI_WORKDIR/windows-msi/image/OpenVPN-${BUILD_VERSION}"-*.msi "$OUTPUT/upload/"
55+
scp "$WINDOWS_MSI_BUILDHOST":"$WINDOWS_MSI_WORKDIR/windows-msi/build/image/OpenVPN-${BUILD_VERSION}"-*.msi "$OUTPUT/upload/"
5456
read -p "Upload MSIs to $SECONDARY_WEBSERVER?"
5557
# upload MSIs
5658
$SCRIPT_DIR/sign-and-push.sh

renovate.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@
5656
{
5757
"customType": "regex",
5858
"managerFilePatterns": [
59-
"/windows-msi/version.m4$/"
59+
"/windows-msi/version\\.cmake$/"
6060
],
6161
"matchStrings": [
62-
"datasource=(?<datasource>.*?) depName=(?<depName>.*?)( versioning=(?<versioning>.*?))?\\sdefine\\(\\[.*?\\],\\s*\\[(?<currentValue>.*?)\\]\\)\\s"
62+
"datasource=(?<datasource>.*?) depName=(?<depName>.*?)( versioning=(?<versioning>.*?))?\\nset\\(\\w+\\s+\"(?<currentValue>.*?)\"\\)"
6363
]
6464
}
6565
]

0 commit comments

Comments
 (0)