name: Update Arch Repository on: push: paths: - 'x86_64/*.pkg.tar.zst' workflow_dispatch: jobs: update-db: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 - name: Setup tools run: sudo apt-get update && sudo apt-get install -y libarchive-tools - name: Update Repository Database run: | cd x86_64 # Remove old DB files rm -f hyprarch-repo.db hyprarch-repo.db.tar.gz hyprarch-repo.files hyprarch-repo.files.tar.gz # Create a temporary directory for metadata mkdir -p db_temp # Extract metadata from each package and put it into the DB structure for pkg in *.pkg.tar.zst; do pkgname=$(bsdtar -xOf "$pkg" .PKGINFO | grep "^pkgname =" | cut -d' ' -f3) pkgver=$(bsdtar -xOf "$pkg" .PKGINFO | grep "^pkgver =" | cut -d' ' -f3) mkdir -p "db_temp/$pkgname-$pkgver" bsdtar -xOf "$pkg" .PKGINFO > "db_temp/$pkgname-$pkgver/desc" # Add file size and build date to desc echo -e "\n%FILENAME%\n$pkg" >> "db_temp/$pkgname-$pkgver/desc" echo -e "\n%CSIZE%\n$(stat -c%s "$pkg")" >> "db_temp/$pkgname-$pkgver/desc" done # Compress the metadata into a real Arch DB cd db_temp tar -c * | gzip -9 > ../hyprarch-repo.db.tar.gz cd .. rm -rf db_temp # Create the required symlinks/copies for GitHub Pages cp hyprarch-repo.db.tar.gz hyprarch-repo.db cp hyprarch-repo.db.tar.gz hyprarch-repo.files cp hyprarch-repo.db.tar.gz hyprarch-repo.files.tar.gz - name: Generate Subfolder Index run: | cd x86_64 echo "
" >> index.html
echo "../" >> index.html
for file in *; do
if [ "$file" != "index.html" ]; then
size=$(du -sh "$file" | cut -f1)
date=$(date -r "$file" '+%d-%b-%Y %H:%M')
printf "%s%-$(($(printf '%s' "$file" | wc -c) > 50 ? 1 : 50 - $(printf '%s' "$file" | wc -c)))s %s %8s\n" "$file" "$file" "" "$date" "$size" >> index.html
fi
done
echo "To use this repository, add the following to your /etc/pacman.conf:
[hyprarch-repo]
SigLevel = Optional TrustAll
Server = https://hyprarch-repo.stuple.net/$arch
Automated by GitHub Actions