Bug 984182

Summary: command-not-found does not work after renaming zypp repository
Product: [openSUSE] openSUSE Distribution Reporter: Petr Tesařík <ptesarik>
Component: OtherAssignee: Bernhard Wiedemann <bwiedemann>
Status: RESOLVED DUPLICATE QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: ma
Version: Leap 42.1   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: L3 Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Petr Tesařík 2016-06-10 14:02:01 UTC
The command-not-found script stopped working on my system. After some time I tracked it down to scout. It's caused by this code in /usr/lib/python2.7/site-packages/scout/bin.py:

    etcpath  = '/etc/zypp/repos.d'
    solvfile = '/var/cache/zypp/solv/%s/solv'
    # path regular expression for binary paths
    pathre   = '^/(bin|sbin|usr/bin|usr/sbin|usr/games|opt/kde3/bin|opt/kde3/sbin|opt/gnome/bin|opt/gnome/sbin)/'

    def __init__(self):
        self.pool = solv.Pool()
        self.parser = SafeConfigParser()

        for repofile in [ f for f in os.listdir(self.etcpath) if fnmatch(f, '*.repo') ]:
            try:
                name = os.path.splitext(repofile)[0]
                self.parser.read( '%s/%s' % (self.etcpath, repofile) )
                if self.parser.get(name, 'enabled') == '1':
                    repo = self.pool.add_repo(name)
                    repo.add_solv(self.solvfile % name)
            except:
                pass

IIUC it assumes that subdirectories under /var/cache/zypp/solv have the same names as files under /etc/zypp/repos.d. This is not the case on my system after renaming the repository with "zypper nr" - the files under /etc/zypp/repos.d keep the old name, but the subdirectories of /var/cache/zypp/solv are renamed.

I'm not sure if zypper should rename the repo files, or scout should use a different algorithm to search for sat-solver files, so I assigned the bug to Bernhard (for scout), but I've also added Michael to Cc (for zypper/libzypp).
Comment 1 Michael Andres 2016-06-13 07:55:39 UTC
> ...assumes that subdirectories under /var/cache/zypp/solv have 
> the same names as files under /etc/zypp/repos.d...

That's a Wrong assumption. A single .repo file may even contain mutiple repo  definitions, so it's file name can not refer to any repo data.

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