diff options
author | Peter Wu <peter@lekensteyn.nl> | 2015-01-24 19:34:28 +0100 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2015-01-24 19:34:28 +0100 |
commit | 66facb91e09da997187b9ee43027c68c18bc2e66 (patch) | |
tree | 22eb0025e95cae72c4685704ba53059f2d197742 | |
parent | d9cee4f7fe70a07fefb28446a2affca86e46ecf6 (diff) | |
download | scripts-66facb91e09da997187b9ee43027c68c18bc2e66.tar.gz |
pactree-aur: mark pactree output with sources
Lsat modified 2014-12-30
-rwxr-xr-x | pactree-aur | 42 |
1 files changed, 42 insertions, 0 deletions
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"); +} +' |