Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 69805 - reading distfiles of a package in shell scripts
Summary: reading distfiles of a package in shell scripts
Status: RESOLVED LATER
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Enhancement/Feature Requests (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-02 00:34 UTC by Chr. Schaefer
Modified: 2007-01-11 14:02 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
distfiles patch for portage.py 2.0.51-r2 (portage.py.distfiles.diff,644 bytes, patch)
2004-11-02 00:36 UTC, Chr. Schaefer
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chr. Schaefer 2004-11-02 00:34:52 UTC
Hi,
I don't see a possibility to get the distfiles of a package for use in
shell scripts or simply to be informed what has been downloaded for a specific 
package. This could be used in scripts to delete or copy the distfiles. I use it
in my own "clean distfiles" script.

I patched portage.py (see attachement portage.py.distfiles.diff) to allow a 
new command "distfiles" to the ebuild script, allowing a command like

ebuild $(equery which xfree) distfiles

This will write all distfiles from the ebuild to standard output.

The patch is for portage-2.0.51-r2.

I would like to see this patch added to portage or another feature that allows 
the same functionality.

Best regards,
Christian.

Reproducible: Always
Steps to Reproduce:
Comment 1 Chr. Schaefer 2004-11-02 00:36:38 UTC
Created attachment 43148 [details, diff]
distfiles patch for portage.py 2.0.51-r2
Comment 2 Brian Harring (RETIRED) gentoo-dev 2004-11-02 00:39:24 UTC
for x in $(python -c "import portage; print portage.portdb.aux_get('$(equery which xfree)',["SRC_URI"])[0]"); do
echo "file $(basename $x)";
done
Comment 3 Brian Harring (RETIRED) gentoo-dev 2004-11-02 00:45:47 UTC
What you're after is a general command line tool for querying metadata about packages- at the moment, not much for it (the code dumped above will query the info you want).

Marking this as later since a tool for querying pkg info would be useful, just not high priority- added, really don't like tacking another phase into doebuild.
Comment 4 Chr. Schaefer 2004-11-02 01:51:54 UTC
Hi Brian,
thanks for providing the code. The difference to the patch is that SRC_URI doesn't get evaluated with your code, so I get things like

file truetype?
file (
file !bindist?
file (
file andale32.exe

What I'm looking for is a tool to extract such information while respecting 
current USE flag settings etc. I understand that this is not high priority and 
will possibly be easier to do when the portage API is done.
Comment 5 Jason Stubbs (RETIRED) gentoo-dev 2004-11-02 05:11:25 UTC
jason@localhost ~ $ echo -e 'import portage, portage_dep\nfor x in portage_dep.use_reduce(portage_dep.paren_reduce(portage.db["/"]["porttree"].dbapi.aux_get("sys-apps/portage-2.0.51-r2", ["SRC_URI"])[0]), portage.settings["USE"].split()):\n print x' | python
http://zarquon.twobit.net/gentoo/portage/portage-2.0.51-r2.tar.bz2
http://gentoo.twobit.net/portage/portage-2.0.51-r2.tar.bz2
mirror://gentoo/portage-2.0.51-r2.tar.bz2


or written more nicely:


#!/bin/bash

grab_distfiles() {

        pyfunc="
import portage, portage_dep

src_uri = portage.db[\"/\"][\"porttree\"].dbapi.aux_get(\"$1\", [\"SRC_URI\"])[0]
use_cfg = portage.settings[\"USE\"].split()
parsed = portage_dep.paren_reduce(src_uri)
processed = portage_dep.use_reduce(parsed, use_cfg)
for url in processed:
        print url
"

        echo "$pyfunc" | python
}

grab_distfiles "sys-apps/portage-2.0.51-r2"



This is not strictly supported, of course. There will be a better alternative later on though. ;)
Comment 6 Marius Mauch (RETIRED) gentoo-dev 2007-01-11 14:02:00 UTC
Really need to add auxget to portage.