/usr/bin/ocap is in paco 2.0.9-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | #!/usr/bin/perl
#----------------------------------------------------------------------
# ocap - Find files not logged by any package in the paco database.
#----------------------------------------------------------------------
# This file is part of the package paco
# Copyright (C) 2006-2009 David Rosal
# For more information visit http://paco.sourceforge.net
#----------------------------------------------------------------------
use warnings;
use strict;
use Getopt::Long;
use Cwd;
Getopt::Long::Configure("no_ignore_case", "bundling");
my $me = "ocap";
my $logdir = '';
sub help
{
print <<EOF;
$me - Find files not logged by any package in the paco database.
Usage:
$me [-hv] [-L DIR] <paths>
Options [default values listed in brackets]:
-v, --version Display version information.
-h, --help Display this help message.
-L, --logdir=DIR Base paco log directory [$logdir].
<paths> List of paths to scan [/].
EOF
exit(0);
}
sub expand_home
{
my $x = shift;
$x or return;
my $home = `echo \$HOME`;
$home or return $x;
chomp($home);
$x =~ s/\${?HOME}?/$home/g;
return $x;
}
# Check for paco, and get the version, pacorc and logdir
my $version = `paco --version` or exit(1);
$version =~ s/^paco-//;
my $pacorc = `pkg-config --variable=pacorc paco 2>/dev/null`;
($pacorc) or $pacorc = "/etc/pacorc";
$logdir = `pkg-config --variable=logdir paco 2>/dev/null`;
# Parse pacorc
if (open(CFG, $pacorc)) {
while (<CFG>) {
chomp;
if (/^LOGDIR=(.+)$/) {
$logdir = &expand_home($1);
last;
}
}
close(CFG);
}
chomp($logdir);
# Command line arguments
GetOptions(
'V|version' => sub { print("$me-$version"); exit(0); },
'h|help' => \&help,
'L|logdir=s' => \$logdir,
) or &help;
($logdir) or $logdir = "/var/log/paco";
chomp($logdir);
my $dirs_regex = "";
my @dirs = @ARGV;
@dirs or @dirs = "/";
for (@dirs) {
chomp;
s/\/+/\//g;
s/(.)\/$/$1/;
$dirs_regex .= "$_|";
}
# Get the list of logged files
my @files = ();
for (glob("$logdir/*")) {
open(LOG, $_) or die("$me: open($_): $!\n");
while (<LOG>) {
(/^-?(($dirs_regex)\/[^|]*)(\.gz|\.bz2)?\|/) and push(@files, $1);
}
close(LOG);
}
chomp(@files);
# Find non logged files
my $found = 0;
for my $file (`find @dirs ! -type d`) {
chomp($file);
$file =~ s/\.(gz|bz2)$//;
$found = 0;
for (@files) {
if ($_ eq $file) {
$found++;
last;
}
}
$found or print("$file\n");
}
|