I've been playing around with the emerge script, specifically looking to use the features that are included in the script, such as the package depgraph creation In the emerge script itself there is a depgraph class which does this with relative accuracy (as it is able to use the empty-tree option) in the past with an older portage, NOTE: MUCH OLDER PORTAGE, i was able to import the emerge script and use it like a normal python class, which doesn't work in python: (import imp; imp.load_source('emerge', '/usr/lib/portage/bin/emerge') ) which allowed this behaviour. I was wondering if the depgraph creation should be moved into the portage so that 3rd party tools can also make use of the depgraph generator emerge uses, or would this be a silly request? Thanks
Yes it should be moved out of the emerge.. patches welcome!
Ideally, the bulk of the code in emerge would be accessible via the portage api. We just haven't gotten around to cleaning it all up yet. Last year I refactored emerge from the (new dead) 2.1-experimental branch: http://dev.gentoo.org/~zmedico/portage/branches/2.1-experimental/bin/emerge I've been thinking about doing it again for current 2.1 and then migrating pieces into the portage api.
Created attachment 89319 [details, diff] Proposed patch patch against: # emerge -V Portage 2.1 (default-linux/amd64/2006.0, gcc-3.4.4, glibc-2.3.5-r2, 2.6.16-gentoo-r9 x86_64) This is my first-attempt, it works as far as i've tested (which isn't much, cause my linux is broken) Hope more can be stripped from emerge in the future!
Created attachment 89325 [details, diff] Proposed solution 2 Ok, after much testing breaking and finally getting things to emerge (like pychecker), and finally running pychecker, i've discovered a few fucntions and classes that depgraph relies on! Emerge needs a bot more refactoring work before this class can be set free, but the basics of pulling it out are here (hopefully) Also had a bit of a mission finding "syslist" which seems to only be defined in special cases, pulling it out might have broken other features of emerge which i have not been able to test, also myopts and myparams seem to be used throughout the script and are NOT passed to the depgraph object, the few cases have been make to use an internal representation of it (self.myparams and self.myopts), myfavorites is also a problem here, because it's also only created in certain cases! I think i need to find a few portage Devs to help unravel these objects
*** Bug 79288 has been marked as a duplicate of this bug. ***