Fix generate empty debugsource packages with rpm 4.14.1 87/254087/1 accepted/tizen/base/tool/20210302.233540 submit/tizen_base/20210223.120237 submit/tizen_base/20210223.130441
authorbiao716.wang <biao716.wang@samsung.com>
Tue, 23 Feb 2021 08:00:38 +0000 (17:00 +0900)
committerbiao716.wang <biao716.wang@samsung.com>
Tue, 23 Feb 2021 08:00:38 +0000 (17:00 +0900)
Change-Id: I6492ba2f49b43470edff096685621147bdadbcfc
Signed-off-by: biao716.wang <biao716.wang@samsung.com>
macros.in
mkinstalldirs
scripts/find-debuginfo.sh
scripts/rpm2cpio.sh
tools/debugedit.c
tools/elfdeps.c

index ea09df3..0fe8ff2 100644 (file)
--- a/macros.in
+++ b/macros.in
@@ -235,8 +235,8 @@ package or when debugging this package.\
 %{nil}
 
 %_defaultdocdir                %{_datadir}/doc/packages
+%_docdir_fmt           %%{NAME}
 %_defaultlicensedir    %{_datadir}/licenses
-%_docdir_fmt          %%{NAME}
 
 # Following macros for filtering auto deps must not be used in spec files.
 # Their purpouse is to set up global filtering for all packages. If you need
@@ -327,6 +327,16 @@ package or when debugging this package.\
 #
 #%bugurl
 
+#      Configurable distribution tag, same as Disttag: tag in a specfile.
+#      The tag will be used to supply reliable information to tools like
+#      rpmfind.
+#
+# Note: You should not configure with disturl (or build packages with
+# the Disttag: tag) unless you are willing to supply content in a
+# yet-to-be-determined format at the tag specified.
+#
+#%disttag
+
 #      Boolean (i.e. 1 == "yes", 0 == "no") that controls whether files
 #      marked as %doc should be installed.
 #%_excludedocs
@@ -555,7 +565,6 @@ package or when debugging this package.\
 # --unique-debug-suffix "-%{VERSION}-%{RELEASE}.%{_arch} find-debuginfo.sh
 # to create debuginfo files which end in -<ver>-<rel>.<arch>.debug
 # Requires _unique_build_ids.
-#For legacy compatibility, Temply change _unique_debug_names to 0.
 #%_unique_debug_names  0
 
 # Whether the /usr/debug/src/<package> directories should be unique between
@@ -583,8 +592,8 @@ package or when debugging this package.\
 %__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
 
 # maxnum,cuttime,minnum
-# 2009/03/01 (SLES11 GA)
-%_binarychangelogtrim 0,1235862000,10
+# 2014/10/13 (SLES12 GA)
+%_binarychangelogtrim 0,1413151200,10
 
 #
 # Path to scripts to autogenerate package dependencies,
@@ -596,11 +605,11 @@ posix.setenv("RPMBUILD_SOURCEDIR",rpm.expand("%?_sourcedir"));
 # Note: Used iff _use_internal_dependency_generator is zero.
 #%__find_provides      %{_rpmconfigdir}/rpmdeps --provides
 #%__find_requires      %{_rpmconfigdir}/rpmdeps --requires
-%__find_provides       %{__set_helper_env}%{_rpmconfigdir}/find-provides %name
-%__find_requires       %{__set_helper_env}%{_rpmconfigdir}/find-requires %name
+%__find_provides       %{_rpmconfigdir}/find-provides %name
+%__find_requires       %{_rpmconfigdir}/find-requires %name
 #%__find_conflicts     ???
 #%__find_obsoletes     ???
-%__find_supplements    %{__set_helper_env}%{_rpmconfigdir}/find-supplements %name
+%__find_supplements    %{_rpmconfigdir}/find-supplements %name
 #%__find_enhances      ???
 
 # 
@@ -680,10 +689,10 @@ posix.setenv("RPMBUILD_SOURCEDIR",rpm.expand("%?_sourcedir"));
 # Misc BDB tuning options
 %__dbi_other                   mp_mmapsize=128Mb mp_size=1Mb
 
-%_dbi_config                   %{?__dbi_other}
+%_dbi_config                   %{?__dbi_other} nofsync
 
 # "Packages" should have shared/exclusive fcntl(2) lock using "lockdbfd".
-%_dbi_config_Packages          %{?_dbi_config} lockdbfd
+%_dbi_config_Packages          %{?__dbi_other} lockdbfd
 
 #==============================================================================
 # ---- GPG/PGP/PGP5 signature macros.
@@ -1002,7 +1011,7 @@ posix.setenv("RPMBUILD_SOURCEDIR",rpm.expand("%?_sourcedir"));
 %_build_vendor         %{_host_vendor}
 %_build_os             %{_host_os}
 %_host                 @host@
-%_host_alias           @host_alias@%{nil}
+%_host_alias           @host@%{nil}
 %_host_cpu             @host_cpu@
 %_host_vendor          @host_vendor@
 %_host_os              @host_os@
