[Yum] building plugin that simulates repository...

James Antill james-yum at and.org
Thu Oct 13 20:38:47 UTC 2011


Dmitry Makovey <dmitry at athabascau.ca> 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'

 This is RHEL-5 ... I assume you are using the latest yum in RHEL-5?

 Change the code to what is done upstream (gives the attribute name),
will help debugging a lot.

> What I'm trying to do is bridge CPacMan and Yum via plugin. CPacMan has it's 
> own concept of "repos" which could be local caches of Yum repos or just 
> directories with RPMs etc. What I want to do with this plugin is to wrap some 
> of those repos CPacMan has (based on certain criteria) and present them to Yum 
> as valid repos making operations of package install much more seamless etc. I 
> didn't want to create 1:1 relationship between CPacMan repo and Yum repo, I 
> also realize that is something that RedHat is already doing with RHN plugin. 
> However instead of trying to cut through the RH code I'd like to get some 
> clean sample of plugin generating dynamic repo "in-memory" rather than what 
> one of the examples shows - creating temp repo definition and pointing it to 
> the directory subsequently doing "createrepo" on it. 
>
> I'm attaching my (oversimplified) attempt of doing so, hoping that somebody 
> can point me at missing bits and pieces (or maybe point me in the right 
> direction?). I intentionally removed most of the CPacMan logic to make it more 
> yum-specific excercise (full, and "ugly" version of it is here: 
> http://cpacman.svn.sourceforge.net/viewvc/cpacman/cpacman-
> yum/trunk/cpacman_yum.py?revision=238&view=markup )


 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.

 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).

-- 
James Antill -- james at and.org


More information about the Yum mailing list