#!/usr/bin/perl -w

use strict;
use warnings;
use Getopt::Long;
use Pod::Usage;
#use File::Basename;
use ALTLinux::ACL;

my $verbose=0;
my $help=0;
my $column=1;

my $result = GetOptions (
    @ALTLinux::ACL::LONGOPT,
    "help"  => \$help,
    'quiet'=> sub {$verbose=0},
    "verbose+"  => \$verbose,
    "column=i"  => \$column,
);

if ($help) {
    pod2usage();
}

my $acl = ALTLinux::ACL->new();
# in perl, column counting is from 0.
$column--;
while (<>) {
    chomp;
    my @line=split(/\s+/,$_);
    my $name=$line[$column];
    next unless $name; # empty line ?
    my @acl_list=$acl->acl($name);
    warn "$name: the package has no acl\n" unless @acl_list;
    print STDERR "name=$name acl: ",join(',',@acl_list),"\n" if $verbose;
    print "$_\t".join(" ",@acl_list),"\n";
}

=head1	NAME

altlinux-acl-filter-list-append-acl - append altlinux acl string to the list of names.

=head1	SYNOPSIS

B<altlinux-acl-filter-list-append-acl>
[B<-h|--help>]
[B<-q|--quiet>]
[B<-v|--verbose>]
[B<-c|--column> I<N>]

=head1	DESCRIPTION

B<altlinux-acl-filter-list-append-acl> 

=head1	OPTIONS

=over

=item	B<-h, --help>

Display this help and exit.

=item	B<-c, --column> I<N>

The column containing source rpm name (counting from 1).

=item	B<-v, --verbose>, B<-q, --quiet>

Verbosity level. Multiple -v increase the verbosity level, -q sets it to 0.

=back

=head1	AUTHOR

Written by Igor Vlasenko <viy@altlinux.org>.

=head1	COPYING

Copyright (c) 2009 Igor Vlasenko, ALT Linux Team.

This is free software; you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any later version.

=cut
