1
1
name : ' Initialize Git for Windows SDK subset to run `pacman`'
2
2
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'
3
8
outputs :
4
9
result :
5
10
description : ' The path to the subset of the SDK'
@@ -13,15 +18,17 @@ runs:
13
18
run : |
14
19
git clone --bare --depth=1 --single-branch --branch=main --filter=blob:none \
15
20
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
17
24
- name : restore cached git-sdk-64 subset
18
25
id : restore-g4w-sdk
19
26
uses : actions/cache/restore@v4
20
27
env :
21
28
cache-name : cache-g4w-sdk
22
29
with :
23
30
path : .sdk
24
- key : g4w-sdk- ${{ steps.clone-g4w-sdk.outputs.rev }}
31
+ key : ${{ steps.clone-g4w-sdk.outputs.cache-key }}
25
32
- name : check out git-sdk-64 subset
26
33
if : ${{ steps.restore-g4w-sdk.outputs.cache-hit != 'true' }}
27
34
shell : bash
@@ -48,18 +55,51 @@ runs:
48
55
/usr/share/makepkg/
49
56
/mingw64/bin/curl.exe
50
57
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 &&
51
86
git checkout -- &&
52
87
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
+ }
55
95
- name : cache git-sdk-64 subset
56
96
if : ${{ steps.restore-g4w-sdk.outputs.cache-hit != 'true' }}
57
97
uses : actions/cache/save@v4
58
98
env :
59
99
cache-name : cache-g4w-sdk
60
100
with :
61
101
path : .sdk
62
- key : g4w-sdk- ${{ steps.clone-g4w-sdk.outputs.rev }}
102
+ key : ${{ steps.clone-g4w-sdk.outputs.cache-key }}
63
103
- name : use git-sdk-64 subset
64
104
id : use-sdk
65
105
shell : bash
0 commit comments