Skip to content

Instantly share code, notes, and snippets.

@ConfuSomu
Created April 22, 2023 16:43
Show Gist options
  • Select an option

  • Save ConfuSomu/95b697c533fa3544341864a1e1cdf2e1 to your computer and use it in GitHub Desktop.

Select an option

Save ConfuSomu/95b697c533fa3544341864a1e1cdf2e1 to your computer and use it in GitHub Desktop.
Script for retriving packages from the Arch Linux Archive. This is handy when you don't upgrade your system often but still have to install packages.
#!/bin/bash
# Script that allows installing packages from the Arch Linux Archive
# Made by ConfuSomu/Twilight on the 2023-01-12
# Licensed under the GNU GPL
URL_BASE="archive.archlinux.org"
PKG_DIR="/var/cache/pacman/pkg"
usage() {
echo "$(basename ${0}) <packages to install from archive>"
exit 1
}
if [ -z "${1}" ]
then
usage
fi
PKGS_IN="${@}"
echo $PKGS_IN
ARCH=$(uname -m)
echo $ARCH
cd $PKG_DIR
# when looping over each package
while read -r line; do
REPO=$(echo "$line" | cut -d " " -f2)
#PKG_NAMEVER=$(echo "$line" | cut -d " " -f1)
PKG_URL=$(echo "$line" | cut -d " " -f1)
PKG_FILE="${PKG_URL##*/}" # works when the package's arch is any
DATE=$(/bin/ls -l --time-style=+"%Y/%m/%d" /var/lib/pacman/sync/$REPO.db | cut -d " " -f6)
echo -n "Retriving $PKG_FILE"
sudo wget --quiet --continue --no-clobber --progress=dot -e dotbytes=10M --show-progress "https://$URL_BASE/repos/$DATE/$REPO/os/$ARCH/$PKG_FILE" "https://$URL_BASE/repos/$DATE/$REPO/os/$ARCH/$PKG_FILE.sig"
#echo "https://$URL_BASE/repos/$DATE/$REPO/os/$ARCH/$PKG_NAMEVER.pkg.tar.zst" #then same but append .sig
done < <(pacman -Sp --print-format "%l %r" $PKGS_IN )
echo -e "\a"
sudo pacman -S $PKGS_IN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment