Skip to content

Commit 875f878

Browse files
committed
Bundle libcurl for Windows
Changes for the user: - The Windows release now ships with `libcurl-4.dll` (from https://curl.se/windows/). Other comments: - The download script was adjusted to use `curl` when it's available instead of `wget`. The latter was problematic on Windows; I couldn't get it to work with a specific output file (with `-O`). - I applied shellcheck recommendations to the download script.
1 parent 4152821 commit 875f878

File tree

4 files changed

+34
-6
lines changed

4 files changed

+34
-6
lines changed

.github/workflows/main.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,18 @@ jobs:
4646
run: |
4747
New-Item -ItemType Directory -ErrorAction SilentlyContinue build/cs-api-${{ steps.build_version.outputs.value }}-windows
4848
Copy-Item _build/install/default/bin/cs-api.exe build/cs-api-${{ steps.build_version.outputs.value }}-windows/
49+
- name: Download and bundle libcurl
50+
shell: bash
51+
env:
52+
SHELLOPTS: igncr
53+
run: |
54+
bash ci/static-dl \
55+
--url https://curl.se/windows/dl-8.9.1_1/curl-8.9.1_1-win64-mingw.zip \
56+
--hash f7bc9e21490d942c937dfe7bfcb9a2e29a490665c8b51e8ea0cdc171ac08c5de \
57+
--out /tmp/curl.zip
58+
mkdir /tmp/curl
59+
unzip -q /tmp/curl.zip -d /tmp/curl
60+
cp /tmp/curl/*/bin/libcurl-x64.dll build/cs-api-${{ steps.build_version.outputs.value }}-windows/libcurl-4.dll
4961
- name: Upload the compiled binary
5062
uses: actions/upload-artifact@v4
5163
with:

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## Unreleased
99

10-
_There are no unreleased changes at the moment._
10+
### Added
11+
12+
- The Windows release now ships with `libcurl-4.dll` (from https://curl.se/windows/).
1113

1214
## [2.7.0] - 2024-08-02
1315

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ RUN apt-get update \
2828
USER "$user"
2929

3030
# Add script for downloading files
31-
COPY --chown="$user:$user" docker/static-dl /usr/local/bin/static-dl
31+
COPY --chown="$user:$user" ci/static-dl /usr/local/bin/static-dl
3232
RUN chmod +x /usr/local/bin/static-dl
3333

3434
RUN mkdir "/home/$user/workdir"

docker/static-dl renamed to ci/static-dl

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ set -o errexit
33
set -o nounset
44
set -o pipefail
55

6-
# Download a file with `wget` and check its SHA-256 hash.
6+
# Download a file with `curl` or `wget` and check its SHA-256 hash.
77
#
88
# To download with a hash check:
99
#
@@ -24,20 +24,34 @@ show_hash_and_fail() {
2424
local url=$1; shift
2525
local file=$1; shift
2626

27-
local hash=$(sha256sum "$file" | cut -f 1 -d " ")
27+
local hash
28+
hash=$(sha256sum "$file" | cut -f 1 -d " ")
2829
echo "Actual hash for $url: $hash" >&2
2930
return 1
3031
}
3132

33+
download() {
34+
local url=$1; shift
35+
local out=$1; shift
36+
37+
# If curl is found, use it, otherwise use wget.
38+
if command -v curl > /dev/null; then
39+
curl --location --output "$out" "$url"
40+
else
41+
wget --output-document "$out" "$url"
42+
fi
43+
}
44+
3245
main() {
3346
local url=$1; shift
3447
local hash_=$1; shift
3548
local out=$1; shift
3649

37-
local tmp_dir=$(mktemp --directory)
50+
local tmp_dir
51+
tmp_dir=$(mktemp --directory)
3852
local tmp_file="$tmp_dir/downloaded"
3953

40-
wget -nv -O "$tmp_file" "$url"
54+
download "$url" "$tmp_file"
4155
echo "$hash_ $tmp_file" | sha256sum --check --strict \
4256
|| show_hash_and_fail "$url" "$tmp_file"
4357

0 commit comments

Comments
 (0)