Skip to content

Commit 3f0fe74

Browse files
committed
cmd-diff: support --rpms-json for outputting JSON
This basically maps to passing `--format=json` to `rpm-ostree db diff`. Useful for updating meta.json with info about package differences and advisories.
1 parent 948b6e5 commit 3f0fe74

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/cmd-diff

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,21 @@ def diff_source_control(diff_from, diff_to):
155155
print(f" --> {origin_url}/compare/{config_from['commit'][:7]}...{config_to['commit'][:7]}")
156156

157157

158-
def diff_rpms(diff_from, diff_to):
158+
def diff_rpms_json(diff_from, diff_to):
159+
diff_rpms(diff_from, diff_to, json=True)
160+
161+
162+
def diff_rpms_no_json(diff_from, diff_to):
163+
diff_rpms(diff_from, diff_to, json=False)
164+
165+
166+
def diff_rpms(diff_from, diff_to, json):
159167
ref_from = diff_from.id
160168
ref_to = diff_to.id
161-
runcmd(['rpm-ostree', 'db', 'diff', '--repo', TMP_REPO, ref_from, ref_to])
169+
cmd = ['rpm-ostree', 'db', 'diff', '--repo', TMP_REPO, ref_from, ref_to]
170+
if json:
171+
cmd.append('--format=json')
172+
runcmd(cmd)
162173

163174

164175
def diff_ostree_ls(diff_from, diff_to):
@@ -465,7 +476,10 @@ def cache_dir(dir):
465476

466477
# unfortunately, this has to come at the end to resolve functions
467478
DIFFERS = [
468-
Differ("rpms", "Diff RPMs", needs_ostree=OSTreeImport.FULL, function=diff_rpms),
479+
Differ("rpms", "Diff RPMs",
480+
needs_ostree=OSTreeImport.FULL, function=diff_rpms_no_json),
481+
Differ("rpms-json", "Diff RPMs, output JSON",
482+
needs_ostree=OSTreeImport.FULL, function=diff_rpms_json),
469483
Differ("source-control", "Diff config and COSA input commits",
470484
needs_ostree=OSTreeImport.NO, function=diff_source_control),
471485
Differ("ostree-ls", "Diff OSTree contents using 'ostree diff'",

0 commit comments

Comments
 (0)