diff --git a/build/parseChangelog.c b/build/parseChangelog.c index ad6d834a17..22f445eb44 100644 --- a/build/parseChangelog.c +++ b/build/parseChangelog.c @@ -200,18 +200,26 @@ static rpmRC addChangelog(Header h, ARGV_const_t sb) rpmRC rc = RPMRC_FAIL; /* assume failure */ char *s, *sp; int i; - time_t time; + time_t firstTime = 0; time_t lastTime = 0; time_t trimtime = rpmExpandNumeric("%{?_changelog_trimtime}"); + time_t trimage = rpmExpandNumeric("%{?_changelog_trimage}"); char *date, *name, *text, *next; int date_words; /* number of words in date string */ + /* Convert _changelog_trimtime to age for backwards compatibility */ + if (trimtime && !trimage) { + trimage = time(NULL) - trimtime; + trimtime = 0; + } + s = sp = argvJoin(sb, ""); /* skip space */ SKIPSPACE(s); while (*s != '\0') { + time_t time; if (*s != '*') { rpmlog(RPMLOG_ERR, _("%%changelog entries must start with *\n")); goto exit; @@ -235,6 +243,12 @@ static rpmRC addChangelog(Header h, ARGV_const_t sb) rpmlog(RPMLOG_ERR, _("bad date in %%changelog: %s\n"), date); goto exit; } + /* Changelog trimming is always relative to first entry */ + if (!firstTime) { + firstTime = time; + if (trimage) + trimtime = firstTime - trimage; + } if (lastTime && lastTime < time) { rpmlog(RPMLOG_ERR, _("%%changelog not in descending chronological order\n")); diff --git a/macros.in b/macros.in index 6245eb879a..0e315b0b5d 100644 --- a/macros.in +++ b/macros.in @@ -212,8 +212,12 @@ package or when debugging this package.\ %__global_requires_exclude_from %{?_docdir:%{_docdir}} %__global_provides_exclude_from %{?_docdir:%{_docdir}} +# Maximum age of preserved changelog entries in binary packages, +# relative to newest existing entry. Unix timestamp format. +%_changelog_trimage 0 + # The Unix time of the latest kept changelog entry in binary packages. -# Any older entry is not packaged in binary packages. +# DEPRACATED, use %_changelog_trimage instead. %_changelog_trimtime 0 # If true, set the SOURCE_DATE_EPOCH environment variable