Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use -q instead of -qa when calling rpm #270

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions tools/packaging/cpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,26 +69,27 @@ def _perror(e):
sys.exit(e.returncode)


def exec_subprocess_call(cmd, cwd, showCMD=False):
def exec_subprocess(cmd, cwd, showCMD, mustSucceed=False):
if showCMD: print(cmd)
cmd = _convert_subprocess_cmd(cmd)
try:
subprocess.check_call(cmd, cwd=cwd, shell=False,
stdin=subprocess.PIPE, stdout=None, stderr=subprocess.STDOUT)
output = subprocess.check_output(cmd, cwd=cwd, shell=False,
stdin=subprocess.PIPE, stderr=subprocess.STDOUT)
return (0, output)
except subprocess.CalledProcessError as e:
_perror(e)
if mustSucceed:
_perror(e)
return (e.returncode, e.output)


def exec_subprocess_check_output(cmd, cwd):
cmd = _convert_subprocess_cmd(cmd)
out = ''
try:
out = subprocess.check_output(cmd, cwd=cwd, shell=False,
stdin=subprocess.PIPE, stderr=subprocess.STDOUT).decode('utf-8')
except subprocess.CalledProcessError as e:
_perror(e)
finally:
return out
def exec_subprocess_call(cmd, cwd, showCMD=False):
exec_subprocess(cmd, cwd, showCMD, mustSucceed=True)

def exec_subprocess_check_output(cmd, cwd, showCMD=False):
return exec_subprocess(cmd, cwd, showCMD, mustSucceed=True)[1]

def exec_subprocess_check_return_code(cmd, cwd, showCMD=False):
return exec_subprocess(cmd, cwd, showCMD)[0]

def travis_fold_start(tag):
if os.environ.get('TRAVIS_BUILD_DIR', None):
Expand Down Expand Up @@ -1012,7 +1013,7 @@ def check_redhat(pkg):
# Python 3.x
print(pkg.ljust(20) + '[SUPPORTED]'.ljust(30))

elif exec_subprocess_check_output("rpm -qa | grep -w %s" % (pkg), '/').strip() == '':
elif exec_subprocess_check_return_code("rpm -q %s" % (pkg), '/') != 0:
print(pkg.ljust(20) + '[NOT INSTALLED]'.ljust(30))
else:
if pkg == "gcc-c++":
Expand Down