|
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'
|
|
15 | 20 | https://github.com/git-for-windows/git-sdk-64 .tmp &&
|
16 | 21 | rev="$(git -C .tmp rev-parse HEAD)" &&
|
17 | 22 | 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 |
19 | 24 | - name: restore cached git-sdk-64 subset
|
20 | 25 | id: restore-g4w-sdk
|
21 | 26 | uses: actions/cache/restore@v4
|
@@ -50,10 +55,43 @@ runs:
|
50 | 55 | /usr/share/makepkg/
|
51 | 56 | /mingw64/bin/curl.exe
|
52 | 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 && |
53 | 86 | git checkout -- &&
|
54 | 87 |
|
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 | + } |
57 | 95 | - name: cache git-sdk-64 subset
|
58 | 96 | if: ${{ steps.restore-g4w-sdk.outputs.cache-hit != 'true' }}
|
59 | 97 | uses: actions/cache/save@v4
|
|
0 commit comments