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

Re: python-apt create_pin question



On 1/17/22 02:54, Michael Lange wrote:
(...)
> 
> So maybe this argument is case sensitive and changing "origin" into
> "Origin" may fix the issue?
> 

Hello Michael,

Thanks for the suggestion.  Unfortunately it does not work.  I had actually
dug into the source a tiny bit before posting:

Unlike the file parsing interface (ReadPinfile) in libapt, which performs a
case-insensitive compare, the Python interface to CreatePin checks for
either "Origin" or "origin":

static PyObject *policy_create_pin(PyObject *self, PyObject *args) {
    pkgVersionMatch::MatchType match_type;
    const char *type, *pkg, *data;
    signed short priority;
    if (PyArg_ParseTuple(args, "sssh", &type, &pkg, &data, &priority) == 0)
        return 0;
    pkgPolicy *policy = GetCpp<pkgPolicy *>(self);
    if (strcmp(type,"Version") == 0 || strcmp(type, "version") == 0)
        match_type = pkgVersionMatch::Version;
    else if (strcmp(type,"Release") == 0 || strcmp(type, "release") == 0)
        match_type = pkgVersionMatch::Release;
    else if (strcmp(type,"Origin") == 0 || strcmp(type, "origin") == 0)
        match_type = pkgVersionMatch::Origin;
    else
        match_type = pkgVersionMatch::None;
    policy->CreatePin(match_type,pkg,data,priority);
    HandleErrors();
    Py_RETURN_NONE;
}

Direct re-testing also fails.

Best,
Antonio

> Best regards
> 
> Michael


Reply to: