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:
Created attachment 43148 [details, diff] distfiles patch for portage.py 2.0.51-r2
for x in $(python -c "import portage; print portage.portdb.aux_get('$(equery which xfree)',["SRC_URI"])[0]"); do echo "file $(basename $x)"; done
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.
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.
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. ;)
Really need to add auxget to portage.