summaryrefslogtreecommitdiffstats
path: root/filter-pacman-log-pactree.pl
blob: 5701e5c31c4eafe9468e39e4911080dd7a268834 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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/;
}