Skip to content

Instantly share code, notes, and snippets.

@zrhoffman
Last active August 13, 2024 16:10
Show Gist options
  • Save zrhoffman/14dc1ec210fe08c70b5c90986011655f to your computer and use it in GitHub Desktop.
Save zrhoffman/14dc1ec210fe08c70b5c90986011655f to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set +o errexit +o nounset;
cd ~/.cache/yay;
format=%Y-%m-%d
date="$(date +"${format}")";
declare -A package_dir_names;
package_dir_names[firefox-nightly]=firefox-nightly-bin;
for package in "${package_dir_names[@]}"; do
install_date="$(</var/log/pacman.log grep " \(installed\|reinstalled\|upgraded\) ${package} " | tail -n1 | sed 's/^\[\([^]]*\).*/\1/g')"
if [[ -z "$install_date" ]]; then
install_date="$(date +"${format}" -d '-1 day')"
else
install_date="$(date +"${format}" --date="$install_date")"
fi
if [[ "$install_date" != "$date" ]]; then
(
cd "$package";
git checkout .
git pull
rm -f -- *.bz2{,.asc} *.gz *.xz *.zst *.part
yay -S --noconfirm "$package" || makepkg --install --noconfirm "$package"
)
fi;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment