Restructuring the repo

This commit is contained in:
Alexander Gehrke 2020-04-02 10:38:36 +02:00
parent 21e3cf65e6
commit 3d67598c27
45 changed files with 368 additions and 77 deletions

66
void/xbps-worldfile Executable file
View file

@ -0,0 +1,66 @@
#!/bin/zsh
zparseopts -D -E h=help -help=help d=desc -describe=desc
function not-in-left() {
awk 'NR==FNR{a[$0]=1;next}!a[$0]' "$@"
}
function first-col() {
cut -d$'\t' -f1
}
function info() {
printf "$@" >&2
}
if [[ -n $help ]]; then
echo 'Usage: xbps-worldfile [-d]'
echo 'Edit a list of manually installed packages in your editor and update the pkgdb'
echo
echo ' -d, --describe Query short description for packages and display it in the list (slow)'
exit
fi
TMPFILE=$(mktemp -p ${TMPDIR:-/tmp} xbps-worldfile.XXXXXXXXXX)
if [[ -n $desc ]]; then
info "Generating worldfile with descriptions\n"
xbps-query -m | while read pkg; do
info .
printf "%-40s\t%s\n" $pkg "$(xbps-query -p short_desc $pkg)"
done > $TMPFILE
else
xbps-query -m > $TMPFILE
fi
EDITFILE=$(mktemp -p ${TMPDIR:-/tmp} xbps-worldfile.edit.XXXXXXXXXX)
cp $TMPFILE $EDITFILE
$EDITOR $EDITFILE
autopkgs=$(not-in-left $EDITFILE $TMPFILE | first-col)
manualpkgs=$(not-in-left $TMPFILE $EDITFILE | first-col)
rm $TMPFILE $EDITFILE
if [[ -z $manualpkgs && -z $autopkgs ]]; then
info "No changes.\n"
exit
fi
info "\e[92minstalling:\e[0m\n${manualpkgs}\n\n"
info "\e[93mchanging to auto:\e[0m\n${autopkgs}\n\n"
info "\e[1mContinue? [y/n]:"
if ! read -q; then exit; fi
if [[ -n $manualpkgs ]]; then
xbps-install $=manualpkgs
xbps-pkgdb -m manual $=manualpkgs
fi
if [[ -n $autopkgs ]]; then
xbps-pkgdb -m auto $=autopkgs
info "\e[93mcleaning orphans\e[0m"
xbps-remove -Ro
fi

23
void/xrevdep Executable file
View file

@ -0,0 +1,23 @@
#!/bin/zsh
CLEAR="\e[2K\e[${COLUMNS}D"
printc() {
printf "$CLEAR\e[32m%s\e[0m" "$*" >&2
}
revdep() {
printc "> $1"
parents=$(xbps-query -X "$1")
if [[ -z $parents ]]; then
echo $1
else
while IFS= read -r i; do
revdep $i
done <<<"$parents"
fi
}
result=$(revdep "$1")
printc
sort -u <<<"$result"