Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
qpkg working correctly?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
Mnemia
Guru
Guru


Joined: 17 May 2002
Posts: 476

PostPosted: Thu Oct 31, 2002 8:06 pm    Post subject: qpkg working correctly? Reply with quote

I apologize if this has been asked before, but I want to find out if the behavior I'm getting from qpkg is correct or if it is broken somehow. I've unmerged and remerged just to make sure.

When I do a qpkg -f <file> in order to find what package owns a file, for some files, it works as expected. For others, it only works when I specify the full path to the file, eg qpkg -f /bin/cp. This does not solve the problem however because it seems to be pretty random whether I need to specify the full path or not and there are some file it does not work for when you do this but does work if you are in the directory.

Examples:
Here's a file I must be in the directory to get any output for:
Code:

luna / # qpkg -f /etc/hostname
luna / #

Code:

luna etc # qpkg -f hostname
sys-apps/net-tools *
luna etc #


Here's a file I must specify the full path to get any output for:
Code:

luna / # qpkg -f /bin/cp
sys-apps/fileutils *

Code:

luna bin # qpkg -f ./cp
luna bin #


Is qpkg supposed to work this way, or is my system messed up and/or is qpkg broken? It's behavior seems very inconsistent and erratic.
Back to top
View user's profile Send private message
Mnemia
Guru
Guru


Joined: 17 May 2002
Posts: 476

PostPosted: Fri Nov 01, 2002 5:06 am    Post subject: Reply with quote

I've been playing around with this some more, and there are quite a few files on my system that qpkg doesn't return any output for at all, by either method above. Why is this the case? It seems that qpkg doesn't work very consistently at all, not to mention that the problem I originally posted basically destroys its usefullness in bash scripts since I can't predict when it's going to need which syntax. Is my portage database horribly broken if qpkg doesn't work on so many files? Or is it a bug in qpkg itself? Has anyone else at all had any of these experiences?
Back to top
View user's profile Send private message
rac
Bodhisattva
Bodhisattva


Joined: 30 May 2002
Posts: 6553
Location: Japanifornia

PostPosted: Fri Nov 01, 2002 5:36 am    Post subject: Re: qpkg working correctly? Reply with quote

Something is definitely strange, but I don't think it's what you think it is. Current working directory is a red herring. qpkg -f hostname returns sys-apps/net-tools for me no matter where I am, and I think it's a false positive. What qpkg is doing is grepping through CONTENTS files using a fairly loose regex syntax. It looks for a space followed by whatever you give it, and in this case, it's picking up the symlinks to /bin/hostname from /bin/domainname and friends. It has nothing to do with /etc/hostname, which you made yourself.

If you're doing what I think you're doing, you might want to use the which command to get full paths for things, and then pass those to qpkg. The regex used by qpkg should probably be changed to add a '^\S+' to the front of it, which would eliminate false positives like a bare hostname.
_________________
For every higher wall, there is a taller ladder
Back to top
View user's profile Send private message
Mnemia
Guru
Guru


Joined: 17 May 2002
Posts: 476

PostPosted: Fri Nov 01, 2002 6:37 am    Post subject: Reply with quote

Cool, thanks. I think I understand better what's going on now.

For files that are placed in the directory tree outside of /etc it seems to work fine if I use the full path name as you suggest. In /etc it still does seem to have some weird behavior even for files that were indeed put there by portage (unlike hostname). It sometimes doesn't associate those with a package even when they are files that some ebuild installed and that I haven't touched since installing them. I'm not entirely sure if qpkg is even meant to deal with those config files though and I don't really care for my present situation since I'll just write my script to not mess with stuff in /etc as I'd rather deal with that by hand.

I was actually trying to make a script that I could run on my different Gentoo machines over NFS so that it could "synchronize" their installations so that they have the same exact list of packages installed for easier management by me. I started to do this mainly just because I thought it might be a cool way to help me save time on cloning machines' install, but I'm not sure it's really worth the effort anymore when portage is so easy to use. And there's probably a better way to do this but I thought I might be able to do this quickly.
Back to top
View user's profile Send private message
rac
Bodhisattva
Bodhisattva


Joined: 30 May 2002
Posts: 6553
Location: Japanifornia

PostPosted: Fri Nov 01, 2002 6:56 am    Post subject: Reply with quote

Mnemia wrote:
In /etc it still does seem to have some weird behavior even for files that were indeed put there by portage (unlike hostname). It sometimes doesn't associate those with a package even when they are files that some ebuild installed and that I haven't touched since installing them.

That is probably the difference between files in /etc that get installed into the image directory during the src_install function of the ebuild and those that get created afterwards, by, for example, ebuild config. Only stuff that made it into the install image are going to get registered in CONTENTS; those made afterwards, although they seem to the user to be part of that ebuild, aren't from the POV of Portage.

Poke around in /var/db/pkg a bit, looking at a few CONTENTS files, and the light bulb should go on as to how qpkg does what it does. Also, qpkg is a shell script, so it's directly readable in place, too. A pretty complicated shell script, but still shell.
_________________
For every higher wall, there is a taller ladder
Back to top
View user's profile Send private message
Mnemia
Guru
Guru


Joined: 17 May 2002
Posts: 476

PostPosted: Fri Nov 01, 2002 7:04 am    Post subject: Reply with quote

Thanks a ton. I looked at the code for qpkg just now and some of the CONTENTS files and I see what you mean about the config files. Regardless I don't think it's that important for what I'm doing. It was just something I had a little trouble understanding when I was trying to use qpkg in a script.

Again, thanks! It's funny how ya don't always realize that you don't understand how Portage works on a fundamental level until you start poking around with trying to script stuff for it. (Actually, I think that's a compliment to Portage since it does a great job of insulating the user from all the complex things it is doing.)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum