Hi! On Thu, 2024-04-25 at 18:42:50 +0100, Rainer Weikusat wrote: > Package: dpkg > Version: 1.21.22 > Severity: minor > Tags: patch > X-Debbugs-Cc: rweiku...@cyberadapt.com
> The /usr/share/dpkg/pkg-info.mk file invokes dpkg-parsechangelog to > set the SOURCE_DATE_EPOCH environment variable to the date of the > last changelog entry for the package being built. If this changelog > entry hasn't yet been finalized with a date, eg, if it looks like this > (actual example): > > apache2 (2.4.59-ca001-1-deb12u2) unstable; urgency=medium > > * updated to Debian 12 sources > > -- > > SOURCE_DATE_EPOCH is set to an empty string. This causes the > parse_timestamp routine in build.c to fail and print the (rather > confusing) error message: > > unable to parse timestamp '': Success > > (Success being printed because errno isn't set). Package generation then > fails because dpkg-deb afterwards terminates with an exit code of 2. > > Building such packages may not be a supported feature but I've been > using it for dev builds of packages for about 20 years (and plan to > continue doing so). The included patch avoids the issue by ignoring the > value of SOURCE_DATA_EPOCH when it's empty. Thanks for the report and the patch! I've queued the attached patch, in addition to another one improving the error messages to avoid the above confusing output, and I'll also add yet another one refactoring the functions (which I had pending on doing). Thanks, Guillem
From 93e7b2268fabc35d754ffe6389b5172b5917eb8c Mon Sep 17 00:00:00 2001 From: Guillem Jover <guil...@debian.org> Date: Thu, 25 Apr 2024 22:44:19 +0200 Subject: [PATCH] src: Check whether SOURCE_DATE_EPOCH is set before parsing it The dpkg-deb and dpkg-split program try to parse this environment variable to use it for their timestamps inside files to generate reproducible artifacts. But when the environment variable is set but empty then the parsing function fails with a confusing error message. This is an issue when building a package directly via debian/rules that uses the pkg-info.mk fragment file, because that one tries to set the SOURCE_DATE_EPOCH and can end up setting it to an empty value if the changelog contains an unfinished trailer. This is not an issue when using dpkg-buildpackage, though because the code there will fallback to use the current time if it there is no value from the changelog. Closes: #1069846 Based-on-patch-by: Rainer Weikusat <rweiku...@cyberadapt.com> --- src/deb/build.c | 2 +- src/split/split.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/deb/build.c b/src/deb/build.c index 1f0c050ee..16f2bafdf 100644 --- a/src/deb/build.c +++ b/src/deb/build.c @@ -597,7 +597,7 @@ do_build(const char *const *argv) m_output(stdout, _("<standard output>")); timestamp_str = getenv("SOURCE_DATE_EPOCH"); - if (timestamp_str) + if (str_is_set(timestamp_str)) timestamp = parse_timestamp(timestamp_str); else timestamp = time(NULL); diff --git a/src/split/split.c b/src/split/split.c index 771de626c..04d41b281 100644 --- a/src/split/split.c +++ b/src/split/split.c @@ -162,7 +162,7 @@ mksplit(const char *file_src, const char *prefix, off_t maxpartsize, version = versiondescribe(&pkg->available.version, vdew_nonambig); timestamp_str = getenv("SOURCE_DATE_EPOCH"); - if (timestamp_str) + if (str_is_set(timestamp_str)) timestamp = parse_timestamp(timestamp_str); else timestamp = time(NULL); -- 2.43.0