[Rpm-maint] [PATCH] find-debuginfo.sh: Don't create dwz multi file if there is only one .debug.

2017-06-26 Thread Mark Wielaard
dwz -m multi only works when there are multiple .debug input files.
With just one .debug file it doesn't really make sense to extract
the shared debug info into a separate file and dwz will complain:

  dwz: Too few files for multifile optimization.

So only add -m multi if there is more than one .debug file.

Signed-off-by: Mark Wielaard 
---
 scripts/find-debuginfo.sh | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/scripts/find-debuginfo.sh b/scripts/find-debuginfo.sh
index aaf4c75..7ab39a2 100755
--- a/scripts/find-debuginfo.sh
+++ b/scripts/find-debuginfo.sh
@@ -442,8 +442,8 @@ fi
 # Invoke the DWARF Compressor utility.
 if $run_dwz \
&& [ -d "${RPM_BUILD_ROOT}/usr/lib/debug" ]; then
-  dwz_files="`cd "${RPM_BUILD_ROOT}/usr/lib/debug"; find -type f -name 
\*.debug`"
-  if [ -n "${dwz_files}" ]; then
+  readarray dwz_files < <(cd "${RPM_BUILD_ROOT}/usr/lib/debug"; find -type f 
-name \*.debug)
+  if [ ${#dwz_files[@]} -gt 0 ]; then
 
dwz_multifile_name="${RPM_PACKAGE_NAME}-${RPM_PACKAGE_VERSION}-${RPM_PACKAGE_RELEASE}.${RPM_ARCH}"
 dwz_multifile_suffix=
 dwz_multifile_idx=0
@@ -452,14 +452,16 @@ if $run_dwz \
   dwz_multifile_suffix=".${dwz_multifile_idx}"
 done
 dwz_multfile_name="${dwz_multifile_name}${dwz_multifile_suffix}"
-dwz_opts="-h -q -r -m .dwz/${dwz_multifile_name}"
+dwz_opts="-h -q -r"
+[ ${#dwz_files[@]} -gt 1 ] \
+  && dwz_opts="${dwz_opts} -m .dwz/${dwz_multifile_name}"
 mkdir -p "${RPM_BUILD_ROOT}/usr/lib/debug/.dwz"
 [ -n "${dwz_low_mem_die_limit}" ] \
   && dwz_opts="${dwz_opts} -l ${dwz_low_mem_die_limit}"
 [ -n "${dwz_max_die_limit}" ] \
   && dwz_opts="${dwz_opts} -L ${dwz_max_die_limit}"
 if type dwz >/dev/null 2>&1; then
-  ( cd "${RPM_BUILD_ROOT}/usr/lib/debug" && dwz $dwz_opts $dwz_files )
+  ( cd "${RPM_BUILD_ROOT}/usr/lib/debug" && dwz $dwz_opts ${dwz_files[@]} )
 else
   echo >&2 "*** ERROR: DWARF compression requested, but no dwz installed"
   exit 2
-- 
1.8.3.1

___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


[Rpm-maint] [PATCH] Update find-debuginfo.sh options and macros documentation.

2017-06-26 Thread Mark Wielaard
This adds some missing documentation for rpm macros and find-debuginfo.sh
options that were recently added (or renamed). -j N, --build-id-seed SEED,
--unique-debug-suffix SUFFIX and --unique-debug-src-base BASE.

Signed-off-by: Mark Wielaard 
---
 macros.in | 14 --
 scripts/find-debuginfo.sh | 28 ++--
 2 files changed, 30 insertions(+), 12 deletions(-)

diff --git a/macros.in b/macros.in
index a2c15ad..78352a8 100644
--- a/macros.in
+++ b/macros.in
@@ -522,8 +522,9 @@ package or when debugging this package.\
 
 # Whether build-ids should be made unique between package version/releases
 # when generating debuginfo packages. If set to 1 this will pass
-# --ver-rel "%{VERSION}-%{RELEASE}" to find-debuginfo.sh which will pass it
-# onto debugedit --build-id-seed to be used to prime the build-id note hash.
+# --build-id-seed "%{VERSION}-%{RELEASE}" to find-debuginfo.sh which will
+# pass it onto debugedit --build-id-seed to be used to prime the build-id
+# note hash.
 %_unique_build_ids 1
 
 # Do not recompute build-ids but keep whatever is in the ELF file already.
@@ -533,15 +534,16 @@ package or when debugging this package.\
 
 # Whether .debug files should be made unique between package version,
 # release and architecture. If set to 1 this will pass
-# --unique-debug-arch "%{_arch}" to find-debuginfo.sh to create
-# debuginfo files which end in --..debug
+# --unique-debug-suffix "-%{VERSION}-%{RELEASE}.%{_arch} find-debuginfo.sh
+# to create debuginfo files which end in --..debug
 # Requires _unique_build_ids.
 %_unique_debug_names   1
 
 # Whether the /usr/debug/src/ directories should be unique between
 # package version, release and architecture. If set to 1 this will pass
-# --unique-debug-src-base "%{name}" to find-debuginfo.sh to name the
-# directory under /usr/debug/src as --.
+# --unique-debug-src-base "%{name}-%{VERSION}-%{RELEASE}.%{_arch}" to
+# find-debuginfo.sh to name the directory under /usr/debug/src as
+# --..
 %_unique_debug_srcs1
 
 # Whether rpm should put debug source files into its own subpackage
diff --git a/scripts/find-debuginfo.sh b/scripts/find-debuginfo.sh
index aaf4c75..0511777 100755
--- a/scripts/find-debuginfo.sh
+++ b/scripts/find-debuginfo.sh
@@ -3,11 +3,14 @@
 #for inclusion in an rpm spec file.
 #
 # Usage: find-debuginfo.sh [--strict-build-id] [-g] [-r] [-m] [-i] [-n]
+# [-j N]
 # [-o debugfiles.list]
 # [-S debugsourcefiles.list]
 # [--run-dwz] [--dwz-low-mem-die-limit N]
 # [--dwz-max-die-limit N]
-# [--build-id-seed VERSION-RELEASE]
+# [--build-id-seed SEED]
+# [--unique-debug-suffix SUFFIX]
+# [--unique-debug-src-base BASE]
 # [[-l filelist]... [-p 'pattern'] -o debuginfo.list]
 # [builddir]
 #
@@ -19,6 +22,9 @@
 # The -i flag says to include a .gdb_index section in the .debug file.
 # The -n flag says to not recompute the build-id.
 #
+# The -j N option will spawn N processes to do the debuginfo extraction
+# in parallel.
+#
 # A single -o switch before any -l or -p switches simply renames
 # the primary output file from debugfiles.list to something else.
 # A -o switch that follows a -p switch or some -l switches produces
@@ -31,11 +37,21 @@
 # if available, and --dwz-low-mem-die-limit and --dwz-max-die-limit
 # provide detailed limits.  See dwz(1) -l and -L option for details.
 #
-# If --build-id-seed VERSION-RELEASE is given then debugedit is called to
-# update the build-ids it finds adding the VERSION-RELEASE string as
-# seed to recalculate the build-id hash.  This makes sure the
-# build-ids in the ELF files are unique between versions and releases
-# of the same package.
+# If --build-id-seed SEED is given then debugedit is called to
+# update the build-ids it finds adding the SEED as seed to recalculate
+# the build-id hash.  This makes sure the build-ids in the ELF files
+# are unique between versions and releases of the same package.
+# (Use --build-id-seed "%{VERSION}-%{RELEASE}".)
+#
+# If --unique-debug-suffix SUFFIX is given then the debug files created
+# for  will be named -.debug.  This makes sure .debug
+# are unique between package version, release and architecture.
+# (Use --unique-debug-suffix "-%{VERSION}-%{RELEASE}.%{_arch}".)
+#
+# If --unique-debug-src-base BASE is given then the source directory
+# will be called /usr/debug/src/.  This makes sure the debug source
+# directories are unique between package version, release and architecture.
+# (Use --unique-debug-src-base "%{name}-%{VERSION}-%{RELEASE}.%{_arch}".)
 #
 # All file names in switches are relative to builddir (. if not given).
 #
-- 
1.8.3.1

___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org

Re: [Rpm-maint] [PATCH] Use a file list to add build-id files to pkgList and explicitly set attrs.

2017-06-26 Thread Panu Matilainen

On 06/22/2017 04:31 PM, Mark Wielaard wrote:

Hi,

Panu sadi on irc he didn't like the duplication of code that parsed the
spec file lists. So this updated patch extracts the setup and parsing
loop in their own function and just calls them twice. I also reformatted
the patch a little so the whitespace differences are minimal.



Hey, sorry for not responding to this earlier, been on PTOs on and off 
and between them just just forgot the whole thing.


For whatever reason the patch is was attached instead of inline so 
harder to comment, but I think we can make do:


Please do the refactor to helper function(s) in a separate patch from 
the rest of the changes, it'll be easier to review and bisect too if it 
ever comes to that.


mkattr() with non-NULL fn argument ceases to be meaningful here, and 
since it's not even used for anything, whether the mode should be 644 or 
755 nobody knows, certainly not that function. Better just drop 
non-defattr case from it entirely.


Finally, I've no particular objections to changing it this way, but it's 
not as obvious win (ends up actually being more code) as at least I 
initially thought. I've attached (apologies for dumb email clients) a 
more minimal version that should do just the same: enforce a sane 
%defattr across the generated files and directories. Might be nicer for 
Fedora backport if nothing else.


- Panu -


diff --git a/build/files.c b/build/files.c
index 4911162..df53d1d 100644
--- a/build/files.c
+++ b/build/files.c
@@ -206,10 +206,7 @@ static void dupAttrRec(const AttrRec oar, AttrRec nar)
 static char *mkattr(const char *fn)
 {
 char *s = NULL;
-if (fn)
-	rasprintf(, "%s(-,%s,%s) %s", "%attr", UID_0_USER, GID_0_GROUP, fn);
-else
-	rasprintf(, "%s(-,%s,%s)", "%defattr", UID_0_USER, GID_0_GROUP);
+rasprintf(, "%s(644,%s,%s,755)", "%defattr", UID_0_USER, GID_0_GROUP);
 return s;
 }
 
@@ -1881,11 +1878,8 @@ static int generateBuildIDs(FileList fl)
 		if ((rc = rpmioMkpath(mainiddir, 0755, -1, -1)) != 0) {
 		rpmlog(RPMLOG_ERR, "%s %s: %m\n", errdir, mainiddir);
 		} else {
-		attrstr = mkattr(mainiddir);
-		parseForAttr(fl->pool, attrstr, 0, >cur);
 		fl->cur.isDir = 1;
 		rc = addFile(fl, mainiddir, NULL);
-		free (attrstr);
 		}
 	}
 
@@ -1893,11 +1887,8 @@ static int generateBuildIDs(FileList fl)
 		if ((rc = rpmioMkpath(debugiddir, 0755, -1, -1)) != 0) {
 		rpmlog(RPMLOG_ERR, "%s %s: %m\n", errdir, debugiddir);
 		} else {
-		attrstr = mkattr(debugiddir);
-		parseForAttr(fl->pool, attrstr, 0, >cur);
 		fl->cur.isDir = 1;
 		rc = addFile(fl, debugiddir, NULL);
-		free (attrstr);
 		}
 	}
 	}
___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint