Skip to content

Commit

Permalink
updpkgsums: include all required files in the sparse checkout
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
dscho committed Jun 10, 2024
1 parent c737905 commit c63e713
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
44 changes: 41 additions & 3 deletions .github/actions/init-g4w-sdk-for-pacman/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
name: 'Initialize Git for Windows SDK subset to run `pacman`'
description: 'This composite GitHub Action initializes a subset of the Git for Windows SDK intended to run `pacman` and friends'
inputs:
include-makepkg:
description: 'Whether to include a working `makepkg`'
required: false
default: 'false'
outputs:
result:
description: 'The path to the subset of the SDK'
Expand All @@ -15,7 +20,7 @@ runs:
https://github.com/git-for-windows/git-sdk-64 .tmp &&
rev="$(git -C .tmp rev-parse HEAD)" &&
echo "rev=$rev" >>$GITHUB_OUTPUT &&
echo "cache-key=g4w-sdk-$rev" >>$GITHUB_OUTPUT
echo "cache-key=g4w-sdk-$rev${{ inputs.include-makepkg != 'false' && '+makepkg' || '' }}" >>$GITHUB_OUTPUT
- name: restore cached git-sdk-64 subset
id: restore-g4w-sdk
uses: actions/cache/restore@v4
Expand Down Expand Up @@ -50,10 +55,43 @@ runs:
/usr/share/makepkg/
/mingw64/bin/curl.exe
EOF
if test false != '${{ inputs.include-makepkg }}'
then
printf "%s\n" >>"$sparse" \
/etc/pacman.conf \
/etc/pacman.d/ \
/var/lib/pacman/ \
/usr/bin/gpg.exe &&
# cheap `objdump -p | grep DLL.Name:` alternative
LC_CTYPE=C sed -n '
# surround MSYS DLL names with `<` and `>` and avoid false positives
s|[<>]||g
s|\(msys-[-a-z0-9.]*\.dll\)|<\1>|g
# remove everything except the MSYS DLL names
s|^[^<]*<*||
s|>*[^>]*$||
s|>[^<>]*<|\n|g
# skip empty lines
/^$/d
# prefix the MSYS DLL names with `/usr/bin/`
s|^|/usr/bin/|
s|\n|&/usr/bin/|g
# print the result
p' /usr/bin/gpg.exe >>"$sparse"
fi &&
git checkout -- &&
# makepkg/updpkgsums expects `curl` to be present in `/usr/bin/`
printf '#!/bin/sh\n\nexec /mingw64/bin/curl.exe "$@"' >usr/bin/curl
# makepkg/updpkgsums expect `curl` to be present in `/usr/bin/`
printf '#!/bin/sh\n\nexec /mingw64/bin/curl.exe "$@"' >usr/bin/curl &&
{
# makepkg expects `git` to be present in `/usr/bin/`
test ! -x mingw64/bin/git.exe ||
printf '#!/bin/sh\n\nexec /mingw64/bin/git.exe "$@"' >usr/bin/git
}
- name: cache git-sdk-64 subset
if: ${{ steps.restore-g4w-sdk.outputs.cache-hit != 'true' }}
uses: actions/cache/save@v4
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/updpkgsums.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ jobs:
core.setOutput('token', accessToken)
- name: Initialize Git for Windows SDK subset
uses: ./.github/actions/init-g4w-sdk-for-pacman
with:
include-makepkg: true
- name: Clone ${{ env.REPO }}
id: clone
shell: bash
Expand Down

0 comments on commit c63e713

Please sign in to comment.