summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-11-23 09:57:19 +0100
committerErich Eckner <git@eckner.net>2018-11-23 09:57:19 +0100
commit6cccbace7755ff7c195fc9f4dcfc9d0b3f32209f (patch)
tree7450872b3049c87ca2daf0c64e0fa72a33295d5c /bin
parentb5012b7bb7b953c04c2b6b3868a97892c1be68dd (diff)
downloadbuilder-6cccbace7755ff7c195fc9f4dcfc9d0b3f32209f.tar.xz
bin/wtf: use local call to pkgfile instead of web api
Diffstat (limited to 'bin')
-rwxr-xr-xbin/wtf59
1 files changed, 22 insertions, 37 deletions
diff --git a/bin/wtf b/bin/wtf
index 1963cff..232ffe7 100755
--- a/bin/wtf
+++ b/bin/wtf
@@ -2,45 +2,30 @@
# shellcheck disable=SC2119,SC2120
+# shellcheck source=../lib/load-configuration
+. "${0%/*}/../lib/load-configuration"
+
+# TODO: search i486, too
+
search="$*"
-wget -qO- 'https://pkgapi.arch32.tyzoid.com/esearch/'"${search##*/}"'.xml' | \
- awk '
- BEGIN {
- package="";
- version="";
- repo="";
- filelen=0;
- }
- {
- if ($1 == "</package>") {
- printf "[" repo "] " package " (" version "):";
- for (i=1; i <= filelen; i++) {
- printf " " file[i];
- }
- print "";
- package="";
- version="";
- repo="";
- filelen=0;
- }
- if ($1 ~ /^<name>/) {
- package = gensub(/<[^>]+>/, " ", "g", $1);
- }
- if ($1 ~ /^<version>/) {
- version = gensub(/<[^>]+>/, "", "g", $1);
- }
- if ($1 ~ /^<repo>/) {
- repo = gensub(/<[^>]+>/, "", "g", $1);
- }
- if ($1 ~ /^<file>/) {
- file[++filelen] = gensub(/<[^>]+>/, "", "g", $1);
- }
- }
- ' | \
+pkgfile -wC "${base_dir}/misc/pacman-i686.conf" -s "${search##*/}" | \
+ xargs -rn1 pkgfile -wC "${base_dir}/misc/pacman-i686.conf" -l | \
if printf '%s\n' "${search}" | \
- grep -q '/'; then
+ grep -q '^/'; then
grep -w "${search}" || true
else
- cat
- fi
+ grep "/${search}\\(/\\|\$\\)" || true
+ fi | \
+ sort -k2,2 | \
+ sed '
+ s,^\([^/[:space:]]\+\)/\([^/[:space:]]\+\)\s\(\S.*\)$,\2 [\1]: \3,
+ ' | \
+ sed '
+ :a
+ $!N
+ s#^\(\([^/:[:space:]]\+ [^/:[:space:]]\+, \)*[^/:[:space:]]\+ [^/:[:space:]]\+\): \([^\n]\+\)\n\([^/:[:space:]]\+ [^/:[:space:]]\+\): \3$#\1, \4: \3#
+ ta
+ P
+ D
+ '