Skip to content

Commit 4f6d39b

Browse files
authored
action to grab old sync dbs from installers (#3)
Also an action to mirror the packages from such a sync db (msys2 db still TODO)
1 parent ff83da6 commit 4f6d39b

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: extract-from-installers
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
startdate:
6+
type: text
7+
required: false
8+
default: ''
9+
jobs:
10+
extract:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
steps:
15+
- name: Process
16+
env:
17+
GITHUB_TOKEN: ${{ github.token }}
18+
INPUT_STARTDATE: ${{ inputs.startdate }}
19+
run: |
20+
for tag in $(gh release list -R msys2/msys2-installer --exclude-drafts --exclude-pre-releases --json publishedAt,tagName --jq '.[]|select(.publishedAt>"'"${INPUT_STARTDATE}"'")|.tagName|select(startswith("nightly")|not)'); do
21+
url="$(gh release view -R msys2/msys2-installer "$tag" --json assets --jq '.assets[]|select((.contentType == "application/x-xz") or (.url|endswith(".tar.xz"))).url')"
22+
mkdir tmp; pushd tmp
23+
curl -Lo msys2.xz "$url"
24+
tar -Jxf msys2.xz msys64/var/lib/pacman/sync
25+
gh release create "$tag" --title "$tag" --notes "" -R ${{ github.repository }} msys64/var/lib/pacman/sync/*
26+
popd
27+
rm -rf tmp
28+
done
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: mirror-snapshot
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
snapshotrelease:
6+
type: text
7+
required: true
8+
reponame:
9+
type: text
10+
required: true
11+
newrelease:
12+
type: text
13+
required: true
14+
jobs:
15+
mirror:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: write
19+
steps:
20+
- name: Clone pacdb
21+
uses: actions/checkout@v4
22+
with:
23+
repository: msys2/pacdb
24+
persist-credentials: false
25+
path: pacdb
26+
- name: Process
27+
env:
28+
GITHUB_TOKEN: ${{ github.token }}
29+
SNAPSHOTRELEASE: ${{ inputs.snapshotrelease }}
30+
REPONAME: ${{ inputs.reponame }}
31+
NEWRELEASE: ${{ inputs.newrelease }}
32+
run: |
33+
python -m venv --system-site-packages .venv
34+
. .venv/bin/activate
35+
pip install pacdb
36+
shopt -s nullglob
37+
mkdir "${NEWRELEASE}" && pushd "${NEWRELEASE}"
38+
for sig in "" ".sig"; do
39+
curl -LO "https://github.com/${{ github.repository }}/releases/download/${SNAPSHOTRELEASE}/${REPONAME}.db${sig}"
40+
done
41+
popd
42+
python pacdb/examples/pacmirror_rsync.py -e "${REPONAME}" -n -v "rsync://repo.msys2.org/builds/mingw/${REPONAME}" "${NEWRELEASE}"
43+
# work around github issue with ~ in file name (turns into .)
44+
for a in "${NEWRELEASE}/"*~*; do
45+
mv "$a" "${a//\~/.}"
46+
done
47+
gh release view -R "${{ github.repository }}" "${NEWRELEASE}" --json assets -q '"'"${NEWRELEASE}"'/" + .assets.[].name' > existing.txt ||
48+
gh release create -d "${NEWRELEASE}" --title "${NEWRELEASE}" --notes "" -R "${{ github.repository }}"
49+
find "${NEWRELEASE}" -type f -print | grep -Fxvf existing.txt | xargs -d '\n' -n 200 bash -c '
50+
IFS=" " read -r remaining limit reset < <(gh api rate_limit --jq '\''"\(.rate.remaining) \(.rate.limit) \(.rate.reset)"'\'');
51+
if (( remaining < 300 )); then
52+
echo "sleeping $(( reset - $(date +%s) ))";
53+
sleep $(( reset - $(date +%s) ));
54+
fi;
55+
gh release upload -R "${{ github.repository }}" "${NEWRELEASE}" "$@" && sleep 100' bash
56+
gh release edit -R "${{ github.repository }}" "${NEWRELEASE}" --latest=false --prerelease=true --draft=false

0 commit comments

Comments
 (0)