Skip to content

Fix the updpkgsums GitHub workflow #83

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 45 additions & 5 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 @@ -13,15 +18,17 @@ runs:
run: |
git clone --bare --depth=1 --single-branch --branch=main --filter=blob:none \
https://github.com/git-for-windows/git-sdk-64 .tmp &&
echo "rev=$(git -C .tmp rev-parse HEAD)" >>$GITHUB_OUTPUT
rev="$(git -C .tmp rev-parse HEAD)" &&
echo "rev=$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
env:
cache-name: cache-g4w-sdk
with:
path: .sdk
key: g4w-sdk-${{ steps.clone-g4w-sdk.outputs.rev }}
key: ${{ steps.clone-g4w-sdk.outputs.cache-key }}
- name: check out git-sdk-64 subset
if: ${{ steps.restore-g4w-sdk.outputs.cache-hit != 'true' }}
shell: bash
Expand All @@ -48,18 +55,51 @@ 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
env:
cache-name: cache-g4w-sdk
with:
path: .sdk
key: g4w-sdk-${{ steps.clone-g4w-sdk.outputs.rev }}
key: ${{ steps.clone-g4w-sdk.outputs.cache-key }}
- name: use git-sdk-64 subset
id: use-sdk
shell: bash
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
Loading