Skip to content

Instantly share code, notes, and snippets.

@acxz
Last active September 10, 2023 04:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acxz/bc40b850be614e9d09e6066ba4f1b430 to your computer and use it in GitHub Desktop.
Save acxz/bc40b850be614e9d09e6066ba4f1b430 to your computer and use it in GitHub Desktop.
Script to update PKGBUILD files in the rocm-arch/rocm-arch repo
#!/bin/bash
# Clone the rocm-arch repository if it hasn't been cloned yet
if [ ! -d rocm-arch ]; then
git clone git@github.com:rocm-arch/rocm-arch
fi
# Move to the rocm-arch directory
cd rocm-arch
# Fetch the latest changes from the remote repository
git fetch
# Commit the updated files to a new branch
git checkout updpkg || git checkout -b updpkg
# Stash current working changes first
git stash
# Loop through each package (i.e. each subfolder)
for package_dir in */
do
# Get the package name from the directory name
package=$(basename "$package_dir")
echo "Updating $package"
# Set the latest version of the package
latest_version=5.6.1
cd "$package_dir"
# Check if the package has a PKGBUILD file
if [ ! -f PKGBUILD ]; then
echo "No PKGBUILD found for $package"
cd ..
continue
fi
# Check if the package is already the latest version
current_version=$(grep -m1 pkgver= PKGBUILD | cut -d= -f2)
if [ "$current_version" = "$latest_version" ]; then
echo "$package is already the latest version"
cd ..
continue
fi
# Update the package version in the PKGBUILD file
sed -i "s/pkgver=.*/pkgver=$latest_version/" PKGBUILD
sed -i "s/pkgrel=.*/pkgrel=1/" PKGBUILD
# Download sources
makepkg -od --noprepare
# Update the checksums
updpkgsums
# Build the package using makepkg
if makepkg -r -f PKGBUILD; then
# Update the .SRCINFO file
makepkg --printsrcinfo > .SRCINFO
git add PKGBUILD .SRCINFO
pkgrel=$(grep pkgrel= PKGBUILD | cut -d= -f2)
commit_message="updpkg: $package-$latest_version-$pkgrel"
git commit -m "$commit_message"
else
echo "Error building package $package. Skipping commit."
fi
cd ..
done
# Push the new branch to the remote repository
git push origin updpkg
# Stash changes that did not build
git stash
# Clean build artifacts
git clean -ffd
git clean -fd
# Switch back to the master branch
git checkout master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment