Search the entire CACHE_DIR because storage paths change across versions

This commit is contained in:
Pablo Suárez Hernández 2017-04-18 16:04:14 +01:00
parent 92c655b94d
commit 47cb1e9495
2 changed files with 11 additions and 9 deletions

View File

@ -19,7 +19,6 @@ from __future__ import absolute_import
import contextlib
import copy
import fnmatch
import glob
import itertools
import logging
import os
@ -923,9 +922,11 @@ def list_downloaded():
CACHE_DIR = os.path.join('/var/cache/', _yum())
ret = {}
for package_path in glob.glob(os.path.join(CACHE_DIR, '*/*/*/packages/*.rpm')):
pkg_info = __salt__['lowpkg.bin_pkg_info'](package_path)
ret.setdefault(pkg_info['name'], {})[pkg_info['version']] = package_path
for root, dirnames, filenames in os.walk(CACHE_DIR):
for filename in fnmatch.filter(filenames, '*.rpm'):
package_path = os.path.join(root, filename)
pkg_info = __salt__['lowpkg.bin_pkg_info'](package_path)
ret.setdefault(pkg_info['name'], {})[pkg_info['version']] = package_path
return ret

View File

@ -15,7 +15,7 @@ Package support for openSUSE via the zypper package manager
# Import python libs
from __future__ import absolute_import
import copy
import glob
import fnmatch
import logging
import re
import os
@ -1794,10 +1794,11 @@ def list_downloaded():
CACHE_DIR = '/var/cache/zypp/packages/'
ret = {}
# Zypper storage is repository_tag/arch/package-version.rpm
for package_path in glob.glob(os.path.join(CACHE_DIR, '*/*/*.rpm')):
pkg_info = __salt__['lowpkg.bin_pkg_info'](package_path)
ret.setdefault(pkg_info['name'], {})[pkg_info['version']] = package_path
for root, dirnames, filenames in os.walk(CACHE_DIR):
for filename in fnmatch.filter(filenames, '*.rpm'):
package_path = os.path.join(root, filename)
pkg_info = __salt__['lowpkg.bin_pkg_info'](package_path)
ret.setdefault(pkg_info['name'], {})[pkg_info['version']] = package_path
return ret