remove complex bit related to fedora rawhide

This commit is contained in:
Lukas Greve
2025-11-18 16:55:24 +01:00
parent c99938e744
commit f25c33eaca

View File

@@ -1,62 +1,5 @@
#!/bin/bash #!/bin/bash
# Function to get latest Fedora Rawhide image URL using a more reliable method
get_fedora_latest_rawhide_url() {
local base_url="https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Cloud/x86_64/images/"
# Method: Try fetching the latest link from the directory
local temp_dir
temp_dir=$(mktemp -d)
# Download the HTML directory listing
if curl -s -o "$temp_dir/listing.html" "$base_url"; then
# Look for the most recent Fedora-Cloud-Base-Generic-Rawhide qcow2 file
local latest_file
latest_file=$(grep -i "Fedora-Cloud-Base-Generic-Rawhide.*\.qcow2" "$temp_dir/listing.html" | \
sort -r | head -1 | sed -E 's/.*href="([^"]*)".*/\1/')
if [[ -n "$latest_file" ]]; then
echo "${base_url}${latest_file}"
else
# If we can't find Fedora-Cloud-Base-Generic-Rawhide specifically,
# look for any Fedora image with a qcow2 extension
local any_file
any_file=$(grep -i "Fedora.*\.qcow2" "$temp_dir/listing.html" | \
head -1 | sed -E 's/.*href="([^"]*)".*/\1/')
if [[ -n "$any_file" ]]; then
echo "${base_url}${any_file}"
else
echo ""
fi
fi
else
# If network fails, return empty string to skip Fedora download
echo ""
fi
# Cleanup
rm -rf "$temp_dir"
}
# Function to check if a Fedora Rawhide image already exists in the target directory
check_fedora_rawhide_exists() {
local target_dir="$1"
# Look for any existing Fedora Rawhide image by pattern
if [[ -d "$target_dir" ]]; then
local exists
exists=$(find "$target_dir" -maxdepth 1 -type f -name "*Fedora-Cloud-Base-Generic-Rawhide*.qcow2" 2>/dev/null | head -1)
if [[ -n "$exists" ]]; then
echo "true"
else
echo "false"
fi
else
echo "false"
fi
}
# Image URLs with dynamic Fedora URL handling # Image URLs with dynamic Fedora URL handling
IMAGES=( IMAGES=(
"https://cloud.debian.org/images/cloud/trixie/latest/debian-13-genericcloud-amd64.raw" "https://cloud.debian.org/images/cloud/trixie/latest/debian-13-genericcloud-amd64.raw"
@@ -65,17 +8,9 @@ IMAGES=(
"https://dl.rockylinux.org/pub/rocky/10/images/x86_64/Rocky-10-GenericCloud-Base.latest.x86_64.qcow2" "https://dl.rockylinux.org/pub/rocky/10/images/x86_64/Rocky-10-GenericCloud-Base.latest.x86_64.qcow2"
"https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img" "https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img"
"https://cloud.centos.org/centos/10-stream/x86_64/images/CentOS-Stream-GenericCloud-x86_64-10-latest.x86_64.qcow2" "https://cloud.centos.org/centos/10-stream/x86_64/images/CentOS-Stream-GenericCloud-x86_64-10-latest.x86_64.qcow2"
"https://download.fedoraproject.org/pub/fedora/linux/releases/43/Cloud/x86_64/images/Fedora-Cloud-Base-Generic-43-1.6.x86_64.qcow2"
) )
# Add Fedora image if we can get a valid URL AND no Fedora Rawhide image exists
FEDORA_EXISTS=$(check_fedora_rawhide_exists "/var/lib/libvirt/images")
if [[ "$FEDORA_EXISTS" == "false" ]]; then
FEDORA_URL=$(get_fedora_latest_rawhide_url)
if [[ -n "$FEDORA_URL" ]]; then
IMAGES+=("$FEDORA_URL")
fi
fi
# Target directory # Target directory
TARGET_DIR="/var/lib/libvirt/images" TARGET_DIR="/var/lib/libvirt/images"