[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#458910: debian-policy: Policy and dpkg disagree on debian revision tests.



Hi,

On Thu, 03 Jan 2008, Matthew Johnson wrote:
> Policy 5.6.12 states:
> 
>    The absence of a debian_revision compares earlier than the presence
>    of one
> 
> However, dpkg tests return:
> 
>    dpkg --compare-versions 1 eq 1-0 && echo equal
>    equal

I confirm that the implementation in dpkg is done in such a way that the
lack of revision is the same than a revision set to "0".
Exactly like the lack of epoch is equal to an epoch of 0.

Maybe we should say "the absence of a debian_revision compares earlier
than the presence of a non-empty non-null one".


In the perl code we use:
sub parseversion ($)
{
    my $ver = shift;
    my %verhash;
    if ($ver =~ /:/)
    {
        $ver =~ /^(\d+):(.+)/ or die "bad version number '$ver'";
        $verhash{epoch} = $1;
        $ver = $2;
    }
    else
    {
        $verhash{epoch} = 0;
    }
    if ($ver =~ /(.+)-(.+)$/)
    {
        $verhash{version} = $1;
        $verhash{revision} = $2;
    }
    else
    {
        $verhash{version} = $ver;
        $verhash{revision} = 0;
    }
    return %verhash;
}


The C code handles this differently and uses an empty string for the
lack of revision... however when it compares revision between them, it
skips any leading "0" and thus considers "0" as equal to the empty string.

Cheers,
-- 
Raphaël Hertzog

Le best-seller français mis à jour pour Debian Etch :
http://www.ouaza.com/livre/admin-debian/


Reply to: