Removed obsolete pacman scripts (replaced by expac, pactree and pacman -Qn).
parent
376bf060da
commit
4f37545808
|
@ -1,121 +0,0 @@
|
|||
#!/usr/bin/env zsh
|
||||
if [ -f "${0%/*}/.pacman-init" ];then
|
||||
. "${0%/*}/.pacman-init"
|
||||
else
|
||||
echo "Missing init file" && exit 1
|
||||
fi
|
||||
|
||||
# Note: we really need to use an array for this one, so Bourne shells will not
|
||||
# work.
|
||||
|
||||
_printhelp()
|
||||
{
|
||||
|
||||
cat <<EOF
|
||||
Usage: ${1##*/} [-a|-h|-q] [-r] PACKAGES
|
||||
|
||||
Display package dependencies. Output contains no double and is alphabetically
|
||||
sorted. It will only work for repos packages by default.
|
||||
|
||||
-a: Uses Yaourt queries instead of repos database. It slows down query but allow displaying size of any packages not available in repos.
|
||||
-h: Show this help.
|
||||
-r: Call function recursively.
|
||||
-q: Uses installed packages database instead of repos database. It speeds up queries and allows displaying size of local packages not available in repos.
|
||||
EOF
|
||||
}
|
||||
|
||||
CMD="pacman -Si"
|
||||
OPT_REC=0
|
||||
SEP=": "
|
||||
|
||||
while getopts ":ahrq" opt; do
|
||||
case $opt in
|
||||
a)
|
||||
CMD="yaourt -Si"
|
||||
;;
|
||||
h)
|
||||
_printhelp "$0"
|
||||
exit 1
|
||||
;;
|
||||
r)
|
||||
OPT_REC=1
|
||||
;;
|
||||
q)
|
||||
CMD="pacman -Qi"
|
||||
;;
|
||||
?)
|
||||
_printhelp "$0"
|
||||
exit 1
|
||||
;;
|
||||
:)
|
||||
echo "Missing argument."
|
||||
_printhelp "$0"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $(($OPTIND - 1))
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "Missing argument."
|
||||
_printhelp "$0"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $OPT_REC -eq 0 ]; then
|
||||
eval "${CMD} $@ 2>/dev/null" | awk -F "$SEP" -v filter="$pacman_deps" \
|
||||
'$0 ~ filter {gsub(/[>=<][^ ]*/,"",$2) ; gsub(/ +/,"\n",$2) ; print $2}' \
|
||||
| sort -u
|
||||
else
|
||||
## Recursive dependencies.
|
||||
|
||||
## Store the complete DB into a variable to speed up access.
|
||||
FULLDEPLIST=$(eval "${CMD}" | grep "${pacman_name}\|${pacman_deps}" | sed -n "/${pacman_name}/{s/.*: \(.*\)/\1:/;h;n;s/${pacman_deps}.*: //;s/[>=<][^ ]*//g;H;x;s/\n//;p}")
|
||||
|
||||
## Note: using an array is important for Ksh/Zsh compatibility.
|
||||
DEPLIST=()
|
||||
|
||||
## Check if argument $1 is in DEPLIST.
|
||||
_not_in_array()
|
||||
{
|
||||
if [ ${#DEPLIST} -eq 0 ]; then
|
||||
return 0
|
||||
else
|
||||
for j in ${DEPLIST[*]}; do
|
||||
if [ "$j" = "$1" ]; then
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
## This function calls recursively over the dependencies. It stops whenever
|
||||
## a package has already be handled, or when it has no dependency. Note:
|
||||
## 'grep | cut' is a little faster than 'sed' for simple stuff. Since it is
|
||||
## a loop, it is quite a performance boost.
|
||||
_pacman_deps_rec()
|
||||
{
|
||||
SUBDEPLIST=()
|
||||
for i ; do
|
||||
SUBDEPLIST=(${SUBDEPLIST[*]} $(echo "$FULLDEPLIST" | grep "^$i\s*:" | cut -d':' -f2))
|
||||
done
|
||||
|
||||
for i in ${SUBDEPLIST[*]} ; do
|
||||
if [ ! "$i" = "$pacman_deps_none" ] && _not_in_array "$i" ; then
|
||||
DEPLIST=(${DEPLIST[*]} "$i")
|
||||
_pacman_deps_rec "$i"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
for i ; do
|
||||
_pacman_deps_rec "$@"
|
||||
done
|
||||
|
||||
## There might be duplicates, so we remove them with the '-u' parameter of
|
||||
## sort.
|
||||
echo "${DEPLIST[*]}" | sed 's/ /\n/g' | sort -u
|
||||
fi
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
#!/bin/sh
|
||||
[ -z "$(command -v pacman)" ] && echo "You need pacman to run this script." && exit 1
|
||||
|
||||
## Retrieve official packages list.
|
||||
OFFICIAL="$(mktemp)"
|
||||
FOREIGN="$(mktemp)"
|
||||
pacman -Qq | sort > "$OFFICIAL"
|
||||
pacman -Qmq | sort > "$FOREIGN"
|
||||
comm -3 "$OFFICIAL" "$FOREIGN"
|
||||
rm -f "$OFFICIAL" "$FOREIGN"
|
||||
|
||||
## Zsh version.
|
||||
# comm -3 <(pacman -Qq | sort) <(pacman -Qmq | sort)
|
||||
|
||||
# Alternative 'diff' verision.
|
||||
# diff <(pacman -Qq | sort) <(pacman -Qmq | sort) --new-line-format='' --unchanged-group-format='%>'
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
#!/bin/sh
|
||||
if [ -f "${0%/*}/.pacman-init" ];then
|
||||
. "${0%/*}/.pacman-init"
|
||||
else
|
||||
echo "Missing init file" && exit 1
|
||||
fi
|
||||
|
||||
_printhelp()
|
||||
{
|
||||
cat <<EOF
|
||||
Usage: ${1##*/} [OPTIONS] PACKAGES
|
||||
|
||||
Display package size. Output contains no double and is alphabetically sorted. A
|
||||
grand total is printed at the end. It will only work for repos packages by
|
||||
default.
|
||||
|
||||
-h: Show this help.
|
||||
-n: Output is sorted by size.
|
||||
-q: Uses installed packages database instead of repos database. It speeds up queries and allows displaying size of local packages not available in repos.
|
||||
EOF
|
||||
}
|
||||
|
||||
CMD="pacman -Si"
|
||||
SEP=": "
|
||||
TOTAL_SIZE=0
|
||||
SORT="sort -u -k3"
|
||||
SORT_SIZE="cat"
|
||||
|
||||
while getopts ":hnq" opt; do
|
||||
case $opt in
|
||||
h)
|
||||
_printhelp "$0"
|
||||
exit 1
|
||||
;;
|
||||
n)
|
||||
SORT_SIZE="sort -n"
|
||||
;;
|
||||
q)
|
||||
CMD="pacman -Qi"
|
||||
;;
|
||||
?)
|
||||
_printhelp "$0"
|
||||
exit 1
|
||||
;;
|
||||
:)
|
||||
echo "Missing argument."
|
||||
_printhelp "$0"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $(($OPTIND - 1))
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "Missing argument."
|
||||
_printhelp "$0"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
## We use external variable for awk to fit current locales.
|
||||
RESULT="$(eval "${CMD} $@" 2>/dev/null | awk -F "$SEP" -v filter="$pacman_size" -v pkg="$pacman_name" \
|
||||
'$0 ~ pkg {pkgname=$2} $0 ~ filter {gsub(/\..*/,"") ; printf("%6s KiB %s\n", $2, pkgname)}' | eval "$SORT" | eval "$SORT_SIZE")"
|
||||
|
||||
echo "$RESULT"
|
||||
|
||||
## Print total size.
|
||||
echo "$RESULT" | awk '{TOTAL=$1+TOTAL} END {printf("Total: %d KiB\n",TOTAL)}'
|
||||
|
||||
## One line version. Approximately same performance. Note the combination of
|
||||
## 'tee' and >(awk ...) to write the detailed list to standard output and to
|
||||
## pass it to awk.
|
||||
|
||||
# eval "${CMD} $@ 2>/dev/null" | awk -F "$SEP" -v filter="$pacman_size" -v pkg="$pacman_name" \
|
||||
# '$0 ~ pkg {pkgname=$2} $0 ~ filter {gsub(/\..*/,"") ; printf("%6s KiB %s\n", $2, pkgname)}' | sort -u -k3 \
|
||||
# | tee >(awk '{TOTAL=$1+TOTAL} END {printf("Total: %d KiB\n",TOTAL)}')
|
||||
|
Loading…
Reference in New Issue