summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2017-11-01 16:37:37 +0100
committerFlorian Pritz <bluewind@xinu.at>2017-11-01 16:37:37 +0100
commit5011f2521ea1f6f2f3b1d22a7ff7e802e4ce3bcf (patch)
tree6e563f210048b44193ac1f731e70f2573c079bf1
parentcd8d6c04469211cdb6d1163d27d47e6fcd9a496e (diff)
downloadbin-5011f2521ea1f6f2f3b1d22a7ff7e802e4ce3bcf.tar.gz
bin-5011f2521ea1f6f2f3b1d22a7ff7e802e4ce3bcf.tar.xz
Add filter-pacman-log-pactree.pl
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r--filter-pacman-log-pactree.pl22
1 files changed, 22 insertions, 0 deletions
diff --git a/filter-pacman-log-pactree.pl b/filter-pacman-log-pactree.pl
new file mode 100644
index 0000000..5701e5c
--- /dev/null
+++ b/filter-pacman-log-pactree.pl
@@ -0,0 +1,22 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+
+use autodie;
+
+my $package = $ARGV[0];
+my $logfile = "/var/log/pacman.log";
+
+open my $logfh, "<", $logfile;
+
+my @dependencies = qx/pactree -l "$package" | sort -u/;
+chomp(@dependencies);
+die "No dependencies found. Did pactree fail?" if (@dependencies == 0);
+
+my $re = join("|", map {quotemeta} @dependencies);
+my $dependency_regex = qr/\s($re)\s/;
+
+while (<$logfh>) {
+ print if m/$dependency_regex/;
+}
+