Update based on package version from info

This commit is contained in:
Ryan Hughes committed 2025-08-25 17:03:17 +02:00
1 parent 2ad6cd90bb
commit 889f3818fc
1 file changed
+45 -40
+45 -40
View File
@@ -1,67 +1,72 @@
#!/bin/bash #!/bin/bash
# AUR package building functions # AUR package building functions
# Get version from local repo database
get_local_version() {
local pkg="$1"
if [[ -f /output/omarchy.db.tar.zst ]]; then
# First find the exact desc file for this package (not package-debug, etc)
# Pattern matches: package-version/desc where version starts with a number
local desc_file=$(tar -tf /output/omarchy.db.tar.zst | grep "^${pkg}-[0-9].*/desc$" | head -1)
if [[ -n "$desc_file" ]]; then
# Extract that specific file and get the version
tar -xOf /output/omarchy.db.tar.zst "$desc_file" 2>/dev/null |
awk '/%VERSION%/{getline; print; exit}'
fi
fi
}
# Simple function to build an AUR package # Simple function to build an AUR package
build_aur_package() { build_aur_package() {
local pkg="$1" local pkg="$1"
local opts="$2" local opts="$2"
echo " -> Building $pkg..." echo " -> Processing $pkg..."
cd /src
# Case 1: Directory exists with PKGBUILD - check for updates # Get version from AUR API (also gets package base)
if [[ -d "$pkg" ]] && [[ -f "$pkg/PKGBUILD" ]]; then local aur_info=$(curl -s "https://aur.archlinux.org/rpc/?v=5&type=info&arg[]=$pkg")
cd "$pkg" local aur_version=$(echo "$aur_info" | jq -r '.results[0].Version // empty')
local pkg_base=$(echo "$aur_info" | jq -r '.results[0].PackageBase // empty')
# Store current commit before pull if [[ -z "$aur_version" ]]; then
OLD_COMMIT=$(git rev-parse HEAD 2>/dev/null || echo "none") echo " Package not found in AUR"
# Try to pull updates
git pull --quiet
# Get new commit after pull
NEW_COMMIT=$(git rev-parse HEAD 2>/dev/null || echo "none")
# Determine if we need to build
if [[ "$FORCE_REBUILD" == "true" ]]; then
echo " Forcing rebuild..."
elif [[ "$OLD_COMMIT" != "$NEW_COMMIT" ]]; then
echo " Updates found, rebuilding..."
else
echo " No updates found, skipping"
return 0
fi
# Case 2: Directory exists but no PKGBUILD - reclone
elif [[ -d "$pkg" ]]; then
echo " Incomplete clone detected, removing and recloning..."
rm -rf "$pkg"
git clone "https://aur.archlinux.org/${pkg}.git" || {
echo " Failed to clone $pkg"
FAILED_PACKAGES="$FAILED_PACKAGES $pkg" FAILED_PACKAGES="$FAILED_PACKAGES $pkg"
return 1 return 1
} fi
cd "$pkg"
# Case 3: Directory doesn't exist - clone # Use package name as base if not specified
else
# Get the package base from AUR RPC (some packages have different repo names)
local pkg_base=$(curl -s "https://aur.archlinux.org/rpc/?v=5&type=info&arg[]=$pkg" | jq -r '.results[0].PackageBase // empty')
# Fall back to package name if API call fails or returns nothing
if [[ -z "$pkg_base" ]]; then if [[ -z "$pkg_base" ]]; then
pkg_base="$pkg" pkg_base="$pkg"
elif [[ "$pkg_base" != "$pkg" ]]; then elif [[ "$pkg_base" != "$pkg" ]]; then
echo " Using package base: $pkg_base" echo " Using package base: $pkg_base"
fi fi
# Check if we need to build
local local_version=$(get_local_version "$pkg")
if [[ "$FORCE_REBUILD" == "true" ]]; then
echo " Forcing rebuild (AUR: $aur_version)"
elif [[ "$local_version" == "$aur_version" ]]; then
echo " Up to date: $local_version - Skipping build"
return 0
elif [[ -n "$local_version" ]]; then
echo " Update available: $local_version -> $aur_version"
else
echo " Not built yet (AUR: $aur_version)"
fi
# Always fresh clone when building
cd /src
rm -rf "$pkg"
git clone "https://aur.archlinux.org/${pkg_base}.git" "$pkg" || { git clone "https://aur.archlinux.org/${pkg_base}.git" "$pkg" || {
echo " Failed to clone $pkg" echo " Failed to clone $pkg_base"
FAILED_PACKAGES="$FAILED_PACKAGES $pkg" FAILED_PACKAGES="$FAILED_PACKAGES $pkg"
return 1 return 1
} }
cd "$pkg" cd "$pkg"
fi
# Build package # Build package
MAKEPKG_FLAGS="-sc --noconfirm" MAKEPKG_FLAGS="-sc --noconfirm"