Richterrettich / rpm-rs

A pure rust library for building and parsing RPM's
Other
39 stars 18 forks source link

Support No Epoch #38

Closed JamesMc86 closed 2 years ago

JamesMc86 commented 3 years ago

I'm not familiar enough with RPMs to know how important this is but...

In a spec file build with rpmbuild you can omit epoch. With rpm-rs this defaults to zero which seems to be different from omitting it. This causes an inconsistency when migrating here.

drahnr commented 2 years ago

I had a brief look into this, and the upstream implementation is identical. Missing epoch values implicitly set to zero.

int rpmVersionCompare(Header first, Header second)
{
    /* Missing epoch becomes zero here, which is what we want */
    uint32_t epochOne = headerGetNumber(first, RPMTAG_EPOCH);
    uint32_t epochTwo = headerGetNumber(second, RPMTAG_EPOCH);
// snip
}

and

uint64_t headerGetNumber(Header h, rpmTagVal tag
{
    uint64_t res = 0;
    struct rpmtd_s td;

    if (headerGet(h, tag, &td, HEADERGET_EXT)) {
    if (rpmtdCount(&td) == 1) {
        res = rpmtdGetNumber(&td);
    }
    rpmtdFreeData(&td);
    }
    return res;
}
Richterrettich commented 2 years ago

As @drahnr said, this is how it works in the "reference" implementation, so we will keep the default 0 value.