Gentoo Archives: gentoo-portage-dev

From: Jason Stubbs <jstubbs@g.o>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] Portage API
Date: Mon, 18 Oct 2004 13:51:33
Message-Id: 200410182253.44450.jstubbs@gentoo.org
In Reply to: Re: [gentoo-portage-dev] Portage API by Brian
1 On Monday 18 October 2004 01:25, Brian wrote:
2 > Dan has been the porthole developer that has done the most integrating
3 > portage modules for porthole's use, but it looks like we are loosing him
4 > from gentoo for now.
5
6 Yeah, I saw that..
7
8 > I have not had much reason to think about how much more we might need from
9 > portage.
10
11 I'm more interested in what you are already using and more importantly why.
12 Whatever the API ends up being, it'll probably resemble portage's current API
13 very little.
14
15 I'll try to ascertain the why's from the what's that you've listed. Let me
16 know if I get any wrong.
17
18 > portage.grabfile():: used for obtaining [keywords.desc, use.desc,
19 > use.local.desc]
20
21 Descriptions of USE flags. (I don't know what keywords.desc is.)
22
23 > portage.config(clone=portage.settings).environ()[var] :: where var = 1 of
24 > ['PORTDIR_OVERLAY','PORTDIR', "USE"]
25
26 The current USE settings. I'm don't see why PORTDIR or PORTDIR_OVERLAY is
27 needed.
28
29 > portage.auxdbkeys
30
31 I'm not sure what's required here either.
32
33 > """Extract installed versions from full name."""
34 > return portage.db['/']['vartree'].dep_match(full_name)
35
36 Querying the installed package database.
37
38 > portage.db['/']['porttree'].getallnodes()
39
40 Querying the ebuild package database.
41
42 > portage.db['/']['vartree'].getallnodes()
43
44 As above.
45
46 > portage.catpkgsplit(ebuild)
47
48 Not sure why this is needed.
49
50 > portage.portdb.aux_get(ebuild, [property])[0]
51
52 Querying individual packages.
53
54 > portage.best(versions)
55
56 Package version comparison.
57
58 > # showing complete porthole function for (possibly) more clarity
59 > def get_properties(ebuild):
60 > """Get all ebuild variables in one chunk."""
61 > return Properties(dict(zip(keys,
62 > portage.portdb.aux_get(ebuild,
63 > portage.auxdbkeys))))
64 >
65 >
66 > def get_versions(self, include_masked = True):
67 > """Returns all versions of the available ebuild"""
68 > # Note: this slow, especially when include_masked is false
69 > criterion = include_masked and 'match-all' or 'match-visible'
70 > return portage.portdb.xmatch(criterion, self.full_name)
71
72 I think these are both covered above.
73
74 > Wish list:
75 >
76 > Portages version comparison/handling code from bug:
77 > http://bugs.gentoo.org/show_bug.cgi?id=37406 was would be implemented soon.
78 > I see browsing thru 2.0.51_rc9 that it is not yet implemented. If it is
79 > being implemented Porthole should use the following from portage's code:
80 >
81 > ver_regexp =
82 > re.compile("^(cvs-)?(\\d+)((\\.\\d+)*)([a-zA-Z]?)((_(pre|p|beta|alpha|rc)\\
83 >d*)*)(-r(\\d+))?$") suffix_regexp =
84 > re.compile("^(alpha|beta|rc|pre|p)(\\d*)$")
85 > # modified portage comparison suffix values for sorting in desired
86 > precedence suffix_value = {"alpha": '0', "beta": '1', "pre": '2', "rc":
87 > '3', "p": '4'}
88
89 This is covered above with version comparison.
90
91 > That would allow porthole's modified version of that code to follow any
92 > changes in portage's values.
93
94 I strongly recommend against doing any of this sort of stuff manually. I know
95 that there isn't really much choice at the moment, but that's exactly what
96 we're trying to get away from.
97
98 I believe porthole also makes a lot of use of emerge. If possible, please let
99 me know what options it is called with and what output is parsed.
100
101 Regards,
102 Jason Stubbs
103
104 --
105 gentoo-portage-dev@g.o mailing list

Replies

Subject Author
Re: [gentoo-portage-dev] Portage API Brian <dol-sen@×××××.net>
Re: [gentoo-portage-dev] Portage API Brian <dol-sen@×××××.net>