index 55d537f..a31ce6d 100755 (executable)
@@ -1,7 +1,7 @@
 #! /bin/sh
 # mkinstalldirs --- make directory hierarchy
 
-scriptversion=2009-04-28.21; # UTC
+scriptversion=2016-01-11.22; # UTC
 
 # Original author: Noah Friedman <friedman@prep.ai.mit.edu>
 # Created: 1993-05-16
@@ -157,6 +157,6 @@ exit $errstatus
 # eval: (add-hook 'write-file-hooks 'time-stamp)
 # time-stamp-start: "scriptversion="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
+# time-stamp-time-zone: "UTC0"
 # time-stamp-end: "; # UTC"
 # End:
index 3276b6d..51bc61a 100755 (executable)
@@ -250,6 +250,7 @@ strip_to_debug()
   local g=
   local r=
 
+
   if test "$strip_disable" = true ; then
       exit
   fi
@@ -385,8 +386,7 @@ trap 'rm -rf "$temp"' EXIT
 
 # Build a list of unstripped ELF files and their hardlinks
 touch "$temp/primary"
-# Strip ELF binaries (and no static libraries)
-find $RPM_BUILD_ROOT ! -path "${debugdir}/*.debug" -type f \( -perm /111 -or -name "*.so*" -or -name "*.ko" \) ! -name "*.a" -print0 | sort -z |
+find "$RPM_BUILD_ROOT" ! -path "${debugdir}/*.debug" -type f \( -perm /111 -or -name "*.so*" -or -name "*.ko" \) ! -name "*.a" -print0 | sort -z |
 xargs --no-run-if-empty -0 stat -c '%h %D_%i %n' |
 while read nlinks inum f; do
   case $(objdump -h $f 2>/dev/null | egrep -o '(debug[\.a-z_]*|gnu.version)') in
@@ -470,7 +470,7 @@ do_file()
   esac
 
   mkdir -p "${debugdn}"
- if [ -e "${BUILDDIR}/Kconfig" ] ; then
 if [ -e "${BUILDDIR}/Kconfig" ] ; then
       mode=$(stat -c %a "$f")
       chmod +w "$f"
       objcopy --only-keep-debug $f $debugfn || :
@@ -505,7 +505,6 @@ do_file()
       fi
   fi
 
-
   # strip -g implies we have full symtab, don't add mini symtab in that case.
   # It only makes sense to add a minisymtab for executables and shared
   # libraries. Other executable ELF files (like kernel modules) don't need it.
@@ -586,7 +585,7 @@ fi
 # Invoke the DWARF Compressor utility.
 if $run_dwz \
    && [ -d "${RPM_BUILD_ROOT}/usr/lib/debug" ]; then
