From 364536a76ef4a3626bbcef3b45effa1bdcb6ce5a Mon Sep 17 00:00:00 2001 From: Zoltan Kozma Date: Wed, 20 May 2015 19:46:39 +0100 Subject: [PATCH] - Fixed annoying bug that disablerepo was essentially broken if a package needed updating by state latest. - Replaced some unsafe practice with default parameters. However looking at the code this does not seem to matter much as the calling functions always seem to supply these parameters anyway. --- packaging/os/yum.py | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/packaging/os/yum.py b/packaging/os/yum.py index a8b996c84de..ac183641a30 100644 --- a/packaging/os/yum.py +++ b/packaging/os/yum.py @@ -26,6 +26,7 @@ import traceback import os import yum import rpm +import syslog try: from yum.misc import find_unfinished_transactions, find_ts_remaining @@ -153,8 +154,6 @@ if not os.path.exists(repoquery): yumbin='/usr/bin/yum' -import syslog - def log(msg): syslog.openlog('ansible-yum', 0, syslog.LOG_USER) syslog.syslog(syslog.LOG_NOTICE, msg) @@ -186,8 +185,11 @@ def po_to_nevra(po): else: return '%s-%s-%s.%s' % (po.name, po.version, po.release, po.arch) -def is_installed(module, repoq, pkgspec, conf_file, qf=def_qf, en_repos=[], dis_repos=[], is_pkg=False): - +def is_installed(module, repoq, pkgspec, conf_file, qf=def_qf, en_repos=None, dis_repos=None, is_pkg=False): + if en_repos is None: + en_repos = [] + if dis_repos is None: + dis_repos = [] if not repoq: pkgs = [] @@ -225,7 +227,11 @@ def is_installed(module, repoq, pkgspec, conf_file, qf=def_qf, en_repos=[], dis_ return [] -def is_available(module, repoq, pkgspec, conf_file, qf=def_qf, en_repos=[], dis_repos=[]): +def is_available(module, repoq, pkgspec, conf_file, qf=def_qf, en_repos=None, dis_repos=None): + if en_repos is None: + en_repos = [] + if dis_repos is None: + dis_repos = [] if not repoq: @@ -262,10 +268,13 @@ def is_available(module, repoq, pkgspec, conf_file, qf=def_qf, en_repos=[], dis_ else: module.fail_json(msg='Error from repoquery: %s: %s' % (cmd, err)) - return [] -def is_update(module, repoq, pkgspec, conf_file, qf=def_qf, en_repos=[], dis_repos=[]): +def is_update(module, repoq, pkgspec, conf_file, qf=def_qf, en_repos=None, dis_repos=None): + if en_repos is None: + en_repos = [] + if dis_repos is None: + dis_repos = [] if not repoq: @@ -312,7 +321,11 @@ def is_update(module, repoq, pkgspec, conf_file, qf=def_qf, en_repos=[], dis_rep return [] -def what_provides(module, repoq, req_spec, conf_file, qf=def_qf, en_repos=[], dis_repos=[]): +def what_provides(module, repoq, req_spec, conf_file, qf=def_qf, en_repos=None, dis_repos=None): + if en_repos is None: + en_repos = [] + if dis_repos is None: + dis_repos = [] if not repoq: @@ -683,7 +696,7 @@ def latest(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos): nothing_to_do = False break - if basecmd == 'update' and is_update(module, repoq, this, conf_file, en_repos=en_repos, dis_repos=en_repos): + if basecmd == 'update' and is_update(module, repoq, this, conf_file, en_repos=en_repos, dis_repos=dis_repos): nothing_to_do = False break