Bug#560058: [buildd-tools-devel] Bug#560058: quinn-diff: should support architecture wildcards
On Tuesday 09 February 2010 13:41:43 Philipp Kern wrote:
> On Fri, Feb 05, 2010 at 01:25:21AM -0500, Andres Mejia wrote:
> > > We have some cases where we don't want that behaviour, see the patches
> > > to parse_sources.c for that.
> >
> > Ok. Makes sense.
>
> Actually it doesn't. When I check any against an architecture I want the
> behaviour that it matches e.g. "linux-any" but not, say, "s390". Could you
> look if you could fix that based on the current dpkg-perl branch?
> Currently I'm calling in_arch_list_verbatim for "all", which sounds sane,
> but also for "any" which needs fixing.
>
> Kind regards,
> Philipp Kern
>
The Dpkg::Arch function debarch_is() takes the first parameter as the
architecture and the second parameter as the alias (wildcard). So using an
alias of "any" will always match true, regardless of what architecture is set,
such as "s390". Also, trying to match "any" against "linux-any" will fail via
debarch_is(), since it won't recognize "linux-any" as an architecture. This is
the behavior you should expect.
By the way, I'm attaching a patch against the dpkg-perl branch that fixes the
ordering of the parameters to debarch_is(). I've also optimized the
arch_equivalent() function when use_equivalence is set to true. Now all
aliases of "any" and "all" return true and skip running the Perl code
entirely. Setting the alias to "any" would always return true from
debarch_is() anyway, and debarch_is() doesn't recognize "all" as an alias,
though "all" should always return true as well.
This brought a substantial increase in performance from the "time" runs,
though it's still slower than not using dpkg-perl. I've attached a log of with
different runs through "time". I've marked what build options I used. The
Packages, Sources, and Packages-arch-specific file were the same as last time.
--
Regards,
Andres
diff --git a/src/utils.c b/src/utils.c
index 866b79e..d801d62 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -311,11 +311,16 @@ arch_equivalent(const char *arch1, const char* arch2, boolean use_equivalence)
#ifdef DPKG_PERL
if(use_equivalence) {
boolean result = FALSE;
+ /* Skip running the Perl code entirely when the alias is "any" or "all".
+ * These should always return true anyway.
+ */
+ if ((strcmp(arch1,"any") == 0) || (strcmp(arch1,"all") == 0))
+ return TRUE;
/* We check the scalar value (which is an integer) returned from the
* debarch_is() subroutine.
*/
- char* perl_code = g_strdup_printf("debarch_is(\"%s\", \"%s\")", arch1, arch2);
+ char* perl_code = g_strdup_printf("debarch_is(\"%s\", \"%s\")", arch2, arch1);
if(SvIVx(eval_pv(perl_code, TRUE)))
result = TRUE;
# Without dpkg-perl "./configure && make"
$ time quinn-diff/src/quinn-diff -a Packages-arch-specific -p Packages-amd64 -s Sources
real 0m0.346s
user 0m0.296s
sys 0m0.048s
real 0m0.347s
user 0m0.316s
sys 0m0.040s
real 0m0.345s
user 0m0.308s
sys 0m0.040s
real 0m0.347s
user 0m0.304s
sys 0m0.036s
real 0m0.351s
user 0m0.308s
sys 0m0.048s
# With dpkg-perl "./configure --with-dpkg-perl && make"
$ time quinn-diff/src/quinn-diff -a Packages-arch-specific -p Packages-amd64 -s Sources
real 0m0.464s
user 0m0.416s
sys 0m0.048s
real 0m0.467s
user 0m0.424s
sys 0m0.040s
real 0m0.462s
user 0m0.416s
sys 0m0.044s
real 0m0.464s
user 0m0.432s
sys 0m0.032s
real 0m0.467s
user 0m0.424s
sys 0m0.040s
Reply to: