Re: building plugin that simulates repository...

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

 



Dmitry Makovey <dmitry@xxxxxxxxxxxxx> writes:

> Hi James,
>
> thanks for the reply! Some clarifications inline...
>
> On Thursday, October 13, 2011, James Antill wrote:
>> Dmitry Makovey <dmitry@xxxxxxxxxxxxx> writes:
>> > Hi,
>> > 
>> > I'm trying to build a plugin that would dynamically "inject" local
>> > "repositories" (which are nothing more than collections of RPM files) but
>> > I keep on bumping into problems. Latest one is:
>> > 
>> > File "/usr/lib/python2.4/site-packages/yum/packages.py", line 1145, in
>> > __getattr__
>> > 
>> >     return self.hdr[thing]
>> > 
>> > KeyError: 'unknown header tag'
[...]
>>  Change the code to what is done upstream (gives the attribute name),
>> will help debugging a lot. 
>
> you got me there. What do you mean? So far I'm stuck trying to figure out what 
> the hdr['tag'] should include - from what I've seen _populatePrco() is 
> supposed to do exactly that, but apparently it doesn't. 

 This is __getattr__ from current upstream:

    def __getattr__(self, thing):
        #FIXME - if an error - return AttributeError, not KeyError 
        # ONLY FIX THIS AFTER THE API BREAK
        if thing.startswith('__') and thing.endswith('__'):
            # If these existed, then we wouldn't get here ...
            # So these are missing.
            raise AttributeError, "%s has no attribute %s" % (self, thing)
        try:
            return self.hdr[thing]
        except KeyError:
            #  Note above, API break to fix this ... this at least is a nicer
            # msg. so we know what we accessed that is bad.
            raise KeyError, "%s has no attribute %s" % (self, thing)
        except ValueError:
            #  Note above, API break to fix this ... this at least is a nicer
            # msg. so we know what we accessed that is bad.
            raise ValueError, "%s has no attribute %s" % (self, thing)

[...]
>   File "/usr/lib/python2.4/site-packages/yum/packages.py", line 1145, in 
> __getattr__
>     return self.hdr[thing]
> KeyError: 'unknown header tag'

...which will at least tell you what 'thing' is here, which should
give some idea about why it can't find it.

>>  The attached code looks like it should work (just creating a normal
>> PackageSack() out of YumLocalPackages(), AIUI). So you should be able
>> to debug it and have it work ... and I'd thought about adding
>> something like that to core yum too, for a few reasons, so parts of it
>> could go upstream.
>
> thus the intent to go as "generic" as I can get away with. 

 *nods*

>>  However if you don't need to squeeze every last bit of speed out of
>> it, look at what the tmprepo plugin does and just do that (I'm
>> assuming it the tmprepo way isn't _much_ slower).
>
> tmprepo is where I've got the "inspiration" but turned out it was creating 
> temp files on a disk (in other words being a bit "hackish").

 Yeh, it's not great (relies on createrepo etc.) ... but it works. If
you create a real "dir. repo" then it'd probably move to using that
pretty quickly :)

-- 
James Antill -- james@xxxxxxx
_______________________________________________
Yum mailing list
Yum@xxxxxxxxxxxxxxxxx
http://lists.baseurl.org/mailman/listinfo/yum


[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux