I am testing the script (i am not a dev and not know about python), and I added some packages more, when run it the archlinux.org server banned me. If use a VPN i can access, so is a ban.
Additionally, vulkan-headers that is flagged out of date, breaks the script.
No user agent or the speed for query maybe I guess?, well, i put here my modification:
import subprocess
import os
PACKAGES = [
"mesa",
"mesa-demos",
"vulkan-mesa-layers",
"opencl-mesa",
"lib32-mesa",
"vulkan-intel",
"vulkan-swrast",
"mesa-vdpau",
"libva-mesa-driver",
"libva-vdpau-driver",
"libva",
"lib32-libva-vdpau-driver",
"lib32-libva-mesa-driver",
"lib32-mesa-demos",
"lib32-mesa-vdpau",
"lib32-vulkan-icd-loader",
"lib32-vulkan-intel",
"lib32-vulkan-radeon",
"mesa-utils",
"vulkan-radeon",
"vulkan-headers",
"vulkan-icd-loader",
"lib32-libva",
]
ARCH = subprocess.run(["uname", "-m"], capture_output=True, text=True).stdout.strip()
URL_PREFIX = f"https://archlinux.org/packages/@REPO@/{ARCH}"
URL_SUFFIX = "download"
CACHE_DIR = f"/tmp/package_cache"
# Create the cache directory inside /tmp if it does not exist
if not os.path.exists(CACHE_DIR):
os.makedirs(CACHE_DIR)
# Set permissions to allow the current user to create and modify files in it
os.chmod(CACHE_DIR, 0o755)
# Generate a list of package URLs using a list comprehension
PACKAGES_URL = [
f"{URL_PREFIX.replace('@REPO@', 'multilib')}/{package}/{URL_SUFFIX}"
if package.startswith("lib32-")
else f"{URL_PREFIX.replace('@REPO@', 'extra')}/{package}/{URL_SUFFIX}"
for package in PACKAGES
if subprocess.run(["pacman", "-Qi", package], capture_output=True, text=True).returncode == 0
]
# Start the yes command in the background to automatically respond "y" to the prompt
yes_process = subprocess.Popen(["yes", "S"], stdout=subprocess.PIPE)
# Run the pacman command, using the output of the yes command as the input
subprocess.run(
["sudo", "pacman", "--cachedir", CACHE_DIR, "-U"] + PACKAGES_URL,
stdin=yes_process.stdout,
)
# Terminate the yes command
yes_process.terminate()
# Delete the cache directory
subprocess.run(["rm", "-rf", CACHE_DIR])