2011/1/20 Jeff Johnson <n3...@mac.com>: > > On Jan 19, 2011, at 7:45 AM, Per Øyvind Karlsen wrote: > >> For RPMTAG_NVRA to expand to using%{___NVRA}, I found myself >> having to modify hGetNevra(). >> > > Why did you have to modify? > > While this setting is a huge mess, its _IS_ adequate to compose > an "identification" string based on other tag data: > > %___NVRA > %%{NAME}-%%{VERSION}-%%{RELEASE}%%|DISTTAG?{-%%{DISTTAG}%%|DISTEPOCH?{%%{DISTEPOCH}}|}|%%|ARCH?{.%%|SOURCERPM?{%%{ARCH}}:{src}|}:{}| > > I fail to understand why changes to hGetNevra() method are _ALSO_ needed. > >> To make dbiFindMatches() to match -%{disttag}%{distepoch}, I changed >> _post_NVRA to: >> >> static const char _post_NVRA[] = >> "(-[^-]+-[^-]+-[^-]+\\.[^.]+|-[^-]+-[^-]+\\.[^.]+|-[^-]+\\.[^.]+|\\.[^.]+|)$"; >> >> This expression gets too greedy for packages with '-' in the name and >> without disttag/distepoch though.. >> > > Yes _post_NVRA MUST be able to parse through variant (like N.A or N-V.A) forms > using a pattern. > > If you can't write a pattern (usually as a tail anchor'es *RE, the usual > parsing rule is that the last 2 '-' characters are GUARANTEED to surround V) > for NVRA strings that include Disttag/Distepoch, well, you are likely screwed. > >> ie. 'rpm -q foo' might return: >> foo-1-1-mdv2011.0.x86_64 >> foo-bar-1-1mdv2011.0.x86_64 >> > > > Yep. Can't tell what's what because the syntax isn't predictable. One workaround could be something like this: if(keyp[0] != '^') { Header h; while((h = rpmmiNext(mi)) { he->tag = RPMTAG_NAME; if(headerGet(h, he, 0)) if(strlen(keyp) < strlen(he->p.str)) rpmmiPrune(mi,...); }
This would remove the matches that has a name longer than the package queried for. Might not make immediate sense, I'll take a closer look tomorrow, bedtime now. :) -- Regards, Per Øyvind ______________________________________________________________________ RPM Package Manager http://rpm5.org Developer Communication List rpm-devel@rpm5.org