summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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/;
+}
+