Fixes for run_command shell usage in remainder of packaging modules, save portinstall.
This commit is contained in:
parent
cb9059b250
commit
d4d87c420f
5 changed files with 13 additions and 10 deletions
|
@ -58,13 +58,13 @@ import json
|
|||
import shlex
|
||||
import os
|
||||
import sys
|
||||
|
||||
import pipes
|
||||
|
||||
def query_package(module, pkgin_path, name, state="present"):
|
||||
|
||||
if state == "present":
|
||||
|
||||
rc, out, err = module.run_command("%s -y list | grep ^%s" % (pkgin_path, name))
|
||||
rc, out, err = module.run_command("%s -y list | grep ^%s" % (pipes.quote(pkgin_path), pipes.quote(name)), use_unsafe_shell=True)
|
||||
|
||||
if rc == 0:
|
||||
# At least one package with a package name that starts with ``name``
|
||||
|
|
|
@ -58,13 +58,14 @@ pkgutil: name=CSWcommon state=present
|
|||
# Install a package from a specific repository
|
||||
pkgutil: name=CSWnrpe site='ftp://myinternal.repo/opencsw/kiel state=latest'
|
||||
'''
|
||||
|
||||
import os
|
||||
import pipes
|
||||
|
||||
def package_installed(module, name):
|
||||
cmd = [module.get_bin_path('pkginfo', True)]
|
||||
cmd.append('-q')
|
||||
cmd.append(name)
|
||||
#rc, out, err = module.run_command(' '.join(cmd), shell=False)
|
||||
rc, out, err = module.run_command(' '.join(cmd))
|
||||
if rc == 0:
|
||||
return True
|
||||
|
@ -73,12 +74,14 @@ def package_installed(module, name):
|
|||
|
||||
def package_latest(module, name, site):
|
||||
# Only supports one package
|
||||
name = pipes.quote(name)
|
||||
site = pipes.quote(site)
|
||||
cmd = [ 'pkgutil', '--single', '-c' ]
|
||||
if site is not None:
|
||||
cmd += [ '-t', site ]
|
||||
cmd.append(name)
|
||||
cmd += [ '| tail -1 | grep -v SAME' ]
|
||||
rc, out, err = module.run_command(' '.join(cmd))
|
||||
rc, out, err = module.run_command(' '.join(cmd), use_unsafe_shell=True)
|
||||
if rc == 1:
|
||||
return True
|
||||
else:
|
||||
|
|
|
@ -216,7 +216,6 @@ class Rhsm(RegistrationBase):
|
|||
if password:
|
||||
args.extend(['--password', password])
|
||||
|
||||
# Do the needful...
|
||||
rc, stderr, stdout = self.module.run_command(args, check_rc=True)
|
||||
|
||||
def unsubscribe(self):
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
# along with this software. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import re
|
||||
import pipes
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
|
@ -78,9 +79,9 @@ def query_package(module, name, depot=None):
|
|||
|
||||
cmd_list = '/usr/sbin/swlist -a revision -l product'
|
||||
if depot:
|
||||
rc, stdout, stderr = module.run_command("%s -s %s %s | grep %s" % (cmd_list, depot, name, name))
|
||||
rc, stdout, stderr = module.run_command("%s -s %s %s | grep %s" % (cmd_list, pipes.quote(depot), pipes.quote(name), pipes.quote(name)), use_unsafe_shell=True)
|
||||
else:
|
||||
rc, stdout, stderr = module.run_command("%s %s | grep %s" % (cmd_list, name, name))
|
||||
rc, stdout, stderr = module.run_command("%s %s | grep %s" % (cmd_list, pipes.quote(name), pipes.quote(name)), use_unsafe_shell=True)
|
||||
if rc == 0:
|
||||
version = re.sub("\s\s+|\t" , " ", stdout).strip().split()[1]
|
||||
else:
|
||||
|
|
|
@ -104,7 +104,7 @@ def query_package_provides(module, name):
|
|||
|
||||
# rpm -q returns 0 if the package is installed,
|
||||
# 1 if it is not installed
|
||||
cmd = "rpm -q --provides %s >/dev/null" % (name)
|
||||
cmd = "rpm -q --provides %s" % (name)
|
||||
rc, stdout, stderr = module.run_command(cmd, check_rc=False)
|
||||
return rc == 0
|
||||
|
||||
|
@ -125,7 +125,7 @@ def remove_packages(module, packages):
|
|||
if not query_package(module, package):
|
||||
continue
|
||||
|
||||
cmd = "%s --auto %s > /dev/null" % (URPME_PATH, package)
|
||||
cmd = "%s --auto %s" % (URPME_PATH, package)
|
||||
rc, stdout, stderr = module.run_command(cmd, check_rc=False)
|
||||
|
||||
if rc != 0:
|
||||
|
@ -158,7 +158,7 @@ def install_packages(module, pkgspec, force=True, no_suggests=True):
|
|||
else:
|
||||
force_yes = ''
|
||||
|
||||
cmd = ("%s --auto %s --quiet %s %s > /dev/null" % (URPMI_PATH, force_yes, no_suggests_yes, packages))
|
||||
cmd = ("%s --auto %s --quiet %s %s" % (URPMI_PATH, force_yes, no_suggests_yes, packages))
|
||||
|
||||
rc, out, err = module.run_command(cmd)
|
||||
|
||||
|
|
Loading…
Reference in a new issue