building plugin that simulates repository...

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

 



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'

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 )

Any help is highly appreciated. 

-- 
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
class CPacManSack(PackageSack):
    def __init__(self):
        PackageSack.__init__(self)

    def populate(self, repo, mdtype='metadata', callback=None, cacheonly=0):
        # looks like this one is not needed in our case - we are loading entire sack manually
        print "In CPacMan Populate"

    def get_added(self):
        """what does this one do???"""
	return []

    added=property(get_added)

class CPacManRepo(YumRepository):
    """CPacMan repo that translates from collects all of the available packages into 
    a neat Yum-like Repo object"""
    def __init__(self,server_name):
        YumRepository.__init__(self,'cpacman')
        self.cpacman_sack=CPacManSack()
        self.__init_sack()
        
    def __init_sack(self):
        global server
        pl=server.listAvailablePackages(all_versions=0, ignore_policy=0)
        ts=rpm.TransactionSet()
        # hack to disable DIGEST and SIGNATURE checks for now
        ts.setVSFlags((rpm._RPMVSF_NOSIGNATURES|rpm._RPMVSF_NODIGESTS))
        for pk in pl.keys():
            pkg=pl[pk]
            localpath=os.path.join(pkg['path'],pkg['package_name'])

            try:
                hdr = rpmUtils.miscutils.hdrFromPackage(ts, localpath)
            except rpmUtils.RpmUtilsError:
                raise yum.Errors.MiscError, \
                    'Could not open local rpm file: %s' % localpath
            ypkg=YumHeaderPackage(self, hdr)
            ypkg._populatePrco()
            self.cpacman_sack.addPackage(ypkg)

    def getPackageSack(self):
        print "---> somebody wants to see my sack?"
        return self.cpacman_sack


def prereposetup_hook(conduit):
    print "adding CPacMan repo"
    repos=conduit.getRepos()
    repos.add(CPacManRepo(conf.servername))
    repos.enableRepo('cpacman')

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
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