From 18d1f2f4ad48629dfa76fd49b614ee044c2a6b539251f7db164effb2db099294 Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Thu, 9 Mar 2017 08:40:16 +0000 Subject: [PATCH 1/7] Accepting request 476984 from home:bmwiedemann:branches:Base:System rebased - 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 OBS-URL: https://build.opensuse.org/request/show/476984 OBS-URL: https://build.opensuse.org/package/show/Base:System/rpm?expand=0&rev=384 --- ...set-SOURCE_DATE_EPOCH-from-changelog.patch | 62 ++++++ ...gelog-to-support-full-timestamps-903.patch | 191 ++++++++++++++++++ ...TE_EPOCH-to-override-file-timestamps.patch | 82 ++++++++ ...E_EPOCH-to-override-RPMTAG_BUILDTIME.patch | 50 +++++ rpm.changes | 10 + rpm.spec | 10 +- 6 files changed, 404 insertions(+), 1 deletion(-) create mode 100644 0001-set-SOURCE_DATE_EPOCH-from-changelog.patch create mode 100644 0002-Extend-changelog-to-support-full-timestamps-903.patch create mode 100644 0003-Allow-SOURCE_DATE_EPOCH-to-override-file-timestamps.patch create mode 100644 0004-Allow-SOURCE_DATE_EPOCH-to-override-RPMTAG_BUILDTIME.patch diff --git a/0001-set-SOURCE_DATE_EPOCH-from-changelog.patch b/0001-set-SOURCE_DATE_EPOCH-from-changelog.patch new file mode 100644 index 0000000..870d8ec --- /dev/null +++ b/0001-set-SOURCE_DATE_EPOCH-from-changelog.patch @@ -0,0 +1,62 @@ +From 42906a9c5da4c89128ed8ffb619f8ef1fa2d9b93 Mon Sep 17 00:00:00 2001 +From: "Bernhard M. Wiedemann" +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 + diff --git a/0002-Extend-changelog-to-support-full-timestamps-903.patch b/0002-Extend-changelog-to-support-full-timestamps-903.patch new file mode 100644 index 0000000..8914d04 --- /dev/null +++ b/0002-Extend-changelog-to-support-full-timestamps-903.patch @@ -0,0 +1,191 @@ +From b74958824c7e0d7c12550ba22d9b31da040d2cd4 Mon Sep 17 00:00:00 2001 +From: Pavlina +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 + diff --git a/0003-Allow-SOURCE_DATE_EPOCH-to-override-file-timestamps.patch b/0003-Allow-SOURCE_DATE_EPOCH-to-override-file-timestamps.patch new file mode 100644 index 0000000..54a5dd8 --- /dev/null +++ b/0003-Allow-SOURCE_DATE_EPOCH-to-override-file-timestamps.patch @@ -0,0 +1,82 @@ +From f2aa612c5a2a99e1186853a3d00d43607bdc6aa2 Mon Sep 17 00:00:00 2001 +From: "Bernhard M. Wiedemann" +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 + +(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 ++#include + #include + #if WITH_CAP + #include +@@ -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 + diff --git a/0004-Allow-SOURCE_DATE_EPOCH-to-override-RPMTAG_BUILDTIME.patch b/0004-Allow-SOURCE_DATE_EPOCH-to-override-RPMTAG_BUILDTIME.patch new file mode 100644 index 0000000..04529a4 --- /dev/null +++ b/0004-Allow-SOURCE_DATE_EPOCH-to-override-RPMTAG_BUILDTIME.patch @@ -0,0 +1,50 @@ +From 686ff4634d69999740c93eea761b09c3fb17c2f6 Mon Sep 17 00:00:00 2001 +From: Nicolas Vigier +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 +(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 + diff --git a/rpm.changes b/rpm.changes index d7fef1e..14f6798 100644 --- a/rpm.changes +++ b/rpm.changes @@ -10,6 +10,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 diff --git a/rpm.spec b/rpm.spec index 6c67efa..3e12211 100644 --- a/rpm.spec +++ b/rpm.spec @@ -125,6 +125,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 @@ -227,7 +235,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 From ff91377c678d5119d7cf2f58e3b935dfb416d7f88cd01e9840ff6c61935a2c11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Schr=C3=B6der?= Date: Mon, 20 Mar 2017 16:57:43 +0000 Subject: [PATCH 2/7] Accepting request 477417 from home:rguenther:branches:Base:System - 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] OBS-URL: https://build.opensuse.org/request/show/477417 OBS-URL: https://build.opensuse.org/package/show/Base:System/rpm?expand=0&rev=385 --- debugsubpkg.diff | 242 +++++++++++++++++++++++++++++++++++++++-------- macrosin.diff | 38 ++++++-- rpm.changes | 8 ++ rpm.spec | 1 + 4 files changed, 239 insertions(+), 50 deletions(-) diff --git a/debugsubpkg.diff b/debugsubpkg.diff index 30dde08..21bb36d 100644 --- a/debugsubpkg.diff +++ b/debugsubpkg.diff @@ -1,7 +1,9 @@ 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 +Index: build/files.c +=================================================================== +--- build/files.c.orig 2017-02-16 10:52:49.292092380 +0100 ++++ build/files.c 2017-02-22 15:17:39.066161045 +0100 @@ -21,6 +21,10 @@ #include #include @@ -13,7 +15,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,298 @@ exit: return rc; } @@ -22,7 +24,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,8 +72,9 @@ 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. */ @@ -139,15 +142,49 @@ 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) ++{ ++ static int handled_dwz = 1; + const char *a; + + elf_version(EV_CURRENT); + 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 +232,49 @@ 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"); ++ { ++ argvAdd(&files, "%dir /usr/lib/debug/.build-id"); ++ if (!handled_dwz) ++ { ++ handled_dwz = 1; ++ /* For now put the shared data from .dwz into the ++ first package we process. ++ ??? Ideally we do this in a postprocessing ++ step after building all -debuginfo packages. */ ++ snprintf(tmp, 1024, "%s%s", buildroot, ++ "/usr/lib/debug/.dwz"); ++ if (lstat(tmp, &sbuf) == 0 && S_ISDIR(sbuf.st_mode)) ++ { ++ DIR *d; ++ struct dirent *de; ++ argvAdd(&files, "/usr/lib/debug/.dwz"); ++ d = opendir (tmp); ++ while ((de = readdir (d))) ++ { ++ unsigned char *build_id2 = NULL; ++ size_t build_id_size2 = 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_id2, ++ &build_id_size2) == -1) ++ continue; ++ snprintf(tmp, 1024, ++ "/usr/lib/debug/.build-id/%02x/", ++ build_id2[0]); ++ for (i = 1; i < build_id_size2; ++i) ++ sprintf(tmp + strlen(tmp), "%02x", build_id2[i]); ++ sprintf(tmp + strlen(tmp), ".debug"); ++ argvAdd(&files, tmp); ++ free (build_id2); ++ } ++ closedir (d); ++ } ++ } ++ } + + /* From the build-id construct the two links pointing back + to the debug information file and the binary. */ @@ -213,30 +292,9 @@ 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; +} +#endif + @@ -246,29 +304,122 @@ 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[41] = { '\0' } ; 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 +@@ -2171,7 +2460,7 @@ rpmRC processBinaryFiles(rpmSpec spec, r + int arch_color; + + if (pkg->fileList == NULL) +- continue; ++ continue; + + headerPutString(pkg->header, RPMTAG_SOURCERPM, spec->sourceRpmName); + +@@ -2179,8 +2468,90 @@ 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) ++ { ++ char tmp[1024]; ++ struct stat sbuf; ++ int i; ++ ARGV_t files = NULL; ++ /* 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. */ ++ if (! first_dbg->next ++ || main_pkg_got_dbg) ++ files = first_dbg->fileList; ++ ++ processing_dbg = 1; ++ ++ snprintf(tmp, 1024, "%s%s", buildroot, ++ "/usr/lib/debug/.dwz"); ++ if (lstat(tmp, &sbuf) == 0 && S_ISDIR(sbuf.st_mode)) ++ { ++ DIR *d; ++ struct dirent *de; ++ argvAdd(&files, "/usr/lib/debug/.dwz"); ++ d = opendir (tmp); ++ 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]); ++ sprintf(dwz_dbg_buildid, "%02x", build_id[0]); ++ for (i = 1; i < build_id_size; ++i) ++ { ++ sprintf(tmp + strlen(tmp), "%02x", build_id[i]); ++ sprintf(dwz_dbg_buildid + strlen(dwz_dbg_buildid), ++ "%02x", build_id[i]); ++ } ++ sprintf(tmp + strlen(tmp), ".debug"); ++ argvAdd(&files, tmp); ++ free (build_id); ++ } ++ closedir (d); ++ } ++ if (! first_dbg->next ++ || main_pkg_got_dbg) ++ { ++ first_dbg->fileList = files; ++ dwz_dbg = pkg; ++ } ++ else ++ 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. */ ++ else if (dwz_dbg_buildid[0] ++ && 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 +Index: build/parseSpec.c +=================================================================== +--- build/parseSpec.c.orig 2017-02-21 12:39:50.036450319 +0100 ++++ build/parseSpec.c 2017-02-21 12:39:50.072450885 +0100 @@ -564,7 +564,7 @@ static void initSourceHeader(rpmSpec spe } @@ -278,8 +429,10 @@ 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 +Index: build/rpmbuild_internal.h +=================================================================== +--- build/rpmbuild_internal.h.orig 2017-02-16 10:40:09.788649545 +0100 ++++ build/rpmbuild_internal.h 2017-02-21 12:39:50.072450885 +0100 @@ -442,6 +442,13 @@ int addReqProv(Package pkg, rpmTagVal ta @@ -294,8 +447,10 @@ 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 +Index: macros.in +=================================================================== +--- macros.in.orig 2017-02-21 12:39:50.060450696 +0100 ++++ macros.in 2017-02-21 15:39:02.817639317 +0100 @@ -186,24 +186,10 @@ # Template for debug information sub-package. %debug_package \ @@ -321,8 +476,10 @@ 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 +Index: scripts/find-debuginfo.sh +=================================================================== +--- scripts/find-debuginfo.sh.orig 2017-02-21 12:39:50.016450005 +0100 ++++ scripts/find-debuginfo.sh 2017-02-21 15:39:03.265646371 +0100 @@ -220,6 +220,11 @@ debug_link() # Provide .2, .3, ... symlinks to all filename instances of this build-id. make_id_dup_link() @@ -360,3 +517,4 @@ Create a debuginfo package for each subpackage. if [ -s "$SOURCEFILE" ]; then mkdir -p "${RPM_BUILD_ROOT}/usr/src/debug" + diff --git a/macrosin.diff b/macrosin.diff index 1b37ddc..111967d 100644 --- a/macrosin.diff +++ b/macrosin.diff @@ -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 #*/ diff --git a/rpm.changes b/rpm.changes index 14f6798..c688697 100644 --- a/rpm.changes +++ b/rpm.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +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 diff --git a/rpm.spec b/rpm.spec index 3e12211..6a354fc 100644 --- a/rpm.spec +++ b/rpm.spec @@ -184,6 +184,7 @@ Requires: binutils Requires: bzip2 Requires: coreutils Requires: diffutils +Requires: dwz Requires: file Requires: findutils Requires: gawk From 3b630e456581ad1969337749eec24a421a3c6a8ead2f87d7782a92470e1f1f90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Schr=C3=B6der?= Date: Wed, 22 Mar 2017 11:56:38 +0000 Subject: [PATCH 3/7] Update debugsubpkg.diff OBS-URL: https://build.opensuse.org/package/show/Base:System/rpm?expand=0&rev=386 --- debugsubpkg.diff | 219 +++++++++++++++++------------------------------ 1 file changed, 80 insertions(+), 139 deletions(-) diff --git a/debugsubpkg.diff b/debugsubpkg.diff index 21bb36d..19e20bb 100644 --- a/debugsubpkg.diff +++ b/debugsubpkg.diff @@ -1,9 +1,7 @@ Create a debuginfo package for each subpackage. -Index: build/files.c -=================================================================== ---- build/files.c.orig 2017-02-16 10:52:49.292092380 +0100 -+++ build/files.c 2017-02-22 15:17:39.066161045 +0100 +--- ./build/files.c.orig 2017-02-16 09:52:49.292092380 +0000 ++++ ./build/files.c 2017-03-22 11:55:13.814882170 +0000 @@ -21,6 +21,10 @@ #include #include @@ -15,7 +13,7 @@ Index: build/files.c #include "rpmio/rpmio_internal.h" /* XXX rpmioSlurp */ #include "misc/fts.h" #include "lib/rpmfi_internal.h" /* XXX fi->apath */ -@@ -2155,13 +2159,298 @@ exit: +@@ -2155,13 +2159,301 @@ exit: return rc; } @@ -178,7 +176,6 @@ Index: build/files.c + +static Package processDebuginfo(rpmSpec spec, Package pkg, char *buildroot) +{ -+ static int handled_dwz = 1; + const char *a; + + elf_version(EV_CURRENT); @@ -233,47 +230,8 @@ Index: build/files.c + directory. */ + if (!seen_build_id) + { ++ seen_build_id = 1; + argvAdd(&files, "%dir /usr/lib/debug/.build-id"); -+ if (!handled_dwz) -+ { -+ handled_dwz = 1; -+ /* For now put the shared data from .dwz into the -+ first package we process. -+ ??? Ideally we do this in a postprocessing -+ step after building all -debuginfo packages. */ -+ snprintf(tmp, 1024, "%s%s", buildroot, -+ "/usr/lib/debug/.dwz"); -+ if (lstat(tmp, &sbuf) == 0 && S_ISDIR(sbuf.st_mode)) -+ { -+ DIR *d; -+ struct dirent *de; -+ argvAdd(&files, "/usr/lib/debug/.dwz"); -+ d = opendir (tmp); -+ while ((de = readdir (d))) -+ { -+ unsigned char *build_id2 = NULL; -+ size_t build_id_size2 = 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_id2, -+ &build_id_size2) == -1) -+ continue; -+ snprintf(tmp, 1024, -+ "/usr/lib/debug/.build-id/%02x/", -+ build_id2[0]); -+ for (i = 1; i < build_id_size2; ++i) -+ sprintf(tmp + strlen(tmp), "%02x", build_id2[i]); -+ sprintf(tmp + strlen(tmp), ".debug"); -+ argvAdd(&files, tmp); -+ free (build_id2); -+ } -+ closedir (d); -+ } -+ } + } + + /* From the build-id construct the two links pointing back @@ -296,6 +254,49 @@ Index: build/files.c + } + 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; ++ ++ 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, @@ -307,108 +308,49 @@ Index: build/files.c + Package first_dbg = NULL, dwz_dbg = NULL; + int processing_dbg = 0; + int main_pkg_got_dbg = 0; -+ char dwz_dbg_buildid[41] = { '\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) { -@@ -2171,7 +2460,7 @@ rpmRC processBinaryFiles(rpmSpec spec, r - int arch_color; - - if (pkg->fileList == NULL) -- continue; -+ continue; - - headerPutString(pkg->header, RPMTAG_SOURCERPM, spec->sourceRpmName); - -@@ -2179,8 +2468,90 @@ rpmRC processBinaryFiles(rpmSpec spec, r +@@ -2179,8 +2471,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) -+ { -+ char tmp[1024]; -+ struct stat sbuf; -+ int i; -+ ARGV_t files = NULL; ++ 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. */ -+ if (! first_dbg->next -+ || main_pkg_got_dbg) -+ files = first_dbg->fileList; -+ + processing_dbg = 1; -+ -+ snprintf(tmp, 1024, "%s%s", buildroot, -+ "/usr/lib/debug/.dwz"); -+ if (lstat(tmp, &sbuf) == 0 && S_ISDIR(sbuf.st_mode)) -+ { -+ DIR *d; -+ struct dirent *de; -+ argvAdd(&files, "/usr/lib/debug/.dwz"); -+ d = opendir (tmp); -+ 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]); -+ sprintf(dwz_dbg_buildid, "%02x", build_id[0]); -+ for (i = 1; i < build_id_size; ++i) -+ { -+ sprintf(tmp + strlen(tmp), "%02x", build_id[i]); -+ sprintf(dwz_dbg_buildid + strlen(dwz_dbg_buildid), -+ "%02x", build_id[i]); -+ } -+ sprintf(tmp + strlen(tmp), ".debug"); -+ argvAdd(&files, tmp); -+ free (build_id); -+ } -+ closedir (d); -+ } -+ if (! first_dbg->next -+ || main_pkg_got_dbg) -+ { -+ first_dbg->fileList = files; ++ if (!first_dbg->next || main_pkg_got_dbg) { ++ dwz_dbg_buildid = addDebugDWZ(&first_dbg->fileList, buildroot); + dwz_dbg = pkg; -+ } -+ else -+ dwz_dbg = addDebuginfoPackage (spec, spec->packages, files); -+ } ++ } 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 -+ if (! processing_dbg) -+ { ++ if (!processing_dbg) { + Package dbg = processDebuginfo(spec, pkg, buildroot); -+ if (dbg && ! first_dbg) -+ { ++ if (dbg && !first_dbg) { + first_dbg = dbg; + if (pkg == spec->packages) -+ main_pkg_got_dbg = 1; -+ } -+ } ++ main_pkg_got_dbg = 1; ++ } ++ } + /* If we have DWZ info and it is not in PKG then add a requires. */ -+ else if (dwz_dbg_buildid[0] -+ && pkg != dwz_dbg) ++ if (dwz_dbg_buildid && pkg != dwz_dbg) + addReqProv(pkg, RPMTAG_REQUIRENAME, + "debuginfo(build-id)", dwz_dbg_buildid, RPMSENSE_EQUAL, 0); +#endif @@ -416,10 +358,16 @@ Index: build/files.c goto exit; a = headerGetString(pkg->header, RPMTAG_ARCH); -Index: build/parseSpec.c -=================================================================== ---- build/parseSpec.c.orig 2017-02-21 12:39:50.036450319 +0100 -+++ build/parseSpec.c 2017-02-21 12:39:50.072450885 +0100 +@@ -2215,6 +2539,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 11:52:02.332400093 +0000 ++++ ./build/parseSpec.c 2017-03-22 11:52:43.249280459 +0000 @@ -564,7 +564,7 @@ static void initSourceHeader(rpmSpec spe } @@ -429,10 +377,8 @@ Index: build/parseSpec.c { const char *arch, *name; char *evr, *isaprov; -Index: build/rpmbuild_internal.h -=================================================================== ---- build/rpmbuild_internal.h.orig 2017-02-16 10:40:09.788649545 +0100 -+++ build/rpmbuild_internal.h 2017-02-21 12:39:50.072450885 +0100 +--- ./build/rpmbuild_internal.h.orig 2017-02-16 09:40:09.788649545 +0000 ++++ ./build/rpmbuild_internal.h 2017-03-22 11:52:43.249280459 +0000 @@ -442,6 +442,13 @@ int addReqProv(Package pkg, rpmTagVal ta @@ -447,10 +393,8 @@ Index: build/rpmbuild_internal.h * Add rpmlib feature dependency. * @param pkg package * @param feature rpm feature name (i.e. "rpmlib(Foo)" for feature Foo) -Index: macros.in -=================================================================== ---- macros.in.orig 2017-02-21 12:39:50.060450696 +0100 -+++ macros.in 2017-02-21 15:39:02.817639317 +0100 +--- ./macros.in.orig 2017-03-22 11:52:02.335400084 +0000 ++++ ./macros.in 2017-03-22 11:52:43.250280456 +0000 @@ -186,24 +186,10 @@ # Template for debug information sub-package. %debug_package \ @@ -476,10 +420,8 @@ Index: macros.in %description debugsource\ This package provides debug sources for package %{name}.\ Debug sources are useful when developing applications that use this\ -Index: scripts/find-debuginfo.sh -=================================================================== ---- scripts/find-debuginfo.sh.orig 2017-02-21 12:39:50.016450005 +0100 -+++ scripts/find-debuginfo.sh 2017-02-21 15:39:03.265646371 +0100 +--- ./scripts/find-debuginfo.sh.orig 2017-03-22 11:52:02.331400096 +0000 ++++ ./scripts/find-debuginfo.sh 2017-03-22 11:52:43.250280456 +0000 @@ -220,6 +220,11 @@ debug_link() # Provide .2, .3, ... symlinks to all filename instances of this build-id. make_id_dup_link() @@ -517,4 +459,3 @@ Index: scripts/find-debuginfo.sh if [ -s "$SOURCEFILE" ]; then mkdir -p "${RPM_BUILD_ROOT}/usr/src/debug" - From 0e3494a2aa30e0cb18372156075eef499fb89ccfae305c2edb37d07dc5829841 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Schr=C3=B6der?= Date: Wed, 22 Mar 2017 12:12:21 +0000 Subject: [PATCH 4/7] Update OBS-URL: https://build.opensuse.org/package/show/Base:System/rpm?expand=0&rev=387 --- debugsubpkg.diff | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/debugsubpkg.diff b/debugsubpkg.diff index 19e20bb..de7bcb3 100644 --- a/debugsubpkg.diff +++ b/debugsubpkg.diff @@ -1,7 +1,5 @@ -Create a debuginfo package for each subpackage. - --- ./build/files.c.orig 2017-02-16 09:52:49.292092380 +0000 -+++ ./build/files.c 2017-03-22 11:55:13.814882170 +0000 ++++ ./build/files.c 2017-03-22 12:11:05.013909767 +0000 @@ -21,6 +21,10 @@ #include #include @@ -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 */ -@@ -2155,13 +2159,301 @@ exit: +@@ -2155,13 +2159,302 @@ exit: return rc; } @@ -263,6 +261,7 @@ Create a debuginfo package for each subpackage. + 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)) @@ -315,7 +314,7 @@ Create a debuginfo package for each subpackage. genSourceRpmName(spec); for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) { -@@ -2179,8 +2471,40 @@ rpmRC processBinaryFiles(rpmSpec spec, r +@@ -2179,8 +2472,40 @@ rpmRC processBinaryFiles(rpmSpec spec, r rpmlog(RPMLOG_NOTICE, _("Processing files: %s\n"), nvr); free(nvr); @@ -358,7 +357,7 @@ Create a debuginfo package for each subpackage. goto exit; a = headerGetString(pkg->header, RPMTAG_ARCH); -@@ -2215,6 +2539,7 @@ rpmRC processBinaryFiles(rpmSpec spec, r +@@ -2215,6 +2540,7 @@ rpmRC processBinaryFiles(rpmSpec spec, r } exit: check_fileList = freeStringBuf(check_fileList); @@ -366,8 +365,8 @@ Create a debuginfo package for each subpackage. return rc; } ---- ./build/parseSpec.c.orig 2017-03-22 11:52:02.332400093 +0000 -+++ ./build/parseSpec.c 2017-03-22 11:52:43.249280459 +0000 +--- ./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 } @@ -378,7 +377,7 @@ Create a debuginfo package for each subpackage. const char *arch, *name; char *evr, *isaprov; --- ./build/rpmbuild_internal.h.orig 2017-02-16 09:40:09.788649545 +0000 -+++ ./build/rpmbuild_internal.h 2017-03-22 11:52:43.249280459 +0000 ++++ ./build/rpmbuild_internal.h 2017-03-22 12:10:20.143010339 +0000 @@ -442,6 +442,13 @@ int addReqProv(Package pkg, rpmTagVal ta @@ -393,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-03-22 11:52:02.335400084 +0000 -+++ ./macros.in 2017-03-22 11:52:43.250280456 +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 \ @@ -420,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-03-22 11:52:02.331400096 +0000 -+++ ./scripts/find-debuginfo.sh 2017-03-22 11:52:43.250280456 +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() From 8a9e054bba993977bbf99d399b985899f5f6bb8800f4675779126c594e5c2d70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Schr=C3=B6der?= Date: Wed, 22 Mar 2017 12:16:00 +0000 Subject: [PATCH 5/7] get rid off pointer-arith warnings OBS-URL: https://build.opensuse.org/package/show/Base:System/rpm?expand=0&rev=388 --- debugsubpkg.diff | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/debugsubpkg.diff b/debugsubpkg.diff index de7bcb3..1d825e5 100644 --- a/debugsubpkg.diff +++ b/debugsubpkg.diff @@ -1,5 +1,5 @@ --- ./build/files.c.orig 2017-02-16 09:52:49.292092380 +0000 -+++ ./build/files.c 2017-03-22 12:11:05.013909767 +0000 ++++ ./build/files.c 2017-03-22 12:15:29.060287267 +0000 @@ -21,6 +21,10 @@ #include #include @@ -77,24 +77,24 @@ + 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) @@ -106,7 +106,7 @@ + + *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); From f5955f21b5f965af3bdda8f0154c09624b1f3074f83e3ef7963b17ec9f2d6a3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Schr=C3=B6der?= Date: Wed, 22 Mar 2017 13:33:48 +0000 Subject: [PATCH 6/7] Fix it OBS-URL: https://build.opensuse.org/package/show/Base:System/rpm?expand=0&rev=389 --- debugsubpkg.diff | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debugsubpkg.diff b/debugsubpkg.diff index 1d825e5..006ae35 100644 --- a/debugsubpkg.diff +++ b/debugsubpkg.diff @@ -1,5 +1,5 @@ --- ./build/files.c.orig 2017-02-16 09:52:49.292092380 +0000 -+++ ./build/files.c 2017-03-22 12:15:29.060287267 +0000 ++++ ./build/files.c 2017-03-22 13:32:42.911865500 +0000 @@ -21,6 +21,10 @@ #include #include @@ -264,7 +264,7 @@ + int i; + + snprintf(tmp, 1024, "%s%s", buildroot, "/usr/lib/debug/.dwz"); -+ if (lstat(tmp, &sbuf) == 0 && S_ISDIR(sbuf.st_mode)) ++ if (lstat(tmp, &sbuf) != 0 || !S_ISDIR(sbuf.st_mode)) + return NULL; + d = opendir(tmp); + if (!d) From 7e7de860a398b7d3ad8c07c2164cec22f468e50dbd57c8ea02348f2583ec6b82 Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Wed, 29 Mar 2017 12:08:58 +0000 Subject: [PATCH 7/7] Accepting request 482469 from home:kukuk:branches:Base:System - Convert rpmconfigcheck init script to systemd unit OBS-URL: https://build.opensuse.org/request/show/482469 OBS-URL: https://build.opensuse.org/package/show/Base:System/rpm?expand=0&rev=390 --- rpm.changes | 5 ++ rpm.spec | 11 +++-- rpmconfigcheck | 101 ++++++++++++++--------------------------- rpmconfigcheck.service | 10 ++++ 4 files changed, 54 insertions(+), 73 deletions(-) create mode 100644 rpmconfigcheck.service diff --git a/rpm.changes b/rpm.changes index c688697..debbaf5 100644 --- a/rpm.changes +++ b/rpm.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +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 diff --git a/rpm.spec b/rpm.spec index 6a354fc..9c7e1bd 100644 --- a/rpm.spec +++ b/rpm.spec @@ -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 @@ -309,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 @@ -401,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.* diff --git a/rpmconfigcheck b/rpmconfigcheck index a4152f9..b6b4471 100644 --- a/rpmconfigcheck +++ b/rpmconfigcheck @@ -3,78 +3,43 @@ # # Author: Michael Schroeder # -# /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 diff --git a/rpmconfigcheck.service b/rpmconfigcheck.service new file mode 100644 index 0000000..9bb9890 --- /dev/null +++ b/rpmconfigcheck.service @@ -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