Skip to content

Commit dc8c7d8

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 295dc9c commit dc8c7d8

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
@@ -150,10 +150,21 @@ def diff_source_control(diff_from, diff_to):
150150
print(f" --> {origin_url}/compare/{config_from['commit'][:7]}...{config_to['commit'][:7]}")
151151

152152

153-
def diff_rpms(diff_from, diff_to):
153+
def diff_rpms_json(diff_from, diff_to):
154+
diff_rpms(diff_from, diff_to, json=True)
155+
156+
157+
def diff_rpms_no_json(diff_from, diff_to):
158+
diff_rpms(diff_from, diff_to, json=False)
159+
160+
161+
def diff_rpms(diff_from, diff_to, json):
154162
ref_from = diff_from.id
155163
ref_to = diff_to.id
156-
runcmd(['rpm-ostree', 'db', 'diff', '--repo', TMP_REPO, ref_from, ref_to])
164+
cmd = ['rpm-ostree', 'db', 'diff', '--repo', TMP_REPO, ref_from, ref_to]
165+
if json:
166+
cmd.append('--format=json')
167+
runcmd(cmd)
157168

158169

159170
def diff_ostree_ls(diff_from, diff_to):
@@ -461,7 +472,10 @@ def cache_dir(dir):
461472

462473
# unfortunately, this has to come at the end to resolve functions
463474
DIFFERS = [
464-
Differ("rpms", "Diff RPMs", needs_ostree=OSTreeImport.FULL, function=diff_rpms),
475+
Differ("rpms", "Diff RPMs",
476+
needs_ostree=OSTreeImport.FULL, function=diff_rpms_no_json),
477+
Differ("rpms-json", "Diff RPMs, output JSON",
478+
needs_ostree=OSTreeImport.FULL, function=diff_rpms_json),
465479
Differ("source-control", "Diff config and COSA input commits",
466480
needs_ostree=OSTreeImport.NO, function=diff_source_control),
467481
Differ("ostree-ls", "Diff OSTree contents using 'ostree diff'",

0 commit comments

Comments
 (0)