Gentoo Archives: gentoo-dev

From: Andrew Gaffney <agaffney@×××××××××××.com>
To: Jason Stubbs <jstubbs@g.o>
Cc: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] question regarding inherit
Date: Fri, 04 Jun 2004 00:15:48
Message-Id: 40BFBD92.5090103@skylineaero.com
In Reply to: Re: [gentoo-dev] question regarding inherit by Jason Stubbs
1 Jason Stubbs wrote:
2 > On Friday 04 June 2004 08:49, Andrew Gaffney wrote:
3 >
4 >>>Jason Stubbs wrote:
5 >>>
6 >>>>On Friday 04 June 2004 03:53, foser wrote:
7 >>>>
8 >>>>>>On Thu, 2004-06-03 at 19:41 +0200, Marius Mauch wrote:
9 >>>>>>
10 >>>>>>>On 06/03/04 Aron Griffis wrote:
11 >>>>>>>
12 >>>>>>>>I'm under the impression that this is bad. Could somebody please
13 >>>>>>>>verify and explain for the sake of people on this list. This
14 >>>>>>>>particular example appears in the libxslt ebuilds, but the kde ebuilds
15 >>>>>>>>make use of a similar syntax:
16 >>>>>>>>
17 >>>>>>>> use python && inherit python
18 >>>>>>>
19 >>>>>>>Bad because it breaks the cache. Depending on the status of the python
20 >>>>>>>flag *on the rsync master* the cache settings are or are not modified
21 >>>>>>>by the python.eclass and could be completely different from the values
22 >>>>>>>the cache should have for the user. That's also the case for other
23 >>>>>>>cache variables like DEPEND, SRC_URI or SLOT, if you make them
24 >>>>>>>conditional on the environment it's likely that the cache values are
25 >>>>>>>wrong for some people.
26 >>>>>>
27 >>>>>>The problem is that it shouldn't be a problem to do things like this,
28 >>>>>>it's portage that makes it problematic. It is not obvious why this is
29 >>>>>>problematic, so situations like these are going to pop up time and time
30 >>>>>>again. In my opinion this need to be fixed in portage, not necessarily
31 >>>>>>in the ebuilds/eclasses. And yeah, i'm talking here without any
32 >>>>>>knowledge of portage cache handling, ideal world type of talk.
33 >>>>
34 >>>>Three options:
35 >>>>
36 >>>>1) Drop portage caching altogether.
37 >>>>2) Separate the global section into a separate non-bash file with new
38 >>>>syntax. 3) Make everything constant in the global section of ebuilds.
39 >>>>
40 >>>>#1 is definately not acceptable at this stage as dep calculation time
41 >>>>would take about 50 times as long. #2 is probably the best but offers no
42 >>>>short term solution. Which leaves #3.
43 >>>
44 >>>In the Perl Portage clone I was working on, I originally didn't use caching
45 >>>and it could generate a (mostly) correct deptree for xfree faster than
46 >>>Portage could. Adding support for Portage's cache only shaved off about .2
47 >>>seconds.
48 >
49 > That's worth investigating then. Perhaps the bulk of the time when doing deps
50 > without a cache is the actual creation of the cache... It doesn't sit right
51 > with me, though. I'll look into it further.
52
53 Instead of calling bash to parse ebuilds, I wrote a subroutine that does
54 bash-style variable interpolation with the ebuilds. It doesn't take 'inherit'
55 into account, but that could be fixed easily enough.
56
57 sub get_ebuild_info {
58 my $pkgname = shift;
59 my $pkg = parse_package_name($pkgname);
60 my @fieldnames = ('DEPEND', 'RDEPEND', 'SLOT', 'SRC_URI', 'RESTRICT',
61 'HOMEPAGE', 'LICENSE', 'DESCRIPTION', 'KEYWORDS', 'INHERITS', 'IUSE', 'CDEPEND',
62 'PDEPEND');
63 my %ebuildinfo;
64
65 return $pkginfo{$pkgname} if(exists $pkginfo{$pkgname});
66 my $cachefname =
67 "/var/cache/edb/dep/$pkg->{category}/$pkg->{name}$pkg->{version}$pkg->{suffix}$pkg->{revision}";
68 if(! -e $cachefname) {
69 my $ebuildcontents;
70 my %ebuildvars;
71 my $ebuildfname;
72
73 my $pkg = parse_package_name($pkgname);
74 $ebuildfname =
75 "/usr/portage/$pkg->{category}/$pkg->{name}/$pkg->{name}$pkg->{version}$pkg->{suffix}$pkg->{revision}.ebuild";
76 $pkg->{version} =~ s/^-//;
77 $ebuildvars{PV} = "$pkg->{version}$pkg->{suffix}";
78
79 open EBUILD, "< $ebuildfname" or die "Couldn't open '$ebuildfname' to get
80 DEPEND\n";
81 while(<EBUILD>) {
82 if(/^\s*if\s*/ || /^\s*#/) {
83 next;
84 }
85 if(/^\s*\w+\(\)\s*{\s*$/) {
86 last;
87 }
88 $ebuildcontents .= $_;
89 }
90 close EBUILD;
91
92 while($ebuildcontents =~ /\b([-A-Z0-9_]+)\s*=\s*\"(.*?)\"/sgc) {
93 my ($varname, $varvalue) = ($1, $2);
94 $varvalue =~ s/\$\{?(\w+)\}?/$ebuildvars{$1}/gs;
95 $ebuildvars{$varname} = $varvalue;
96 }
97
98 my $depend = $ebuildvars{'DEPEND'} || '';
99 $depend .= " $ebuildvars{'RDEPEND'}" if(defined $ebuildvars{'RDEPEND'});
100 $depend =~ s/(\s+|\n+)/ /gs;
101
102 foreach(@fieldnames) {
103 $ebuildinfo{$_} = $ebuildvars{$_};
104 }
105 } else {
106 open DEPCACHE, "< $cachefname" or return undef; #die "Can't open
107 '$cachefname'\n";
108 foreach(@fieldnames) {
109 my $temp = <DEPCACHE>;
110 chomp $temp;
111 $ebuildinfo{$_} = $temp;
112 }
113 close DEPCACHE;
114 }
115
116 return \%ebuildinfo;
117 }
118
119 --
120 Andrew Gaffney
121 Network Administrator
122 Skyline Aeronautics, LLC.
123 636-357-1548
124
125
126 --
127 gentoo-dev@g.o mailing list

Replies

Subject Author
Re: [gentoo-dev] question regarding inherit Paul de Vrieze <pauldv@g.o>