Skip to content

Commit fd03c02

Browse files
fix: make install.dependencies on Windows (#340)
Issue #, if available: Found during integration of 91c52d7 into finch. ``` deps/install.sh: line 75: shasum: command not found + grep -xq '^93ff4407f289f695424d3a4fe47158f712201d2b5ffcb0033a15d64e2082ddf8ef6e2f1612fa07ebb2bc9d57b38d0a5f3164fee1418d354847716e3594bd998d$' + echo 'error: shasum verification failed for dependency' + rm -f D:/a/finch-core/finch-core/_output/os/finch-rootfs-production-amd64-1715724303.tar.gz error: shasum verification failed for dependency + exit 1 make: *** [Makefile.windows:27: D:/a/finch-core/finch-core/_output/os/finch-rootfs-production-amd64-171[57](https://github.com/austinvazquez/finch-core/actions/runs/9666641032/job/26666620967#step:4:58)24303.tar.gz] Error 1 ``` *Description of changes:* This change fixes make install.dependencies on Windows. The Windows platform relies on sha512sum tool instead of shasum tool which is available on macOS. This change also adds a spot check for make install.dependencies on macOS 13 and Windows to CI. *Testing done:* `make install.dependencies` && `make clean` is successful on macOS 13 and Windows 2022 - [x] I've reviewed the guidance in CONTRIBUTING.md #### License Acceptance By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. Signed-off-by: Austin Vazquez <[email protected]>
1 parent 91c52d7 commit fd03c02

File tree

4 files changed

+53
-5
lines changed

4 files changed

+53
-5
lines changed

.github/workflows/ci.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,33 @@ concurrency:
2020
cancel-in-progress: true
2121

2222
jobs:
23+
install-dependencies:
24+
# This is a spot check for make install.dependencies on macOS and Windows platforms.
25+
# Finch-core provides the core dependencies needed to run Finch such as the base OS
26+
# image, rootfs, and Lima bundle. Validate the mechanism used to install the core
27+
# dependencies works on the respective platforms.
28+
strategy:
29+
fail-fast: false
30+
matrix:
31+
os: [macos-13, windows-2022]
32+
runs-on: ${{ matrix.os }}
33+
steps:
34+
- name: Checkout code
35+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
36+
with:
37+
fetch-depth: 0
38+
persist-credentials: false
39+
submodules: true
40+
- name: Setup go
41+
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
42+
with:
43+
go-version-file: e2e/go.mod
44+
cache-dependency-path: e2e/go.sum
45+
- name: Install platform dependencies
46+
run: make install.dependencies
47+
- name: Clean up dependencies
48+
run: make clean
49+
2350
e2e-tests:
2451
strategy:
2552
fail-fast: false

Makefile.windows

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ endif
1616
WINGIT_TEMP_DIR := $(CURDIR)/wingit-temp
1717
WINGIT_x86_URL := $(or $(WINGIT_x86_URL),https://github.com/git-for-windows/git/releases/download/v2.42.0.windows.2/Git-2.42.0.2-64-bit.tar.bz2)
1818
WINGIT_x86_BASENAME ?= $(notdir $(WINGIT_x86_URL))
19-
WINGIT_x86_HASH := $(or $(WINGIT_x86_HASH),"sha256:c192e56f8ed3d364acc87ad04d1f5aa6ae03c23b32b67bf65fcc6f9b8f032e65")
19+
WINGIT_x86_HASH := $(or $(WINGIT_x86_HASH),"sha512:795a2e7e0be5ab78f2d28d0bd971961d121b9c808a95dec795343dc5af943574dcf54f63a8580c5a5102075abdae387d7a67135c165821428afc07f11ef7543d")
2020

2121
install.dependencies: install.rootfs install.lima
2222

bin/verify_hash.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ param (
1111
[string]$DependencyHash = 'out.png'
1212
)
1313

14-
if (!(Get-FileHash -Algorithm SHA256 "$DependencyFilePath").Hash -eq $DependencyHash) {
14+
if (!(Get-FileHash -Algorithm SHA512 "$DependencyFilePath").Hash -eq $DependencyHash) {
1515
$host.SetShouldExit(-1); exit
1616
} else {
1717
Write-Output "Verified $DependencyFilePath"

deps/install.sh

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010
set -euxo pipefail
1111

12+
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13+
PROJECT_ROOT="$(cd -- "${CURRENT_DIR}/.." && pwd)"
14+
1215
file=""
1316
sources=""
1417

@@ -68,9 +71,27 @@ case "${arch}" in
6871
;;
6972
esac
7073

74+
windows=false
75+
os="$(uname -s)"
76+
case "${os}" in
77+
"Darwin")
78+
;;
79+
CYGWIN*|MINGW32*|MINGW*|MYSYS*)
80+
windows=true
81+
;;
82+
*)
83+
echo "error: unsupported operating system" && exit 1
84+
;;
85+
esac
86+
7187
# pull artifact from dependency repository
7288
curl -L --fail "${url}/${artifact}" > "${file}"
7389

74-
# validate shasum for downloaded artifact
75-
(shasum --algorithm 512 "${file}" | cut -d ' ' -f 1 | grep -xq "^${digest}$") || \
76-
(echo "error: shasum verification failed for dependency" && rm -f "${file}" && exit 1)
90+
# validate artifact digest
91+
if [[ $windows = true ]]; then
92+
(pwsh "${PROJECT_ROOT}/bin/verify_hash.ps1" "${file}" "${digest}") || \
93+
(echo "error: shasum verification failed for dependency" && rm -f "${file}" && exit 1)
94+
else
95+
(shasum --algorithm 512 "${file}" | cut -d ' ' -f 1 | grep -xq "^${digest}$") || \
96+
(echo "error: shasum verification failed for dependency" && rm -f "${file}" && exit 1)
97+
fi

0 commit comments

Comments
 (0)