From 66facb91e09da997187b9ee43027c68c18bc2e66 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Sat, 24 Jan 2015 19:34:28 +0100 Subject: pactree-aur: mark pactree output with sources Lsat modified 2014-12-30 --- pactree-aur | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 pactree-aur diff --git a/pactree-aur b/pactree-aur new file mode 100755 index 0000000..6771606 --- /dev/null +++ b/pactree-aur @@ -0,0 +1,42 @@ +#!/bin/sh +# Runs pactree and outputs the annotated output + +pactree "$@" | +gawk -e ' +BEGIN { + FS = "[/ ]"; + cmd = "pacman -Ss"; + while (cmd | getline) { + # package name -> repo + if (/^[^ ]/) + packages[$2] = $1; + } +} + +# Appends repo to each package (match each package name and prepend repo) +{ + # misunderstood output of pactree. It has only one package per line. + packages_per_line = 1; + + # Include ";" so it is easier to recognize colors + count = split($0, pkgs, /[^;A-Za-z0-9@._+-]+/, seps); + for (i = 1; i <= count; i++) { + pkg = pkgs[i]; + if (match(pkg, /^[0-9;]*m/) > 0) { + printf("%s", substr(pkg, 1, RLENGTH)); + #printf("(%s:%s)", substr(pkg, 1, RLENGTH), substr(pkg, RLENGTH + 1)); + pkg = substr(pkg, RLENGTH + 1); + } + if (pkg ~ /^[A-Za-z0-9]/ && packages_per_line-- > 0) { + if (pkg in packages) { + pkg = packages[pkg] "/" pkg; + } else { + pkg = "aur/" pkg; + } + } + printf("%s", pkg); + printf("%s", seps[i]); # Empty for last field + } + printf("\n"); +} +' -- cgit v1.2.1