Accepting request 483307 from Base:System

1

OBS-URL: https://build.opensuse.org/request/show/483307
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/rpm?expand=0&rev=244
This commit is contained in:
Ludwig Nussel 2017-04-03 09:03:53 +00:00 committed by Git OBS Bridge
commit e4270fa767
10 changed files with 644 additions and 131 deletions

View File

@ -0,0 +1,62 @@
From 42906a9c5da4c89128ed8ffb619f8ef1fa2d9b93 Mon Sep 17 00:00:00 2001
From: "Bernhard M. Wiedemann" <bwiedemann@suse.de>
Date: Fri, 27 Jan 2017 13:01:57 +0100
Subject: [PATCH 1/4] set SOURCE_DATE_EPOCH from changelog
if requested by macro
to allow for more reproducible builds of packages.
See https://reproducible-builds.org/ for why this is good
and https://reproducible-builds.org/specs/source-date-epoch/
for the definition of this variable.
(cherry picked from commit 0e87aed1785d0531c40b23889f8338744f6abb3a)
---
build/build.c | 15 +++++++++++++++
macros.in | 4 ++++
2 files changed, 19 insertions(+)
diff --git a/build/build.c b/build/build.c
index 04b039c..89b04ce 100644
--- build/build.c
+++ build/build.c
@@ -209,6 +209,21 @@ static rpmRC buildSpec(BTA_t buildArgs, rpmSpec spec, int what)
int test = (what & RPMBUILD_NOBUILD);
char *cookie = buildArgs->cookie ? xstrdup(buildArgs->cookie) : NULL;
+ if (rpmExpandNumeric("%{?source_date_epoch_from_changelog}") &&
+ getenv("SOURCE_DATE_EPOCH") == NULL) {
+ /* Use date of first (== latest) changelog entry */
+ Header h = spec->packages->header;
+ struct rpmtd_s td;
+ if (headerGet(h, RPMTAG_CHANGELOGTIME, &td, (HEADERGET_MINMEM|HEADERGET_RAW))) {
+ char sdestr[22];
+ snprintf(sdestr, sizeof(sdestr), "%lli",
+ (long long) rpmtdGetNumber(&td));
+ rpmlog(RPMLOG_NOTICE, _("setting %s=%s\n"), "SOURCE_DATE_EPOCH", sdestr);
+ setenv("SOURCE_DATE_EPOCH", sdestr, 0);
+ rpmtdFreeData(&td);
+ }
+ }
+
/* XXX TODO: rootDir is only relevant during build, eliminate from spec */
spec->rootDir = buildArgs->rootdir;
if (!spec->recursing && spec->BACount) {
diff --git a/macros.in b/macros.in
index fd57f2e..85f172a 100644
--- macros.in
+++ macros.in
@@ -210,6 +210,10 @@ package or when debugging this package.\
# Any older entry is not packaged in binary packages.
%_changelog_trimtime 0
+# If true, set the SOURCE_DATE_EPOCH environment variable
+# to the timestamp of the topmost changelog entry
+%source_date_epoch_from_changelog 0
+
# The directory where newly built binary packages will be written.
%_rpmdir %{_topdir}/RPMS
--
2.10.2

View File

@ -0,0 +1,191 @@
From b74958824c7e0d7c12550ba22d9b31da040d2cd4 Mon Sep 17 00:00:00 2001
From: Pavlina <pavlina@dhcp-27-209.brq.redhat.com>
Date: Thu, 6 Oct 2016 08:59:47 +0200
Subject: [PATCH 2/4] Extend %changelog to support full timestamps (#903)
The newly accepted date format is
Mon Jan 6 09:02:22 CEST 2016
(like output of "date" command). Original format "Mon Jun 6 2016" is still supported.
(cherry picked from commit 57f94a582602f0353cdb17a02dc12c4461d4f32d)
---
build/parseChangelog.c | 106 +++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 89 insertions(+), 17 deletions(-)
diff --git a/build/parseChangelog.c b/build/parseChangelog.c
index ff301b9..82fd096 100644
--- build/parseChangelog.c
+++ build/parseChangelog.c
@@ -32,17 +32,20 @@ static int sameDate(const struct tm *ot, const struct tm *nt)
/**
* Parse date string to seconds.
+ * accepted date formats are "Mon Jun 6 2016" (original one)
+ * and "Thu Oct 6 06:48:39 CEST 2016" (extended one)
* @param datestr date string (e.g. 'Wed Jan 1 1997')
* @retval secs secs since the unix epoch
* @return 0 on success, -1 on error
*/
-static int dateToTimet(const char * datestr, time_t * secs)
+static int dateToTimet(const char * datestr, time_t * secs, int * date_words)
{
int rc = -1; /* assume failure */
struct tm time, ntime;
const char * const * idx;
char *p, *pe, *q, *date, *tz;
-
+ char tz_name[10]; /* name of timezone (if extended format is used) */
+
static const char * const days[] =
{ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", NULL };
static const char * const months[] =
@@ -80,26 +83,93 @@ static int dateToTimet(const char * datestr, time_t * secs)
if (*p == '\0') goto exit;
pe = p; SKIPNONSPACE(pe); if (*pe != '\0') *pe++ = '\0';
- /* make this noon so the day is always right (as we make this UTC) */
- time.tm_hour = 12;
-
time.tm_mday = strtol(p, &q, 10);
if (!(q && *q == '\0')) goto exit;
if (time.tm_mday < 0 || time.tm_mday > lengths[time.tm_mon]) goto exit;
- /* year */
- p = pe; SKIPSPACE(p);
- if (*p == '\0') goto exit;
- pe = p; SKIPNONSPACE(pe); if (*pe != '\0') *pe = '\0';
+ /* first part of year entry (original format) / time entry (extended format)*/
+ p = pe;
+ SKIPSPACE(p);
+ if (*p == '\0')
+ goto exit;
+
+ /* in the original format here is year record (e.g. 1999),
+ * in the extended one here is time stamp (e.g. 10:22:30).
+ * Choose the format
+ */
+ if ((p[1]==':') || ((p[1]!='\0') && ((p[2]==':')))) {
+ /* it can be extended format */
+ *date_words = 6;
+
+ /* second part of time entry */
+ /* hours */
+ time.tm_hour = strtol(p, &q, 10);
+ if ( (time.tm_hour < 0) || (time.tm_hour > 23) )
+ goto exit;
+ if (*q!=':')
+ goto exit;
+ p = ++q;
+ /* minutes */
+ time.tm_min = strtol(p, &q, 10);
+ if ( (time.tm_min < 0) || (time.tm_min > 59) )
+ goto exit;
+ if (*q != ':')
+ goto exit;
+ p = ++q;
+ /* time - seconds */
+ time.tm_sec = strtol(p, &q, 10);
+ if ( (time.tm_sec < 0) || (time.tm_sec > 59) )
+ goto exit;
+ p = q;
+
+ /* time zone name */
+ SKIPSPACE(p);
+ if (*p == '\0')
+ goto exit;
+ pe = p;
+ SKIPNONSPACE(pe);
+ if (*pe != '\0')
+ *pe++ = '\0';
+ if (((int)(pe-p) + 1) > 9 )
+ goto exit;
+ strncpy(tz_name, p, (int)(pe-p));
+ tz_name[(int)(pe-p)] = '\0';
+
+ /* first part of year entry */
+ p = pe;
+ SKIPSPACE(p);
+ if (*p == '\0')
+ goto exit;
+ } else {
+ *date_words = 4;
+ /* the original format */
+ /* make this noon so the day is always right (as we make this UTC) */
+ time.tm_hour = 12;
+ }
+
+ /* year - second part */
+ pe = p;
+ SKIPNONSPACE(pe);
+ if (*pe != '\0')
+ *pe = '\0';
time.tm_year = strtol(p, &q, 10);
if (!(q && *q == '\0')) goto exit;
if (time.tm_year < 1990 || time.tm_year >= 3000) goto exit;
time.tm_year -= 1900;
- /* chnagelog date is always in UTC */
+ /* change time zone and compute calendar time representation */
tz = getenv("TZ");
- if (tz) tz = xstrdup(tz);
- setenv("TZ", "UTC", 1);
+ if (tz)
+ tz = xstrdup(tz);
+ if (*date_words == 6) {
+ /* changelog date is in read time zone */
+ tz = getenv("TZ");
+ if (tz) tz = xstrdup(tz);
+ setenv("TZ", tz_name, 1);
+ } else {
+ /* changelog date is always in UTC */
+ setenv("TZ", "UTC", 1);
+ }
ntime = time; /* struct assignment */
*secs = mktime(&ntime);
unsetenv("TZ");
@@ -107,6 +177,7 @@ static int dateToTimet(const char * datestr, time_t * secs)
setenv("TZ", tz, 1);
free(tz);
}
+
if (*secs == -1) goto exit;
/* XXX Turn this into a hard error in a release or two */
@@ -135,6 +206,7 @@ static rpmRC addChangelog(Header h, ARGV_const_t sb)
time_t lastTime = 0;
time_t trimtime = rpmExpandNumeric("%{?_changelog_trimtime}");
char *date, *name, *text, *next;
+ int date_words; /* number of words in date string */
s = sp = argvJoin(sb, "");
@@ -160,12 +232,8 @@ static rpmRC addChangelog(Header h, ARGV_const_t sb)
/* 4 fields of date */
date++;
s = date;
- for (i = 0; i < 4; i++) {
- SKIPSPACE(s);
- SKIPNONSPACE(s);
- }
SKIPSPACE(date);
- if (dateToTimet(date, &time)) {
+ if (dateToTimet(date, &time, &date_words)) {
rpmlog(RPMLOG_ERR, _("bad date in %%changelog: %s\n"), date);
goto exit;
}
@@ -174,6 +242,10 @@ static rpmRC addChangelog(Header h, ARGV_const_t sb)
_("%%changelog not in descending chronological order\n"));
goto exit;
}
+ for (i = 0; i < date_words; i++) {
+ SKIPSPACE(s);
+ SKIPNONSPACE(s);
+ }
lastTime = time;
/* skip space to the name */
--
2.10.2

View File

@ -0,0 +1,82 @@
From f2aa612c5a2a99e1186853a3d00d43607bdc6aa2 Mon Sep 17 00:00:00 2001
From: "Bernhard M. Wiedemann" <bwiedemann@suse.de>
Date: Sun, 13 Mar 2016 10:20:47 +0100
Subject: [PATCH 3/4] Allow SOURCE_DATE_EPOCH to override file timestamps
Limit the maximum date to SOURCE_DATE_EPOCH or use origtime if not defined
similar to the tar --clamp-mtime option
based on a patch by Nicolas Vigier <boklm at torproject.org>
(cherry picked from commit 8d84878ee05b2e63858af3a5a49d98e9e2933b1b)
---
build/files.c | 22 ++++++++++++++++++++++
macros.in | 5 +++++
2 files changed, 27 insertions(+)
diff --git build/files.c build/files.c
index b76ce04..48b03e9 100644
--- build/files.c
+++ build/files.c
@@ -9,6 +9,7 @@
#define MYALLPERMS 07777
#include <errno.h>
+#include <stdlib.h>
#include <regex.h>
#if WITH_CAP
#include <sys/capability.h>
@@ -939,6 +940,24 @@ static void genCpioListAndHeader(FileList fl, Package pkg, int isSrc)
uint32_t defaultalgo = PGPHASHALGO_MD5, digestalgo;
rpm_loff_t totalFileSize = 0;
Header h = pkg->header; /* just a shortcut */
+ int override_date = 0;
+ time_t source_date_epoch;
+ char *srcdate = getenv("SOURCE_DATE_EPOCH");
+
+ /* Limit the maximum date to SOURCE_DATE_EPOCH if defined
+ * similar to the tar --clamp-mtime option
+ * https://reproducible-builds.org/specs/source-date-epoch/
+ */
+ if (srcdate && rpmExpandNumeric("%{?clamp_mtime_to_source_date_epoch}")) {
+ char *endptr;
+ errno = 0;
+ source_date_epoch = strtol(srcdate, &endptr, 10);
+ if (srcdate == endptr || *endptr || errno != 0) {
+ rpmlog(RPMLOG_ERR, _("unable to parse %s=%s\n"), "SOURCE_DATE_EPOCH", srcdate);
+ exit(28);
+ }
+ override_date = 1;
+ }
/*
* See if non-md5 file digest algorithm is requested. If not
@@ -1070,6 +1089,9 @@ static void genCpioListAndHeader(FileList fl, Package pkg, int isSrc)
}
}
+ if (override_date && flp->fl_mtime > source_date_epoch) {
+ flp->fl_mtime = source_date_epoch;
+ }
/*
* For items whose size varies between systems, always explicitly
* cast to the header type before inserting.
diff --git macros.in macros.in
index 85f172a..e0d7b7f 100644
--- macros.in
+++ macros.in
@@ -214,6 +214,11 @@ package or when debugging this package.\
# to the timestamp of the topmost changelog entry
%source_date_epoch_from_changelog 0
+# If true, make sure that timestamps in built rpms
+# are not later than the value of SOURCE_DATE_EPOCH.
+# Is ignored when SOURCE_DATE_EPOCH is not set.
+%clamp_mtime_to_source_date_epoch 0
+
# The directory where newly built binary packages will be written.
%_rpmdir %{_topdir}/RPMS
--
2.10.2

View File

@ -0,0 +1,50 @@
From 686ff4634d69999740c93eea761b09c3fb17c2f6 Mon Sep 17 00:00:00 2001
From: Nicolas Vigier <boklm@torproject.org>
Date: Thu, 3 Dec 2015 12:57:22 +0100
Subject: [PATCH 4/4] Allow SOURCE_DATE_EPOCH to override RPMTAG_BUILDTIME
SOURCE_DATE_EPOCH environment variable is a distribution-agnostic
standard for build systems to exchange a timestamp.
SOURCE_DATE_EPOCH specification is available at:
https://reproducible-builds.org/specs/source-date-epoch
Signed-off-by: Dhiru Kholia <dhiru@openwall.com>
(cherry picked from commit b8a54d6a1e9bb6140b6b47e23dc707e4b967537e)
---
build/pack.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git build/pack.c build/pack.c
index 094419e..8305b42 100644
--- build/pack.c
+++ build/pack.c
@@ -154,9 +154,23 @@ exit:
static rpm_time_t * getBuildTime(void)
{
static rpm_time_t buildTime[1];
+ char *srcdate;
+ time_t epoch;
+ char *endptr;
+
+ if (buildTime[0] == 0) {
+ srcdate = getenv("SOURCE_DATE_EPOCH");
+ if (srcdate) {
+ errno = 0;
+ epoch = strtol(srcdate, &endptr, 10);
+ if (srcdate == endptr || *endptr || errno != 0)
+ rpmlog(RPMLOG_ERR, _("unable to parse SOURCE_DATE_EPOCH\n"));
+ else
+ buildTime[0] = (int32_t) epoch;
+ } else
+ buildTime[0] = (int32_t) time(NULL);
+ }
- if (buildTime[0] == 0)
- buildTime[0] = (int32_t) time(NULL);
return buildTime;
}
--
2.10.2

View File

@ -1,7 +1,5 @@
Create a debuginfo package for each subpackage.
--- ./build/files.c.orig 2016-10-21 09:44:00.300962089 +0000
+++ ./build/files.c 2017-01-19 13:01:34.731859805 +0000
--- ./build/files.c.orig 2017-02-16 09:52:49.292092380 +0000
+++ ./build/files.c 2017-03-22 13:32:42.911865500 +0000
@@ -21,6 +21,10 @@
#include <rpm/rpmlog.h>
#include <rpm/rpmbase64.h>
@ -13,7 +11,7 @@ Create a debuginfo package for each subpackage.
#include "rpmio/rpmio_internal.h" /* XXX rpmioSlurp */
#include "misc/fts.h"
#include "lib/rpmfi_internal.h" /* XXX fi->apath */
@@ -2156,13 +2160,238 @@ exit:
@@ -2155,13 +2159,302 @@ exit:
return rc;
}
@ -22,7 +20,7 @@ Create a debuginfo package for each subpackage.
+ allocated *build_id array of size *build_id_size. Returns -1 on
+ error. */
+
+int
+static int
+getELFBuildId (const char *name,
+ unsigned char **id, size_t *id_size)
+{
@ -70,32 +68,33 @@ Create a debuginfo package for each subpackage.
+ Elf_Data src = dst;
+
+ gelf_getshdr (s, &shdr);
+ if (shdr.sh_type != SHT_NOTE
+ || !(shdr.sh_flags & SHF_ALLOC))
+ /* LD creates .note.gnu.build-id with SHF_ALLOC but the DWZ
+ common debuginfo only file only has non-allocated sections. */
+ if (shdr.sh_type != SHT_NOTE)
+ continue;
+
+ /* Look for a build-ID note here. */
+ data = elf_rawdata (s, NULL);
+ src.d_buf = data->d_buf;
+ assert (sizeof (Elf32_Nhdr) == sizeof (Elf64_Nhdr));
+ while (data->d_buf + data->d_size - src.d_buf > (int) sizeof nh
+ while ((unsigned char *)data->d_buf + data->d_size - (unsigned char *)src.d_buf > (int) sizeof nh
+ && elf32_xlatetom (&dst, &src, ehdr.e_ident[EI_DATA]))
+ {
+ Elf32_Word len = sizeof nh + nh.n_namesz;
+ len = (len + 3) & ~3;
+
+ if (nh.n_namesz == sizeof "GNU" && nh.n_type == 3
+ && !memcmp (src.d_buf + sizeof nh, "GNU", sizeof "GNU"))
+ && !memcmp ((unsigned char *)src.d_buf + sizeof nh, "GNU", sizeof "GNU"))
+ {
+ build_id = data;
+ build_id_offset = src.d_buf + len - data->d_buf;
+ build_id_offset = (unsigned char *)src.d_buf + len - (unsigned char *)data->d_buf;
+ build_id_size = nh.n_descsz;
+ break;
+ }
+
+ len += nh.n_descsz;
+ len = (len + 3) & ~3;
+ src.d_buf += len;
+ src.d_buf = (unsigned char *)src.d_buf + len;
+ }
+
+ if (build_id != NULL)
@ -107,7 +106,7 @@ Create a debuginfo package for each subpackage.
+
+ *id = malloc (build_id_size);
+ *id_size = build_id_size;
+ memcpy (*id, build_id->d_buf + build_id_offset, build_id_size);
+ memcpy (*id, (unsigned char *)build_id->d_buf + build_id_offset, build_id_size);
+
+ elf_end (elf);
+ close (fd);
@ -139,7 +138,41 @@ Create a debuginfo package for each subpackage.
+ 0
+};
+
+static void addDebuginfoPackage(rpmSpec spec, Package pkg, char *buildroot)
+/* Add a new debuginfo package based on PKG with FILES. */
+
+static Package addDebuginfoPackage(rpmSpec spec, Package pkg, ARGV_t files)
+{
+ const char *name;
+ char tmp[1024];
+ Package dbg = newPackage(NULL, spec->pool, &spec->packages);
+ name = headerGetString(pkg->header, RPMTAG_NAME);
+ /* Set name, summary and group. */
+ snprintf(tmp, 1024, "%s-debuginfo", name);
+ headerPutString(dbg->header, RPMTAG_NAME, tmp);
+ snprintf(tmp, 1024, "Debug information for package %s", name);
+ headerPutString(dbg->header, RPMTAG_SUMMARY, tmp);
+ snprintf(tmp, 1024, "This package provides debug information for package %s.\n"
+ "Debug information is useful when developing applications that use this\n"
+ "package or when debugging this package.", name);
+ headerPutString(dbg->header, RPMTAG_DESCRIPTION, tmp);
+ headerPutString(dbg->header, RPMTAG_GROUP, "Development/Debug");
+ /* Inherit other tags from parent. */
+ headerCopyTags(spec->packages->header,
+ dbg->header, copyTagsForDebug);
+
+ /* Add self-provides */
+ dbg->ds = rpmdsThis(dbg->header, RPMTAG_REQUIRENAME, RPMSENSE_EQUAL);
+ addPackageProvides(dbg);
+
+ /* Build up the files list. */
+ dbg->fileList = files;
+ return dbg;
+}
+
+/* Process the filelist of PKG and see to eventually create a debuginfo
+ packge for it. */
+
+static Package processDebuginfo(rpmSpec spec, Package pkg, char *buildroot)
+{
+ const char *a;
+
@ -147,7 +180,6 @@ Create a debuginfo package for each subpackage.
+ a = headerGetString(pkg->header, RPMTAG_ARCH);
+ if (strcmp(a, "noarch") != 0)
+ {
+ Package dbg;
+ rpmfi fi = rpmfilesIter(pkg->cpioList, RPMFI_ITER_FWD);
+ char tmp[1024];
+ const char *name;
@ -195,7 +227,10 @@ Create a debuginfo package for each subpackage.
+ /* If we see build-id links for the first time add the
+ directory. */
+ if (!seen_build_id)
+ argvAdd(&files, "%dir /usr/lib/debug/.build-id");
+ {
+ seen_build_id = 1;
+ argvAdd(&files, "%dir /usr/lib/debug/.build-id");
+ }
+
+ /* From the build-id construct the two links pointing back
+ to the debug information file and the binary. */
@ -213,31 +248,54 @@ Create a debuginfo package for each subpackage.
+ /* If there are debuginfo files for this package add a
+ new debuginfo package. */
+ if (files)
+ {
+ dbg = newPackage(NULL, spec->pool, &spec->packages);
+ headerNVR(pkg->header, &name, NULL, NULL);
+ /* Set name, summary and group. */
+ snprintf(tmp, 1024, "%s-debuginfo", name);
+ headerPutString(dbg->header, RPMTAG_NAME, tmp);
+ snprintf(tmp, 1024, "Debug information for package %s", name);
+ headerPutString(dbg->header, RPMTAG_SUMMARY, tmp);
+ snprintf(tmp, 1024, "This package provides debug information for package %s.\n"
+ "Debug information is useful when developing applications that use this\n"
+ "package or when debugging this package.", name);
+ headerPutString(dbg->header, RPMTAG_DESCRIPTION, tmp);
+ headerPutString(dbg->header, RPMTAG_GROUP, "Development/Debug");
+ /* Inherit other tags from parent. */
+ headerCopyTags(pkg->header, dbg->header, copyTagsForDebug);
+
+ /* Add self-provides */
+ dbg->ds = rpmdsThis(dbg->header, RPMTAG_REQUIRENAME, RPMSENSE_EQUAL);
+ addPackageProvides(dbg);
+
+ /* Build up the files list. */
+ dbg->fileList = files;
+ }
+ return addDebuginfoPackage (spec, pkg, files);
+ }
+ return NULL;
+}
+
+
+static char *addDebugDWZ(ARGV_t *filesp, char *buildroot)
+{
+ char tmp[1024];
+ struct stat sbuf;
+ char *dwz_dbg_buildid = NULL;
+ DIR *d;
+ struct dirent *de;
+ int i;
+
+ snprintf(tmp, 1024, "%s%s", buildroot, "/usr/lib/debug/.dwz");
+ if (lstat(tmp, &sbuf) != 0 || !S_ISDIR(sbuf.st_mode))
+ return NULL;
+ d = opendir(tmp);
+ if (!d)
+ return NULL;
+
+ argvAdd(filesp, "/usr/lib/debug/.dwz");
+ while ((de = readdir (d))) {
+ unsigned char *build_id = NULL;
+ size_t build_id_size = 0;
+
+ snprintf(tmp, 1024, "%s/usr/lib/debug/.dwz/%s", buildroot, de->d_name);
+ if (lstat(tmp, &sbuf) == -1 || !S_ISREG(sbuf.st_mode))
+ continue;
+ if (getELFBuildId(tmp, &build_id, &build_id_size) == -1)
+ continue;
+ snprintf(tmp, 1024, "/usr/lib/debug/.build-id/%02x/", build_id[0]);
+ for (i = 1; i < build_id_size; ++i)
+ sprintf(tmp + strlen(tmp), "%02x", build_id[i]);
+ sprintf(tmp + strlen(tmp), ".debug");
+ argvAdd(filesp, tmp);
+ if (!dwz_dbg_buildid) {
+ for (i = 0; i < build_id_size; ++i)
+ sprintf(tmp + 2 * i, "%02x", build_id[i]);
+ dwz_dbg_buildid = xstrdup(tmp);
+ }
+ free(build_id);
+ }
+ closedir(d);
+ return dwz_dbg_buildid;
+}
+
+#endif
+
rpmRC processBinaryFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags,
@ -246,29 +304,69 @@ Create a debuginfo package for each subpackage.
Package pkg;
rpmRC rc = RPMRC_OK;
+ char *buildroot;
+ Package first_dbg = NULL, dwz_dbg = NULL;
+ int processing_dbg = 0;
+ int main_pkg_got_dbg = 0;
+ char *dwz_dbg_buildid = NULL;
check_fileList = newStringBuf();
+ buildroot = rpmGenPath(spec->rootDir, spec->buildRoot, NULL);
genSourceRpmName(spec);
for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) {
@@ -2180,8 +2409,12 @@ rpmRC processBinaryFiles(rpmSpec spec, r
@@ -2179,8 +2472,40 @@ rpmRC processBinaryFiles(rpmSpec spec, r
rpmlog(RPMLOG_NOTICE, _("Processing files: %s\n"), nvr);
free(nvr);
- if ((rc = processPackageFiles(spec, pkgFlags, pkg, installSpecialDoc, test)) != RPMRC_OK ||
- (rc = rpmfcGenerateDepends(spec, pkg)) != RPMRC_OK)
+#if HAVE_GELF_H && HAVE_LIBELF
+ if (pkg == first_dbg) {
+ /* If we have multiple debug packages then we put
+ DWZ generated files into %name-debuginfo which
+ may already exist. Otherwise put the DWZ data
+ into the only debug package. */
+ processing_dbg = 1;
+ if (!first_dbg->next || main_pkg_got_dbg) {
+ dwz_dbg_buildid = addDebugDWZ(&first_dbg->fileList, buildroot);
+ dwz_dbg = pkg;
+ } else {
+ ARGV_t files = NULL;
+ dwz_dbg_buildid = addDebugDWZ(&files, buildroot);
+ dwz_dbg = addDebuginfoPackage(spec, spec->packages, files);
+ }
+ }
+#endif
+ if ((rc = processPackageFiles(spec, pkgFlags, pkg, installSpecialDoc, test)) != RPMRC_OK)
+ goto exit;
+#if HAVE_GELF_H && HAVE_LIBELF
+ addDebuginfoPackage(spec, pkg, buildroot);
+ if (!processing_dbg) {
+ Package dbg = processDebuginfo(spec, pkg, buildroot);
+ if (dbg && !first_dbg) {
+ first_dbg = dbg;
+ if (pkg == spec->packages)
+ main_pkg_got_dbg = 1;
+ }
+ }
+ /* If we have DWZ info and it is not in PKG then add a requires. */
+ if (dwz_dbg_buildid && pkg != dwz_dbg)
+ addReqProv(pkg, RPMTAG_REQUIRENAME,
+ "debuginfo(build-id)", dwz_dbg_buildid, RPMSENSE_EQUAL, 0);
+#endif
+ if ((rc = rpmfcGenerateDepends(spec, pkg)) != RPMRC_OK)
goto exit;
a = headerGetString(pkg->header, RPMTAG_ARCH);
--- ./build/parseSpec.c.orig 2017-01-19 13:01:28.985876261 +0000
+++ ./build/parseSpec.c 2017-01-19 13:01:34.732859802 +0000
@@ -2215,6 +2540,7 @@ rpmRC processBinaryFiles(rpmSpec spec, r
}
exit:
check_fileList = freeStringBuf(check_fileList);
+ _free(dwz_dbg_buildid);
return rc;
}
--- ./build/parseSpec.c.orig 2017-03-22 12:10:11.304029953 +0000
+++ ./build/parseSpec.c 2017-03-22 12:10:20.142010341 +0000
@@ -564,7 +564,7 @@ static void initSourceHeader(rpmSpec spe
}
@ -278,8 +376,8 @@ Create a debuginfo package for each subpackage.
{
const char *arch, *name;
char *evr, *isaprov;
--- ./build/rpmbuild_internal.h.orig 2016-10-13 07:12:21.364778540 +0000
+++ ./build/rpmbuild_internal.h 2017-01-19 13:01:34.732859802 +0000
--- ./build/rpmbuild_internal.h.orig 2017-02-16 09:40:09.788649545 +0000
+++ ./build/rpmbuild_internal.h 2017-03-22 12:10:20.143010339 +0000
@@ -442,6 +442,13 @@ int addReqProv(Package pkg, rpmTagVal ta
@ -294,8 +392,8 @@ Create a debuginfo package for each subpackage.
* Add rpmlib feature dependency.
* @param pkg package
* @param feature rpm feature name (i.e. "rpmlib(Foo)" for feature Foo)
--- ./macros.in.orig 2017-01-19 13:01:28.988876252 +0000
+++ ./macros.in 2017-01-19 13:01:34.733859800 +0000
--- ./macros.in.orig 2017-03-22 12:10:11.307029946 +0000
+++ ./macros.in 2017-03-22 12:10:20.143010339 +0000
@@ -186,24 +186,10 @@
# Template for debug information sub-package.
%debug_package \
@ -321,8 +419,8 @@ Create a debuginfo package for each subpackage.
%description debugsource\
This package provides debug sources for package %{name}.\
Debug sources are useful when developing applications that use this\
--- ./scripts/find-debuginfo.sh.orig 2017-01-19 13:01:28.983876267 +0000
+++ ./scripts/find-debuginfo.sh 2017-01-19 13:01:34.733859800 +0000
--- ./scripts/find-debuginfo.sh.orig 2017-03-22 12:10:11.303029955 +0000
+++ ./scripts/find-debuginfo.sh 2017-03-22 12:10:20.144010337 +0000
@@ -220,6 +220,11 @@ debug_link()
# Provide .2, .3, ... symlinks to all filename instances of this build-id.
make_id_dup_link()

View File

@ -1,5 +1,7 @@
--- ./macros.in.orig 2016-10-21 09:47:06.238886221 +0000
+++ ./macros.in 2017-01-19 12:48:15.414136831 +0000
Index: macros.in
===================================================================
--- macros.in.orig 2017-02-16 10:40:09.908649457 +0100
+++ macros.in 2017-03-06 13:35:44.504200409 +0100
@@ -185,22 +185,22 @@
# Template for debug information sub-package.
@ -45,7 +47,27 @@
# Algorithm to use for generating file checksum digests on build.
# If not specified or 0, MD5 is used.
@@ -459,16 +460,22 @@ package or when debugging this package.\
@@ -448,6 +449,19 @@ package or when debugging this package.\
#
#%_include_minidebuginfo 1
+# Number of debugging information entries (DIEs) above which
+# dwz will stop considering file for multifile optimizations
+# and enter a low memory mode, in which it will optimize
+# in about half the memory needed otherwise.
+%_dwz_low_mem_die_limit 10000000
+# Number of DIEs above which dwz will stop processing
+# a file altogether.
+%_dwz_max_die_limit 50000000
+
+%_find_debuginfo_dwz_opts --run-dwz\\\
+ --dwz-low-mem-die-limit %{_dwz_low_mem_die_limit}\\\
+ --dwz-max-die-limit %{_dwz_max_die_limit}
+
#
# Use internal dependency generator rather than external helpers?
%_use_internal_dependency_generator 1
@@ -459,16 +473,22 @@ package or when debugging this package.\
# Directories whose contents should be considered as documentation.
%__docdir_path %{_datadir}/doc:%{_datadir}/man:%{_datadir}/info:%{_datadir}/gtk-doc/html:%{?_docdir}:%{?_mandir}:%{?_infodir}:%{?_javadocdir}:/usr/doc:/usr/man:/usr/info:/usr/X11R6/man
@ -70,7 +92,7 @@
#
# Path to file attribute classifications for automatic dependency
@@ -538,10 +545,10 @@ package or when debugging this package.\
@@ -538,10 +558,10 @@ package or when debugging this package.\
# Misc BDB tuning options
%__dbi_other mp_mmapsize=128Mb mp_size=1Mb
@ -83,7 +105,7 @@
#==============================================================================
# ---- GPG/PGP/PGP5 signature macros.
@@ -840,7 +847,7 @@ package or when debugging this package.\
@@ -840,7 +860,7 @@ package or when debugging this package.\
%_build_vendor %{_host_vendor}
%_build_os %{_host_os}
%_host @host@
@ -92,7 +114,7 @@
%_host_cpu @host_cpu@
%_host_vendor @host_vendor@
%_host_os @host_os@
@@ -1009,6 +1016,183 @@ done \
@@ -1009,6 +1029,183 @@ done \
%python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; import sys; sys.stdout.write(get_python_lib(1))")
%python_version %(%{__python} -c "import sys; sys.stdout.write(sys.version[:3])")
@ -276,7 +298,7 @@
#------------------------------------------------------------------------------
# arch macro for all Intel i?86 compatibile processors
# (Note: This macro (and it's analogues) will probably be obsoleted when
@@ -1019,7 +1203,9 @@ done \
@@ -1019,7 +1216,9 @@ done \
#------------------------------------------------------------------------------
# arch macro for all supported ARM processors
@ -287,7 +309,7 @@
#------------------------------------------------------------------------------
# arch macro for 32-bit MIPS processors
@@ -1174,3 +1360,24 @@ end}
@@ -1174,3 +1373,24 @@ end}
# \endverbatim
#*/

View File

@ -1,3 +1,16 @@
-------------------------------------------------------------------
Fri Mar 17 18:14:37 UTC 2017 - kukuk@suse.com
- Convert rpmconfigcheck init script to systemd unit
-------------------------------------------------------------------
Mon Mar 6 12:37:48 UTC 2017 - rguenther@suse.com
- Tweak debugsubpkg.diff to no longer use obsoleted RPM interfaces
and add support for debuginfo compressed by DWZ.
- Add %_find_debuginfo_dwz_opts and DWZ limits to macrosin.diff.
- Add dwz requires to rpm-build. [fate#322957]
-------------------------------------------------------------------
Wed Mar 1 13:55:51 CET 2017 - mls@suse.de
@ -10,6 +23,16 @@ Mon Feb 27 13:24:26 UTC 2017 - rguenther@suse.com
- Fix debugedit-canon-fix.diff to handle directory table size
shrinking by 1 byte correctly.
-------------------------------------------------------------------
Wed Feb 22 12:54:05 UTC 2017 - bwiedemann@suse.com
- Add upstream patches 0001-set-SOURCE_DATE_EPOCH-from-changelog.patch
0002-Extend-changelog-to-support-full-timestamps-903.patch
0003-Allow-SOURCE_DATE_EPOCH-to-override-file-timestamps.patch
0004-Allow-SOURCE_DATE_EPOCH-to-override-RPMTAG_BUILDTIME.patch
in order to allow for building bit-identical rpms as described in
https://github.com/rpm-software-management/rpm/pull/144
-------------------------------------------------------------------
Mon Feb 20 14:17:26 CET 2017 - mls@suse.de

View File

@ -59,6 +59,7 @@ Source9: sysconfig.services-rpm
Source10: beecrypt-4.1.2.tar.bz2
Source11: db-4.8.30.tar.bz2
Source12: baselibs.conf
Source13: rpmconfigcheck.service
Patch1: beecrypt-4.1.2.diff
Patch2: db.diff
Patch3: rpm-4.12.0.1-fix-bashisms.patch
@ -125,6 +126,14 @@ Patch76: python3-abi-kind.diff
Patch77: langnoc.diff
Patch78: headerchk2.diff
Patch79: helperenv.diff
# PATCH-FEATURE-UPSTREAM 4.14 0e87aed1785d0531c40b23889f8338744f6abb3a
Patch80: 0001-set-SOURCE_DATE_EPOCH-from-changelog.patch
# PATCH-FEATURE-UPSTREAM 4.14 57f94a582602f0353cdb17a02dc12c4461d4f32d
Patch81: 0002-Extend-changelog-to-support-full-timestamps-903.patch
# PATCH-FEATURE-UPSTREAM 4.14 8d84878ee05b2e63858af3a5a49d98e9e2933b1b
Patch82: 0003-Allow-SOURCE_DATE_EPOCH-to-override-file-timestamps.patch
# PATCH-FEATURE-UPSTREAM 4.14 b8a54d6a1e9bb6140b6b47e23dc707e4b967537e
Patch83: 0004-Allow-SOURCE_DATE_EPOCH-to-override-RPMTAG_BUILDTIME.patch
Patch85: brp-compress-no-img.patch
Patch92: find-lang-python.patch
Patch93: weakdepscompat.diff
@ -176,6 +185,7 @@ Requires: binutils
Requires: bzip2
Requires: coreutils
Requires: diffutils
Requires: dwz
Requires: file
Requires: findutils
Requires: gawk
@ -227,7 +237,7 @@ rm -f rpmdb/db.h
%patch -P 50 -P 51 -P 52 -P 53 -P 54 -P 55 -P 56 -P 57 -P 58
%patch -P 60 -P 61 -P 65 -P 66 -P 67 -P 68 -P 69
%patch -P 70 -P 71 -P 73 -P 74 -P 75 -P 76 -P 77 -P 78 -P 79
%patch -P 85
%patch -P 80 -P 81 -P 82 -P 83 -P 85
%patch -P 92 -P 93 -P 94 -P 96 -P 98 -P 99
%patch -P 100 -P 101 -P 102
@ -300,10 +310,10 @@ install -m 644 db3/db.h %{buildroot}/usr/include/rpm
for f in %{buildroot}/%{_libdir}/*.la; do
sed -i -e "s,/%_lib/libpopt.la,-lpopt,g" $f
done
mkdir -p %{buildroot}/etc/init.d
install -m 755 %{SOURCE8} %{buildroot}/etc/init.d
mkdir -p %{buildroot}/usr/sbin
ln -sf ../../etc/init.d/rpmconfigcheck %{buildroot}/usr/sbin/rcrpmconfigcheck
install -m 755 %{SOURCE8} %{buildroot}/usr/sbin
mkdir -p %{buildroot}/usr/lib/systemd/system
install -m 644 %{SOURCE13} %{buildroot}/usr/lib/systemd/system/
cp -a suse_macros %{buildroot}/usr/lib/rpm
mkdir -p %{buildroot}/usr/lib/rpm/macros.d
mkdir -p %{buildroot}/usr/lib/rpm/suse
@ -392,8 +402,8 @@ rm -f var/lib/rpm/Filemd5s var/lib/rpm/Filedigests var/lib/rpm/Requireversion va
/bin/rpm
/usr/bin/*
%exclude /usr/bin/rpmbuild
/etc/init.d/rpmconfigcheck
/usr/sbin/rcrpmconfigcheck
/usr/sbin/rpmconfigcheck
/usr/lib/systemd/system/rpmconfigcheck.service
/usr/lib/rpm
%{_libdir}/rpm-plugins
%{_libdir}/librpm.so.*

View File

@ -3,78 +3,43 @@
#
# Author: Michael Schroeder <feedback@suse.de>
#
# /etc/init.d/rpmconfigcheck
# /usr/sbin/rcrpmconfigcheck
#
# Script to scan for unresolved .rpmnew, .rpmorig, and .rpmsave files
#
### BEGIN INIT INFO
# Provides: rpmconfigcheck
# Required-Start: $remote_fs
# Required-Stop: $null
# Default-Start: 2 3 5
# Default-Stop:
# Description: rpm config file scan
### END INIT INFO
. /etc/rc.status
# First reset status of this service
rc_reset
configcheckfile=/var/adm/rpmconfigcheck
packages=/var/lib/rpm/Packages
test -z "$1" && set start
case "$1" in
start|restart|try-restart|reload|force-reload)
if test -s $packages -a \( ! -e $configcheckfile -o -s $configcheckfile -o ! $packages -ot $configcheckfile \) ; then
echo -n "Searching for unresolved configuration files"
if test ! -e $configcheckfile -o ! $packages -ot $configcheckfile ; then
test -e $configcheckfile && mv -f $configcheckfile $configcheckfile.old
rpm -qalc | sort | perl -lne '-e "$_.rpmnew" and print "$_.rpmnew"; -e "$_.rpmorig" and print "$_.rpmorig"; -e "$_.rpmsave" and print "$_.rpmsave"' > $configcheckfile
else
mv -f $configcheckfile $configcheckfile.old
while read l; do
test -e $l && echo $l
done < $configcheckfile.old > $configcheckfile
true
fi
rc_status -v
if test -s $configcheckfile; then
echo "Please check the following files (see /var/adm/rpmconfigcheck):"
sed -e 's/^/ /' < $configcheckfile
touch $configcheckfile.old
cat $configcheckfile $configcheckfile.old | sort | uniq -d > $configcheckfile.dup
cat $configcheckfile $configcheckfile.dup | sort | uniq -u > $configcheckfile.new
if test -s $configcheckfile.new ; then
(
echo "----------------------------------------------------------------------"
echo "----------------------------------------------------------------------"
echo "rpmconfigcheck"
date
echo "----------------------------------------"
echo "This is a warning message."
echo "rpmconfigcheck has found the following new unresolved config files"
echo "(all files are listed in /var/adm/rpmconfigcheck):"
cat $configcheckfile.new
echo "----------------------------------------"
) >> /var/log/update-messages
fi
fi
rm -f $configcheckfile.old $configcheckfile.dup $configcheckfile.new
if test -s $packages -a \( ! -e $configcheckfile -o -s $configcheckfile -o ! $packages -ot $configcheckfile \) ; then
echo "Searching for unresolved configuration files"
if test ! -e $configcheckfile -o ! $packages -ot $configcheckfile ; then
test -e $configcheckfile && mv -f $configcheckfile $configcheckfile.old
rpm -qalc | sort | perl -lne '-e "$_.rpmnew" and print "$_.rpmnew"; -e "$_.rpmorig" and print "$_.rpmorig"; -e "$_.rpmsave" and print "$_.rpmsave"' > $configcheckfile
else
mv -f $configcheckfile $configcheckfile.old
while read l; do
test -e $l && echo $l
done < $configcheckfile.old > $configcheckfile
fi
if test -s $configcheckfile; then
echo "Please check the following files (see /var/adm/rpmconfigcheck):"
sed -e 's/^/ /' < $configcheckfile
touch $configcheckfile.old
cat $configcheckfile $configcheckfile.old | sort | uniq -d > $configcheckfile.dup
cat $configcheckfile $configcheckfile.dup | sort | uniq -u > $configcheckfile.new
if test -s $configcheckfile.new ; then
(
echo "----------------------------------------------------------------------"
echo "----------------------------------------------------------------------"
echo "rpmconfigcheck"
date
echo "----------------------------------------"
echo "This is a warning message."
echo "rpmconfigcheck has found the following new unresolved config files"
echo "(all files are listed in /var/adm/rpmconfigcheck):"
cat $configcheckfile.new
echo "----------------------------------------"
) >> /var/log/update-messages
fi
;;
stop)
;;
status)
rc_failed 4
rc_status -v
;;
*)
echo "Usage: $0 {start}"
exit 1
;;
esac
rc_exit
fi
rm -f $configcheckfile.old $configcheckfile.dup $configcheckfile.new
fi

10
rpmconfigcheck.service Normal file
View File

@ -0,0 +1,10 @@
[Unit]
Description=Scan for unresolved .rpmnew, .rpmorig, and .rpmsave files
After=local-fs.target
[Service]
Type=oneshot
ExecStart=/usr/sbin/rpmconfigcheck
[Install]
WantedBy=default.target