Skip to content

Commit 292b89b

Browse files
authored
Merge pull request #83 from git-for-windows/fix-updpkgsums
Fix the `updpkgsums` GitHub workflow
2 parents 7d0f7ea + c63e713 commit 292b89b

File tree

2 files changed

+47
-5
lines changed

2 files changed

+47
-5
lines changed

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

Lines changed: 45 additions & 5 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'
@@ -13,15 +18,17 @@ runs:
1318
run: |
1419
git clone --bare --depth=1 --single-branch --branch=main --filter=blob:none \
1520
https://github.com/git-for-windows/git-sdk-64 .tmp &&
16-
echo "rev=$(git -C .tmp rev-parse HEAD)" >>$GITHUB_OUTPUT
21+
rev="$(git -C .tmp rev-parse HEAD)" &&
22+
echo "rev=$rev" >>$GITHUB_OUTPUT &&
23+
echo "cache-key=g4w-sdk-$rev${{ inputs.include-makepkg != 'false' && '+makepkg' || '' }}" >>$GITHUB_OUTPUT
1724
- name: restore cached git-sdk-64 subset
1825
id: restore-g4w-sdk
1926
uses: actions/cache/restore@v4
2027
env:
2128
cache-name: cache-g4w-sdk
2229
with:
2330
path: .sdk
24-
key: g4w-sdk-${{ steps.clone-g4w-sdk.outputs.rev }}
31+
key: ${{ steps.clone-g4w-sdk.outputs.cache-key }}
2532
- name: check out git-sdk-64 subset
2633
if: ${{ steps.restore-g4w-sdk.outputs.cache-hit != 'true' }}
2734
shell: bash
@@ -48,18 +55,51 @@ runs:
4855
/usr/share/makepkg/
4956
/mingw64/bin/curl.exe
5057
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 &&
5186
git checkout -- &&
5287
53-
# makepkg/updpkgsums expects `curl` to be present in `/usr/bin/`
54-
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+
}
5595
- name: cache git-sdk-64 subset
5696
if: ${{ steps.restore-g4w-sdk.outputs.cache-hit != 'true' }}
5797
uses: actions/cache/save@v4
5898
env:
5999
cache-name: cache-g4w-sdk
60100
with:
61101
path: .sdk
62-
key: g4w-sdk-${{ steps.clone-g4w-sdk.outputs.rev }}
102+
key: ${{ steps.clone-g4w-sdk.outputs.cache-key }}
63103
- name: use git-sdk-64 subset
64104
id: use-sdk
65105
shell: bash

.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)