dotfiles

:)
git clone https://git.sr.ht/~ashymad/dotfiles
Log | Files | Refs | Submodules | LICENSE

commit 8de0cd3947fea45c9be1b46c84faa96060b3fb80
parent e5c803ae74c4a16f1f28edd2482d1e3e06da96e2
Author: Szymon Mikulicz <szymon.mikulicz@posteo.net>
Date:   Tue, 17 Mar 2020 22:12:59 +0100

fish: ugprade aur-cleanup and aur + add aur-vercmp-devel and rollback

Diffstat:
Mfish/.config/fish/functions/aur-cleanup.fish | 40+++++++++++++++++++++++-----------------
Afish/.config/fish/functions/aur-vercmp-devel.sh | 27+++++++++++++++++++++++++++
Mfish/.config/fish/functions/aur.fish | 12+++++++-----
Afish/.config/fish/functions/rollback.fish | 14++++++++++++++
4 files changed, 71 insertions(+), 22 deletions(-)

diff --git a/fish/.config/fish/functions/aur-cleanup.fish b/fish/.config/fish/functions/aur-cleanup.fish @@ -1,23 +1,29 @@ function aur-cleanup - source ~/.config/fish/utils/pacmsg.fish - msg1 "Cleaning pacman cache..." - sudo pacman -Sc --noconfirm - msg1 "Rebuilding custom repositories..." - for repo in /var/cache/pacman/*custom* - cd $repo + source ~/.config/fish/utils/pacmsg.fish + msg1 "Cleaning pacman cache..." + sudo pacman -Sc --noconfirm + msg1 "Rebuilding custom repositories..." + for repo in /var/cache/pacman/*custom* + cd $repo set reponame (basename $repo) rm $reponame.db* repo-add -n $reponame.db.tar *.pkg.tar.xz - end - sudo pacman -Sy - msg1 "Cleaning aur sync cache..." - cd ~/.cache/aurutils/sync - for dir in * - set pkgname (bash -c "source $dir/PKGBUILD;"'echo $pkgname') - if not pacman -Qi $pkgname >/dev/null 2>/dev/null - echo "Removing $dir..." - rm -rf -- $dir - end - end + end + sudo pacman -Sy + msg1 "Cleaning aur sync cache..." + cd ~/.cache/aurutils/sync + for dir in * + set pkgname (bash -c "source $dir/PKGBUILD;"'echo $pkgname') + if not pacman -Qi $pkgname >/dev/null 2>/dev/null + echo "Removing $dir..." + rm -rf -- $dir + else + set reponame (pacman -Ss '^'(string escape --style=regex $pkgname)'$' | head -1 | sed 's@/.*$@@g') + if not string match -q 'custom*' $reponame + echo "Removing $dir..." + rm -rf -- $dir + end + end + end end diff --git a/fish/.config/fish/functions/aur-vercmp-devel.sh b/fish/.config/fish/functions/aur-vercmp-devel.sh @@ -0,0 +1,27 @@ +#!/bin/bash +XDG_CACHE_HOME=${XDG_CACHE_HOME:-$HOME/.cache} +AURDEST=${AURDEST:-$XDG_CACHE_HOME/aurutils/sync} +AURVCS=${AURVCS:-.*-(cvs|svn|git|hg|bzr|darcs)$} + +filter_vcs() { + awk -v "mask=$AURVCS" '$1 ~ mask {print $1}' "$@" +} + +# Note that valid PKGBUILDs cannot contain \n in pkgname. +get_latest_revision() { + grep -Fxf - <(printf '%s\n' *) | xargs -r aur srcver +} + +db_tmp=$(mktemp) +trap 'rm -rf "$db_tmp"' EXIT + +# Retrieve a list of the local repository contents. The repository +# can be specified with the usual aur-repo arguments. +aur repo --list "$@" >"$db_tmp" + +# Find VCS packages that are outdated according to aur-srcver. +# This checks out the latest revision for existing source directories, +# assuming the PKGBUILD has been viewed priorly. +if cd "$AURDEST"; then + aur vercmp -p <(filter_vcs "$db_tmp" | get_latest_revision) <"$db_tmp" +fi diff --git a/fish/.config/fish/functions/aur.fish b/fish/.config/fish/functions/aur.fish @@ -1,9 +1,11 @@ #!/usr/bin/env fish function aur - if test -f "$HOME/.config/fish/functions/aur-$argv[1].fish" - eval "aur-$argv[1]" $argv[2..-1] - else - /usr/bin/aur $argv - end + if test -f "$HOME/.config/fish/functions/aur-$argv[1].fish" + eval "aur-$argv[1]" $argv[2..-1] + else if test -f "$HOME/.config/fish/functions/aur-$argv[1].sh" + bash "$HOME/.config/fish/functions/aur-$argv[1].sh" + else + /usr/bin/aur $argv + end end diff --git a/fish/.config/fish/functions/rollback.fish b/fish/.config/fish/functions/rollback.fish @@ -0,0 +1,14 @@ +function rollback + set Y (date --date "$argv" +%Y) + set m (date --date "$argv" +%m) + set d (date --date "$argv" +%d) + sudo mv /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bkp + echo "Server=https://archive.archlinux.org/repos/$Y/$m/$d/"'$repo/os/$arch' | sudo tee /etc/pacman.d/mirrorlist + sudo timedatectl set-ntp false + sudo timedatectl set-time "$Y-$m-$d" + sudo pacman -Syyuu + sudo timedatectl set-ntp true + sudo hwclock --systohc + sudo mv /etc/pacman.d/mirrorlist.bkp /etc/pacman.d/mirrorlist +end +