Skip to content

Commit

Permalink
[mockbuild] create custom error message for dnf-utils not being insta…
Browse files Browse the repository at this point in the history
…lled

Created new exception for absent weak dependent package.
Added custom message for error caused by dnf utils not being installed.

bugzilla url:
https://bugzilla.redhat.com/show_bug.cgi?id=1626879
  • Loading branch information
Petr Junák authored and xsuchy committed Sep 14, 2018
1 parent 3d929d8 commit eb6da09
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions mock/py/mockbuild/exception.py
Expand Up @@ -41,6 +41,7 @@ def __str__(self):
# 70 = result dir could not be created
# 80 = unshare of namespace failed
# 110 = unbalanced call to state functions
# 120 = weak dependent package not installed

class BuildError(Error):
"rpmbuild failed."
Expand Down
18 changes: 17 additions & 1 deletion mock/py/mockbuild/package_manager.py
Expand Up @@ -5,6 +5,7 @@
import glob
import os.path
import shutil
import sys
from textwrap import dedent

import distro
Expand Down Expand Up @@ -156,7 +157,22 @@ def update(self, *args, **kwargs):
# pylint: disable=unused-argument
@traceLog()
def builddep(self, *args, **kwargs):
return self.execute('builddep', returnOutput=1, *args)
try:
result = self.execute('builddep', returnOutput=1, *args)
except (FileNotFoundError) as error:
er = str(error)
if "builddep" in er:
print(error)
print("""
Error: dnf-utils is not installed. Dnf-utils is needed to complete this action.
To install dnf-utils use one of the commands below:
$ dnf install dnf-utils
or
$ yum install dnf-utils""")
sys.exit(120)
else:
raise
return result

@traceLog()
def copy_gpg_keys(self):
Expand Down

0 comments on commit eb6da09

Please sign in to comment.