Re: A question about --queryformat

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 30 Dec 2003, Paul Nasrat wrote:

> On Tue, Dec 30, 2003 at 12:12:55PM -0500, Tom Diehl wrote:
> 
> > They both return /etc/auto.master for the filename. Is there a way to have
> > rpm display the filename I am querying in the output?? Can someone tell
> > me what the filename querytag is really displaying??
> 
> %{filenames} is a list of all the files belonging to the package, you are getting the first element:
>                                                                                         
> rpm -qf --qf '[%{name} %{filenames}\n]' /etc/auto.misc
> 
> AFAIK there is no tag which corresponds to the file/package that is being queried with qp/qf

:-(

> You could do something like:
> 
> for file in /etc/auto.misc; do  rpm -qf --qf "%{name} $file\n" $file; done

Thanks for the info but I should have given some more details as to what
I was actually trying to do. I knew I could do this in the shell but I am
playing with perl and so far I have not found a way to make it do what I want.
I am trying to do something like the following:

open(CKFILE,"rpm -qf $path |");
while(<CKFILE>)
    {
    ($status, $filename) = split(" ");
    if ( $status eq "file")
        {
        # "file ... is not owned by any package "
        printf("Process Line -->%s<--\n", $filename);
        }
    else
        {
        # rpm returned the name of the owning package as the only string on the line
        printf("File >>%s<< is owned by package >>%s<<. Skipping\n", $status, $filename);
        }
    }
close(CKFILE);

If I set $path to something like /etc/auto.* rpm will expand the * as it should and
do the checks. The problem is that if the file I am checking is not owned by
any package I need its name so that I can do some further processing. The printf
above prints out /etc/auto.* as opposed to /etc/auto.master, /etc/auto.misc, etc.
I realize this is a perl problem that I am trying to solve with rpm so since it
appears that will not work I huess I need to go learn some more perl. :-)

Oh well, that is after all what this is all about.

Thanks again.

........Tom


_______________________________________________
Rpm-list mailing list
Rpm-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/rpm-list

[Index of Archives]     [RPM Ecosystem]     [Linux Kernel]     [Red Hat Install]     [PAM]     [Red Hat Watch]     [Red Hat Development]     [Red Hat]     [Gimp]     [Yosemite News]     [IETF Discussion]

  Powered by Linux