libpriv/rpm-util: Group by SRPMs when printing changelogs
I've become quite fond of the `--changelogs` switch lately on my Silverblue. I find it useful as a first step when nailing down a regression, or just to peruse the churn of changes after an update. One annoyance is that the same changelog gets printed multiple times for each RPM that shares the same SRPM. This patch does a naive lookahead to dedupe them. Example output: ``` NetworkManager 1:1.12.6-4.fc29.x86_64 -> 1:1.12.6-5.fc29.x86_64 NetworkManager-adsl 1:1.12.6-4.fc29.x86_64 -> 1:1.12.6-5.fc29.x86_64 NetworkManager-bluetooth 1:1.12.6-4.fc29.x86_64 -> 1:1.12.6-5.fc29.x86_64 NetworkManager-config-connectivity-fedora 1:1.12.6-4.fc29.noarch -> 1:1.12.6-5.fc29.noarch NetworkManager-libnm 1:1.12.6-4.fc29.x86_64 -> 1:1.12.6-5.fc29.x86_64 NetworkManager-ppp 1:1.12.6-4.fc29.x86_64 -> 1:1.12.6-5.fc29.x86_64 NetworkManager-wifi 1:1.12.6-4.fc29.x86_64 -> 1:1.12.6-5.fc29.x86_64 NetworkManager-wwan 1:1.12.6-4.fc29.x86_64 -> 1:1.12.6-5.fc29.x86_64 * Mon Jan 14 2019 Beniamino Galvani <bgalvani@redhat.com> - 1:1.12.6-5 - improve Wi-Fi PMF support (rh #1665694) ``` I say "naive" because this doesn't catch the case where a binary RPM is named differently enough that they're not consecutive. Anyway, this simple heuristic cleans up the output nicely. Closes: #1738 Approved by: cgwalters
This commit is contained in:
parent
65afbec3b1
commit
fa5be441b1
@ -501,6 +501,8 @@ rpmhdrs_diff_prnt_block (gboolean changelogs, struct RpmHeadersDiff *diff)
|
||||
{
|
||||
gboolean done = FALSE;
|
||||
|
||||
/* used to avoid fetching SOURCERPM from the same header twice */
|
||||
const char *next_srpm = NULL;
|
||||
for (num = 0; num < diff->hs_mod_new->len; ++num)
|
||||
{
|
||||
Header ho = diff->hs_mod_old->pdata[num];
|
||||
@ -539,6 +541,20 @@ rpmhdrs_diff_prnt_block (gboolean changelogs, struct RpmHeadersDiff *diff)
|
||||
if (!changelogs)
|
||||
continue;
|
||||
|
||||
/* RPMs from the same SRPM share the same changelogs; just peek ahead and skip if
|
||||
* the next one has the same SRPM; i.e. this effectively groups consecutive RPMs
|
||||
* from the same SRPM. */
|
||||
const char *current_srpm = next_srpm ?: headerGetString (ho, RPMTAG_SOURCERPM);
|
||||
if (num == diff->hs_mod_old->len - 1)
|
||||
next_srpm = NULL;
|
||||
else
|
||||
{
|
||||
Header next_ho = diff->hs_mod_old->pdata[num+1];
|
||||
next_srpm = headerGetString(next_ho, RPMTAG_SOURCERPM);
|
||||
}
|
||||
if (g_strcmp0 (current_srpm, next_srpm) == 0)
|
||||
continue;
|
||||
|
||||
/* Load the old %changelog entries */
|
||||
ochanges_date = &ochanges_date_s;
|
||||
headerGet (ho, RPMTAG_CHANGELOGTIME, ochanges_date, HEADERGET_MINMEM);
|
||||
|
Loading…
Reference in New Issue
Block a user