Skip to content

Commit c63e713

Browse files
committed
updpkgsums: include all required files in the sparse checkout
When the `updpkgsums` workflow runs, it initializes a subset of Git for Windows SDK's repository via a sparse checkout. This subset is defined in the custom `init-g4w-sdk-for-pacman` Action, and it works well for `pacman`/`updpkgsums` invocations. For `makepkg`, however, we need to include the Pacman configuration, and `gpg.exe`,otherwise the workflow will fail with an error message like this: ==> Checking runtime dependencies... error: config file /etc/pacman.conf could not be read: No such file or directory This happened in this failed workflow run: https://github.com/git-for-windows/git-for-windows-automation/actions/runs/9415088089/job/25935346092#step:9:87 Fix this by including the Pacman configuration and `gpg.exe in the sparse checkout. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent c737905 commit c63e713

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

.github/actions/init-g4w-sdk-for-pacman/action.yml

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
name: 'Initialize Git for Windows SDK subset to run `pacman`'
22
description: 'This composite GitHub Action initializes a subset of the Git for Windows SDK intended to run `pacman` and friends'
3+
inputs:
4+
include-makepkg:
5+
description: 'Whether to include a working `makepkg`'
6+
required: false
7+
default: 'false'
38
outputs:
49
result:
510
description: 'The path to the subset of the SDK'
@@ -15,7 +20,7 @@ runs:
1520
https://github.com/git-for-windows/git-sdk-64 .tmp &&
1621
rev="$(git -C .tmp rev-parse HEAD)" &&
1722
echo "rev=$rev" >>$GITHUB_OUTPUT &&
18-
echo "cache-key=g4w-sdk-$rev" >>$GITHUB_OUTPUT
23+
echo "cache-key=g4w-sdk-$rev${{ inputs.include-makepkg != 'false' && '+makepkg' || '' }}" >>$GITHUB_OUTPUT
1924
- name: restore cached git-sdk-64 subset
2025
id: restore-g4w-sdk
2126
uses: actions/cache/restore@v4
@@ -50,10 +55,43 @@ runs:
5055
/usr/share/makepkg/
5156
/mingw64/bin/curl.exe
5257
EOF
58+
if test false != '${{ inputs.include-makepkg }}'
59+
then
60+
printf "%s\n" >>"$sparse" \
61+
/etc/pacman.conf \
62+
/etc/pacman.d/ \
63+
/var/lib/pacman/ \
64+
/usr/bin/gpg.exe &&
65+
# cheap `objdump -p | grep DLL.Name:` alternative
66+
LC_CTYPE=C sed -n '
67+
# surround MSYS DLL names with `<` and `>` and avoid false positives
68+
s|[<>]||g
69+
s|\(msys-[-a-z0-9.]*\.dll\)|<\1>|g
70+
71+
# remove everything except the MSYS DLL names
72+
s|^[^<]*<*||
73+
s|>*[^>]*$||
74+
s|>[^<>]*<|\n|g
75+
76+
# skip empty lines
77+
/^$/d
78+
79+
# prefix the MSYS DLL names with `/usr/bin/`
80+
s|^|/usr/bin/|
81+
s|\n|&/usr/bin/|g
82+
83+
# print the result
84+
p' /usr/bin/gpg.exe >>"$sparse"
85+
fi &&
5386
git checkout -- &&
5487
55-
# makepkg/updpkgsums expects `curl` to be present in `/usr/bin/`
56-
printf '#!/bin/sh\n\nexec /mingw64/bin/curl.exe "$@"' >usr/bin/curl
88+
# makepkg/updpkgsums expect `curl` to be present in `/usr/bin/`
89+
printf '#!/bin/sh\n\nexec /mingw64/bin/curl.exe "$@"' >usr/bin/curl &&
90+
{
91+
# makepkg expects `git` to be present in `/usr/bin/`
92+
test ! -x mingw64/bin/git.exe ||
93+
printf '#!/bin/sh\n\nexec /mingw64/bin/git.exe "$@"' >usr/bin/git
94+
}
5795
- name: cache git-sdk-64 subset
5896
if: ${{ steps.restore-g4w-sdk.outputs.cache-hit != 'true' }}
5997
uses: actions/cache/save@v4

.github/workflows/updpkgsums.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ jobs:
6363
core.setOutput('token', accessToken)
6464
- name: Initialize Git for Windows SDK subset
6565
uses: ./.github/actions/init-g4w-sdk-for-pacman
66+
with:
67+
include-makepkg: true
6668
- name: Clone ${{ env.REPO }}
6769
id: clone
6870
shell: bash

0 commit comments

Comments
 (0)