-  readarray dwz_files < <(cd "${RPM_BUILD_ROOT}/usr/lib/debug"; find -type f -name \*.debug)
+  readarray dwz_files < <(cd "${RPM_BUILD_ROOT}/usr/lib/debug"; find -type f -name \*.debug | LC_ALL=C sort)
   if [ ${#dwz_files[@]} -gt 0 ]; then
     dwz_multifile_name="${RPM_PACKAGE_NAME}-${RPM_PACKAGE_VERSION}-${RPM_PACKAGE_RELEASE}.${RPM_ARCH}"
     dwz_multifile_suffix=
@@ -644,7 +643,6 @@ fi
 #  fi
 #done
 
-
 if [ -s "$SOURCEFILE" ]; then
   # See also debugedit invocation. Directories must match up.
   debug_base_name="$RPM_BUILD_DIR"
@@ -662,15 +660,16 @@ if [ -s "$SOURCEFILE" ]; then
 
   # Get package name from directory and then filter out all files not
   # starting with this name
-  pn=$(basename "$BUILDDIR")
+  #remove old patch: 6428714ec2f4a0aa2b3c3b2e1b81c2cedf06e8c6
+  #pn=$(basename "$BUILDDIR")
   LC_ALL=C sort -z -u "$SOURCEFILE" | grep -E -v -z '(^|/)<[a-z _-]+>$' |
-  grep -E -z "^${pn}" |
+  #grep -E -z "^${pn}" |
   (cd "${debug_base_name}"; cpio -pd0mL "${RPM_BUILD_ROOT}${debug_dest_name}")
   # stupid cpio creates new directories in mode 0700,
   # and non-standard modes may be inherented from original directories, fixup
   find "${RPM_BUILD_ROOT}${debug_dest_name}" -type d -print0 |
   xargs --no-run-if-empty -0 chmod 0755
-  find "${RPM_BUILD_ROOT}/usr/src/debug" -type f -print0 |
+  find "${RPM_BUILD_ROOT}${debug_dest_name}" -type f -print0 |
   xargs --no-run-if-empty -0 chmod a+r
 fi
 
index a883562..daa8613 100755 (executable)
@@ -11,7 +11,7 @@ pkg="$1"
 
 _dd() {
        local o="$1"; shift
-       dd if="$pkg" skip="$o" iflag=skip_bytes status=none $*
+       dd if="$pkg" skip="$o" iflag=skip_bytes $*
 }
 
 calcsize() {
index 1912f89..6c572ae 100644 (file)
@@ -858,9 +858,6 @@ record_file_string_entry_idx (struct strings *strings, size_t old_idx)
   struct stridxentry *entry = string_find_new_entry (strings, old_idx);
   if (entry != NULL)
     {
-      if (old_idx >= debug_sections[DEBUG_STR].size)
-       error (1, 0, "Bad string pointer index %zd", old_idx);
-
       Strent *strent;
       const char *old_str = (char *)debug_sections[DEBUG_STR].data + old_idx;
       const char *file = skip_dir_prefix (old_str, base_dir);
@@ -911,9 +908,6 @@ record_existing_string_entry_idx (struct strings *strings, size_t old_idx)
   struct stridxentry *entry = string_find_new_entry (strings, old_idx);
   if (entry != NULL)
     {
-      if (old_idx >= debug_sections[DEBUG_STR].size)
-       error (1, 0, "Bad string pointer index %zd", old_idx);
-
       const char *str = (char *)debug_sections[DEBUG_STR].data + old_idx;
       Strent *strent = strtab_add_len (strings->str_tab,
                                       str, strlen (str) + 1);
@@ -1577,18 +1571,10 @@ edit_attributes (DSO *dso, unsigned char *ptr, struct abbrev_tag *t, int phase)
                {
                  const char *dir;
                  size_t idx = do_read_32_relocated (ptr);
-                 /* In phase zero we collect the comp_dir.  */
-                 if (phase == 0)
-                   {
-                     if (idx >= debug_sections[DEBUG_STR].size)
-                       error (1, 0,
-                              "%s: Bad string pointer index %zd for comp_dir",
-                              dso->filename, idx);
-                     dir = (char *) debug_sections[DEBUG_STR].data + idx;
+                 dir = (char *) debug_sections[DEBUG_STR].data + idx;
 
-                     free (comp_dir);
-                     comp_dir = strdup (dir);
-                   }
+                 free (comp_dir);
+                 comp_dir = strdup (dir);
 
                  if (dest_dir != NULL && phase == 0)
                    {
@@ -1608,29 +1594,21 @@ edit_attributes (DSO *dso, unsigned char *ptr, struct abbrev_tag *t, int phase)
                 unit. If starting with / it is a full path name.
                 Note that we don't handle DW_FORM_string in this
                 case.  */
+             char *name;
              size_t idx = do_read_32_relocated (ptr);
-
-             /* In phase zero we will look for a comp_dir to use.  */
-             if (phase == 0)
+             name = (char *) debug_sections[DEBUG_STR].data + idx;
+             if (*name == '/' && comp_dir == NULL)
                {
-                 if (idx >= debug_sections[DEBUG_STR].size)
-                   error (1, 0,
-                          "%s: Bad string pointer index %zd for unit name",
-                          dso->filename, idx);
-                 char *name = (char *) debug_sections[DEBUG_STR].data + idx;
-                 if (*name == '/' && comp_dir == NULL)
-                   {
-                     char *enddir = strrchr (name, '/');
+                 char *enddir = strrchr (name, '/');
 
-                     if (enddir != name)
-                       {
-                         comp_dir = malloc (enddir - name + 1);
-                         memcpy (comp_dir, name, enddir - name);
-                         comp_dir [enddir - name] = '\0';
-                       }
-                     else
-                       comp_dir = strdup ("/");
+                 if (enddir != name)
+                   {
+                     comp_dir = malloc (enddir - name + 1);
+                     memcpy (comp_dir, name, enddir - name);
+                     comp_dir [enddir - name] = '\0';
                    }
+                 else
+                   comp_dir = strdup ("/");
                }
 
              /* First pass (0) records the new name to be
index a1c1a6a..5eead40 100644 (file)
@@ -16,9 +16,9 @@
 int filter_private = 0;
 int soname_only = 0;
 int fake_soname = 1;
-int assume_exec = 0;
 int filter_soname = 1;
 int require_interp = 0;
+int assume_exec = 0;
 
 typedef struct elfInfo_s {
     Elf *elf;
@@ -364,9 +364,9 @@ int main(int argc, char *argv[])
        { "filter-private", 0, POPT_ARG_VAL, &filter_private, -1, NULL, NULL },
        { "soname-only", 0, POPT_ARG_VAL, &soname_only, -1, NULL, NULL },
        { "no-fake-soname", 0, POPT_ARG_VAL, &fake_soname, 0, NULL, NULL },
-       { "assume-exec", 0, POPT_ARG_VAL, &assume_exec, -1, NULL, NULL },
        { "no-filter-soname", 0, POPT_ARG_VAL, &filter_soname, 0, NULL, NULL },
        { "require-interp", 0, POPT_ARG_VAL, &require_interp, -1, NULL, NULL },
+       { "assume-exec", 0, POPT_ARG_VAL, &assume_exec, -1, NULL, NULL },
        POPT_AUTOHELP 
        POPT_TABLEEND
     };