[Yum] building plugin that simulates repository...

Dmitry Makovey dmitry at athabascau.ca
Thu Oct 13 21:03:30 UTC 2011


Hi James,

thanks for the reply! Some clarifications inline...

On Thursday, October 13, 2011, James Antill wrote:
> 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?

yep.

$ rpm -q yum
yum-3.2.22-26.el5

and after quick update to

3.2.22-37.el5

same picture...

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

BTW, full traceback is:

0 packages excluded due to repository protections
Traceback (most recent call last):
  File "/usr/bin/yum", line 29, in ?
    yummain.user_main(sys.argv[1:], exit_code=True)
  File "/usr/share/yum-cli/yummain.py", line 309, in user_main
    errcode = main(args)
  File "/usr/share/yum-cli/yummain.py", line 178, in main
    result, resultmsgs = base.doCommands()
  File "/usr/share/yum-cli/cli.py", line 345, in doCommands
    self._getTs(needTsRemove)
  File "/usr/lib/python2.4/site-packages/yum/depsolve.py", line 101, in _getTs
    self._getTsInfo(remove_only)
  File "/usr/lib/python2.4/site-packages/yum/depsolve.py", line 112, in 
_getTsInfo
    pkgSack = self.pkgSack
  File "/usr/lib/python2.4/site-packages/yum/__init__.py", line 662, in 
<lambda>
    pkgSack = property(fget=lambda self: self._getSacks(),
  File "/usr/lib/python2.4/site-packages/yum/__init__.py", line 517, in 
_getSacks
    self._pkgSack.buildIndexes()
  File "/usr/lib/python2.4/site-packages/yum/packageSack.py", line 385, in 
buildIndexes
    sack.buildIndexes()
  File "/usr/lib/python2.4/site-packages/yum/packageSack.py", line 711, in 
buildIndexes
    self._addPackageToIndex(obj)
  File "/usr/lib/python2.4/site-packages/yum/packageSack.py", line 741, in 
_addPackageToIndex
    self._addToDictAsList(self.pkgsByID, obj.id, obj)
  File "/usr/lib/python2.4/site-packages/yum/packages.py", line 1145, in 
__getattr__
    return self.hdr[thing]
KeyError: 'unknown header tag'

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

>  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"). CPacMan repos 
should be aggregated with cpacman_yum plugin and provide "unified" view even 
through packages themselves are sprinkled around the filesystem. In our use-
case we use Yum as an "engine" and we have several people attempting to run 
transactions at the same time (those push packages to remote machines rather 
than install locally) so temp files don't look as tempting ;) 

-- 
Dmitry Makovey
Web Systems Administrator
Athabasca University
(780) 675-6245
---
Confidence is what you have before you understand the problem
    Woody Allen

When in trouble when in doubt run in circles scream and shout 
     http://www.wordwizard.com/phpbb3/viewtopic.php?f=16&t=19330
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.baseurl.org/pipermail/yum/attachments/20111013/450b0264/attachment.asc>


More information about the Yum mailing list