Bug 733165

Summary: reposync of rhn repositories ignores repoid specified
Product: Red Hat Enterprise Linux 6 Reporter: Steven Seed <Steven.Seed>
Component: yum-utilsAssignee: James Antill <james.antill>
Status: CLOSED DUPLICATE QA Contact: Red Hat Satellite QA List <satellite-qa-list>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.1   
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-08-25 15:04:53 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Description Steven Seed 2011-08-25 00:27:16 UTC
Description of problem:

reposync on RHEL6 behaves differently from RHEL5 when it comes to syncing rhn repositories. It seems that the repoid specified as a command line flag is ignored (at least with respect to rhn repos). In other words if I specify a repoid of rhel-x86_64-workstation-6, the rhn plugin will override this choice and enalbe all repos the host is subscribed to on rhn. The result is reposync transfers all repos in rhn that the host has a subscription for.

Version-Release number of selected component (if applicable):


How reproducible:

Steps to Reproduce:
1. register host with rhn (in this case RHEL Workstation 6)
2. run reposync command (/usr/bin/reposync -l -m -d -n -r rhel-x86_64-workstation-6 --download_path=/var/repo_mirror -a x86_64)
Actual results:
reposync syncs all repos including:

Expected results:
reposync should only sync rhel-x86_64-workstation-6

Additional info:

As far as I can tell this problem comes about in the reposync script (/usr/bin/reposyc) when it calls my.doRepoSetup (line 191) after it's gone and determined which repos to enable/disable (based on the repoid passed in). This call ultimately calls doSetup in repos.py (/usr/lib/python2.6/site-packages/yum/repos.py). The first line in this function is where the problem occurs because is calls 'prereposetup' in the rhnplugin:

    def doSetup(self, thisrepo = None):

        if thisrepo is None:
            repos = self.listEnabled()
            repos = self.findRepos(thisrepo)
In the above snippet, the prereposetup that is executed in the rhnplugin overwrites the enalbed rhn repos in the repo object with all the rhn repos currently subscribed. The result of self.listEnalbed() is changed after this point.

A workaround I've put in place, though I'm not sure of the fallout is to move the call to 'my.doRepoSetup()' in reposync before the section that enables/disables the repos. This way, it properly disables the repos after the rhnplugin enables them. Here is the snippet (starting at line 162):
    elif opts.cachedir:

    my.doRepoSetup()  ### New position of this call

    if len(opts.repoid) > 0:
        myrepos = []
        # find the ones we want
        for glob in opts.repoid:
        # disable them all
        for repo in my.repos.repos.values():
        # enable the ones we like
        for repo in myrepos:

    # --norepopath can only be sensibly used with a single repository:
    if len(my.repos.listEnabled()) > 1 and opts.norepopath:
        print >> sys.stderr, "Error: Can't use --norepopath with multiple repositories"

    # Use progress bar display when downloading repo metadata
    # and package files
    if not opts.quiet:


        arches = rpmUtils.arch.getArchList(opts.arch)

Comment 2 James Antill 2011-08-25 15:04:53 UTC
Yeh, it's already fixed for 6.2 ... basically the workaround you thought. I've also heard rumours that rhnplugin might be fixed as well.

*** This bug has been marked as a duplicate of bug 713108 ***

Comment 3 Steven Seed 2011-08-25 18:50:08 UTC
OK. Great. Thanks!