1 Star 0 Fork 80

zhanghua/rpm

forked from src-openEuler/rpm 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-Fix-changelog-trimming-to-work-relative-to-newest-ex.patch 3.23 KB
一键复制 编辑 原始数据 按行查看 历史
Liquor 提交于 2021-01-11 11:10 . backport patches from upstream
From a58725822651f791b2e74fe40a6e85b3b7e72aca Mon Sep 17 00:00:00 2001
From: Panu Matilainen <[email protected]>
Date: Mon, 10 Aug 2020 11:01:37 +0300
Subject: [PATCH] Fix changelog trimming to work relative to newest
existing
entry (#1301)
%_changelog_trimtime is an absolute timestamp which needs to be
%constantly
pushed forward to preserve the same relative age, and will start
trimming
entries from unchanged packages until none are left, leading to
unexpected
and confusing behavior (RhBug:1722806, ...)
It's better to trim by age relative to newest changelog entry. This way
the
number of trimmed entries will not change unless the spec changes, and
at
least one entry is always preserved. Introduce a new %_changelog_trimage
macro for this and mark the broken by design %_changelog_trimtime as
deprecated, but autoconvert an existing trimtime into relative for now.
As a seemingly unrelated change, move the "time" variable declaration
to a narrower scope to unmask the time() function for use on entry.
Fixes: #1301
---
build/parseChangelog.c | 16 +++++++++++++++-
macros.in | 6 +++++-
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/build/parseChangelog.c b/build/parseChangelog.c
index ad6d834..22f445e 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 8619c13..5b45d73 100644
--- a/macros.in
+++ b/macros.in
@@ -230,8 +230,12 @@ package or when debugging this package.\
# The path to the gzip executable (legacy, use %{__gzip} instead).
%_gzipbin %{__gzip}
+# 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
--
2.27.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhanghua1831/rpm.git
[email protected]:zhanghua1831/rpm.git
zhanghua1831
rpm
rpm
master

搜索帮助