Skip to content

Commit

Permalink
Add mirroring for Alpine 3.14
Browse files Browse the repository at this point in the history
It shouldn't be actually used, just mirrored.
  • Loading branch information
tbodt committed Jun 25, 2021
1 parent 2fd76a1 commit ab48933
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/update-alpine-repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ jobs:
RCLONE_CONFIG: ${{ secrets.RCLONE_CONFIG }}
- name: Update
run: |
deps/aports/sync-archive.sh v3.12 main/x86
deps/aports/sync-archive.sh v3.12 community/x86
deps/aports/sync-archive.sh v3.14 main/x86
deps/aports/sync-archive.sh v3.14 community/x86
deps/aports/sync-archive.sh v3.12 main/x86 deps/aports/main/x86/index.txt
deps/aports/sync-archive.sh v3.12 community/x86 deps/aports/community/x86/index.txt
- name: Commit
id: commit
run: |
Expand Down
23 changes: 14 additions & 9 deletions deps/aports/sync-archive.sh
Original file line number Diff line number Diff line change
@@ -1,38 +1,43 @@
#!/bin/bash -ex
# This script only works on my machine
cd "$(dirname $0)"
archive_remote="wasabici:alpine-archive"

function sync_repo() {
version="$1"
path="$2"
index_name_file="$3"
rclone copy -v --transfers=32 "alpine:$version/$path" "$archive_remote/$path"
date=$(date +%F)
new_index_name="APKINDEX-$version-$date.tar.gz"
rclone moveto "$archive_remote/$path/APKINDEX.tar.gz" "$archive_remote/$path/$new_index_name"
echo "$new_index_name" > "$path/index.txt"
echo "$new_index_name" > "$index_name_file"
}

function update_repo() {
version="$1"
path="$2"
old_index_name="$(cat "$path/index.txt")"
sync_repo "$version" "$path"
new_index_name="$(cat "$path/index.txt")"
index_name_file="$path/$3"
old_index_name="$(cat "$index_name_file")"
sync_repo "$version" "$path" "$index_name_file"
new_index_name="$(cat "$index_name_file")"
rclone cat "$archive_remote/$path/$new_index_name" | tar -xzOf - -O APKINDEX | format_index > /tmp/APKINDEX.new
rclone cat "$archive_remote/$path/$old_index_name" | tar -xzOf - -O APKINDEX | format_index > /tmp/APKINDEX.old
if diff -u /tmp/APKINDEX.new /tmp/APKINDEX.old; then
echo "nothing new"
echo "$old_index_name" > "$path/index.txt"
echo "$old_index_name" > "$index_name_file"
fi
}

function format_index() {
awk '/^P:/ {name=substr($0,3)} /^V:/ {version=substr($0,3)} /^$/ {print name, version}' | sort
}

if [[ "$#" != 2 ]]; then
echo "usage: $0 version path" >&2
if [[ "$#" -lt 2 || "$#" -gt 3 ]]; then
echo "usage: $0 version path [index.txt]" >&2
exit 1
fi
update_repo "$@"
if [[ -n "$3" ]]; then
update_repo "$1" "$2" "$3"
else
sync_repo "$1" "$2" /dev/null
fi

0 comments on commit ab48933

Please sign in to comment.