Skip to content

Commit

Permalink
rpmbuild: more verbose results.json SRPM generator
Browse files Browse the repository at this point in the history
  • Loading branch information
praiskup committed Aug 10, 2023
1 parent cc994d7 commit 727b40b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions rpmbuild/copr_rpmbuild/automation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ def run_automation_tools(task, resultdir, mock_config_file, log):
continue
log.info("Running %s tool", tool.__class__.__name__)
tool.run()
log.info("%s finished", tool.__class__.__name__)
6 changes: 4 additions & 2 deletions rpmbuild/copr_rpmbuild/automation/rpm_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ def run(self):
"""
nevras = self.find_results_nevras_dicts()
packages = {"packages": nevras}
packages_json = json.dumps(packages, indent=4)
self.log.info("Package info:\n%s", packages_json)
path = os.path.join(self.resultdir, "results.json")
with open(path, "w") as dst:
json.dump(packages, dst, indent=4)
with open(path, "w", encoding="utf-8") as dst:
dst.write(packages_json)

def find_results_nevras_dicts(self):
"""
Expand Down
6 changes: 4 additions & 2 deletions rpmbuild/copr_rpmbuild/automation/srpm_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ def run(self):
Create `results.json`
"""
data = self.get_package_info()
data_json = json.dumps(data, indent=4)
self.log.info("Package info: %s", data_json)
path = os.path.join(self.resultdir, "results.json")
with open(path, "w", encoding="utf-8") as dst:
json.dump(data, dst, indent=4)
dst.write(data_json)

def get_package_info(self):
"""
Expand All @@ -52,7 +54,7 @@ def get_package_info(self):
msg = "Exception appeared during handling spec file: {0}".format(path)
self.log.exception(msg)

# Fallback to querying NEVRA from the SRPM package header
path = locate_srpm(self.resultdir)
self.log.warning("Querying NEVRA from SRPM header: %s", path)
hdr = get_rpm_header(path)
return {key: hdr[key] for key in keys}

0 comments on commit 727b40b

Please sign in to comment.