Rebase to rpm 4.13.0-rc2

This commit is contained in:
Panu Matilainen 2016-10-20 18:38:49 +03:00
parent 9c2066b222
commit cf4d3ed708
43 changed files with 7 additions and 3427 deletions

1
.gitignore vendored
View File

@ -20,3 +20,4 @@
/rpm-4.12.0.1.tar.bz2
/rpm-4.12.90.tar.bz2
/rpm-4.13.0-rc1.tar.bz2
/rpm-4.13.0-rc2.tar.bz2

View File

@ -1,101 +0,0 @@
--- rpm-4.10.0/scripts/find-debuginfo.sh 2012-03-20 09:07:25.000000000 +0100
+++ rpm-4.10.0/scripts/find-debuginfo.sh.jj 2012-06-19 12:32:33.147503858 +0200
@@ -4,6 +4,8 @@
#
# Usage: find-debuginfo.sh [--strict-build-id] [-g] [-r]
# [-o debugfiles.list]
+# [--run-dwz] [--dwz-low-mem-die-limit N]
+# [--dwz-max-die-limit N]
# [[-l filelist]... [-p 'pattern'] -o debuginfo.list]
# [builddir]
#
@@ -20,6 +22,10 @@
# The -p argument is an grep -E -style regexp matching the a file name,
# and must not use anchors (^ or $).
#
+# The --run-dwz flag instructs find-debuginfo.sh to run the dwz utility
+# 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.
+#
# All file names in switches are relative to builddir (. if not given).
#
@@ -32,6 +38,11 @@ strip_r=false
# Barf on missing build IDs.
strict=false
+# DWZ parameters.
+run_dwz=false
+dwz_low_mem_die_limit=
+dwz_max_die_limit=
+
BUILDDIR=.
out=debugfiles.list
nout=0
@@ -40,6 +51,17 @@ while [ $# -gt 0 ]; do
--strict-build-id)
strict=true
;;
+ --run-dwz)
+ run_dwz=true
+ ;;
+ --dwz-low-mem-die-limit)
+ dwz_low_mem_die_limit=$2
+ shift
+ ;;
+ --dwz-max-die-limit)
+ dwz_max_die_limit=$2
+ shift
+ ;;
-g)
strip_g=true
;;
@@ -266,6 +288,37 @@ while read nlinks inum f; do
fi
done || exit
+# Invoke the DWARF Compressor utility.
+if $run_dwz && type dwz >/dev/null 2>&1 \
+ && [ -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
+ dwz_multifile_name="${RPM_PACKAGE_NAME}-${RPM_PACKAGE_VERSION}-${RPM_PACKAGE_RELEASE}.${RPM_ARCH}"
+ dwz_multifile_suffix=
+ dwz_multifile_idx=0
+ while [ -f "${RPM_BUILD_ROOT}/usr/lib/debug/.dwz/${dwz_multifile_name}${dwz_multifile_suffix}" ]; do
+ let ++dwz_multifile_idx
+ 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}"
+ 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}"
+ ( cd "${RPM_BUILD_ROOT}/usr/lib/debug" && dwz $dwz_opts $dwz_files )
+ # Remove .dwz directory if empty
+ rmdir "${RPM_BUILD_ROOT}/usr/lib/debug/.dwz" 2>/dev/null
+ if [ -f "${RPM_BUILD_ROOT}/usr/lib/debug/.dwz/${dwz_multifile_name}" ]; then
+ id="`readelf -Wn "${RPM_BUILD_ROOT}/usr/lib/debug/.dwz/${dwz_multifile_name}" \
+ 2>/dev/null | sed -n 's/^ Build ID: \([0-9a-f]\+\)/\1/p'`"
+ [ -n "$id" ] \
+ && make_id_link "$id" "/usr/lib/debug/.dwz/${dwz_multifile_name}" .debug
+ fi
+ fi
+fi
+
# For each symlink whose target has a .debug file,
# make a .debug symlink to that file.
find "$RPM_BUILD_ROOT" ! -path "${debugdir}/*" -type l -print |
--- rpm-4.10.0/macros.in 2012-03-20 09:07:25.000000000 +0100
+++ rpm-4.10.0/macros.in.jj 2012-06-19 12:32:33.147503858 +0200
@@ -176,7 +176,7 @@
# the script. See the script for details.
#
%__debug_install_post \
- %{_rpmconfigdir}/find-debuginfo.sh %{?_missing_build_ids_terminate_build:--strict-build-id} %{?_find_debuginfo_opts} "%{_builddir}/%{?buildsubdir}"\
+ %{_rpmconfigdir}/find-debuginfo.sh %{?_missing_build_ids_terminate_build:--strict-build-id} %{?_find_debuginfo_dwz_opts} %{?_find_debuginfo_opts} "%{_builddir}/%{?buildsubdir}"\
%{nil}
# Template for debug information sub-package.

View File

@ -1,98 +0,0 @@
--- rpm-4.10.0/macros.in 2012-06-11 11:16:21.216952339 +0200
+++ rpm-4.10.0/macros.in.minidebug 2012-06-11 11:16:23.686912455 +0200
@@ -175,7 +175,7 @@
# the script. See the script for details.
#
%__debug_install_post \
- %{_rpmconfigdir}/find-debuginfo.sh %{?_missing_build_ids_terminate_build:--strict-build-id} %{?_find_debuginfo_dwz_opts} %{?_find_debuginfo_opts} "%{_builddir}/%{?buildsubdir}"\
+ %{_rpmconfigdir}/find-debuginfo.sh %{?_missing_build_ids_terminate_build:--strict-build-id} %{?_include_minidebuginfo:-m} %{?_find_debuginfo_dwz_opts} %{?_find_debuginfo_opts} "%{_builddir}/%{?buildsubdir}"\
%{nil}
# Template for debug information sub-package.
@@ -418,6 +418,12 @@ package or when debugging this package.\
#%_missing_build_ids_terminate_build 1
#
+# Include minimal debug information in build binaries.
+# Requires _enable_debug_packages.
+#
+#%_include_minidebuginfo 1
+
+#
# Use internal dependency generator rather than external helpers?
%_use_internal_dependency_generator 1
--- rpm-4.10.0/scripts/find-debuginfo.sh 2012-06-11 11:16:09.698138273 +0200
+++ rpm-4.10.0/scripts/find-debuginfo.sh.minidebug 2012-06-11 11:16:13.399078526 +0200
@@ -2,7 +2,7 @@
#find-debuginfo.sh - automagically generate debug info and file list
#for inclusion in an rpm spec file.
#
-# Usage: find-debuginfo.sh [--strict-build-id] [-g] [-r]
+# Usage: find-debuginfo.sh [--strict-build-id] [-g] [-r] [-m]
# [-o debugfiles.list]
# [--run-dwz] [--dwz-low-mem-die-limit N]
# [--dwz-max-die-limit N]
@@ -29,6 +29,9 @@ strip_g=false
# with -r arg, pass --reloc-debug-sections to eu-strip.
strip_r=false
+# with -m arg, add minimal debuginfo to binary.
+include_minidebug=false
+
# Barf on missing build IDs.
strict=false
@@ -43,6 +46,9 @@ while [ $# -gt 0 ]; do
-g)
strip_g=true
;;
+ -m)
+ include_minidebug=true
+ ;;
-o)
if [ -z "${lists[$nout]}" -a -z "${ptns[$nout]}" ]; then
out=$2
@@ -105,6 +111,32 @@ strip_to_debug()
chmod 444 "$1" || exit
}
+add_minidebug()
+{
+ local debuginfo="$1"
+ local binary="$2"
+
+ local dynsyms=`mktemp`
+ local funcsyms=`mktemp`
+ local keep_symbols=`mktemp`
+ local mini_debuginfo=`mktemp`
+
+ # Extract the dynamic symbols from the main binary, there is no need to also have these
+ # in the normal symbol table
+ nm -D "$binary" --format=posix --defined-only | awk '{ print $1 }' | sort > "$dynsyms"
+ # Extract all the text (i.e. function) symbols from the debuginfo
+ nm "$debuginfo" --format=posix --defined-only | awk '{ if ($2 == "T" || $2 == "t") print $1 }' | sort > "$funcsyms"
+ # Keep all the function symbols not already in the dynamic symbol table
+ comm -13 "$dynsyms" "$funcsyms" > "$keep_symbols"
+ # Copy the full debuginfo, keeping only a minumal set of symbols and removing some unnecessary sections
+ objcopy -S --remove-section .gdb_index --remove-section .comment --keep-symbols="$keep_symbols" "$debuginfo" "$mini_debuginfo" &> /dev/null
+ #Inject the compressed data into the .gnu_debugdata section of the original binary
+ xz "$mini_debuginfo"
+ mini_debuginfo="${mini_debuginfo}.xz"
+ objcopy --add-section .gnu_debugdata="$mini_debuginfo" "$binary"
+ rm -f "$dynsyms" "$funcsyms" "$keep_symbols" "$mini_debuginfo"
+}
+
# Make a relative symlink to $1 called $3$2
shopt -s extglob
link_relative()
@@ -260,6 +292,9 @@ while read nlinks inum f; do
chmod u-w "$f"
fi
+ # strip -g implies we have full symtab, don't add mini symtab in that case.
+ $strip_g || ($include_minidebug && add_minidebug "${debugfn}" "$f")
+
if [ -n "$id" ]; then
make_id_link "$id" "$dn/$(basename $f)"
make_id_link "$id" "/usr/lib/debug$dn/$bn" .debug

View File

@ -1,395 +0,0 @@
--- rpm-4.11.1-rc1-orig/Makefile.am 2013-06-07 12:19:21.000000000 +0200
+++ rpm-4.11.1-rc1/Makefile.am 2013-06-24 18:34:06.342894002 +0200
@@ -162,6 +162,10 @@ rpmlibexec_PROGRAMS += elfdeps
elfdeps_SOURCES = tools/elfdeps.c
elfdeps_LDADD = rpmio/librpmio.la
elfdeps_LDADD += @WITH_LIBELF_LIB@ @WITH_POPT_LIB@
+
+rpmlibexec_PROGRAMS += sepdebugcrcfix
+sepdebugcrcfix_SOURCES = tools/sepdebugcrcfix.c
+sepdebugcrcfix_LDADD = @WITH_LIBELF_LIB@
endif
endif
--- rpm-4.11.1-rc1-orig/scripts/find-debuginfo.sh 2013-06-24 17:20:55.407538301 +0200
+++ rpm-4.11.1-rc1/scripts/find-debuginfo.sh 2013-06-24 18:34:41.270897302 +0200
@@ -114,10 +114,12 @@ done
LISTFILE="$BUILDDIR/$out"
SOURCEFILE="$BUILDDIR/debugsources.list"
LINKSFILE="$BUILDDIR/debuglinks.list"
+ELFBINSFILE="$BUILDDIR/elfbins.list"
> "$SOURCEFILE"
> "$LISTFILE"
> "$LINKSFILE"
+> "$ELFBINSFILE"
debugdir="${RPM_BUILD_ROOT}/usr/lib/debug"
@@ -316,6 +318,8 @@
# strip -g implies we have full symtab, don't add mini symtab in that case.
$strip_g || ($include_minidebug && add_minidebug "${debugfn}" "$f")
+
+ echo "./${f#$RPM_BUILD_ROOT}" >> "$ELFBINSFILE"
if [ -n "$id" ]; then
make_id_link "$id" "$dn/$(basename $f)"
@@ -354,6 +357,10 @@ if $run_dwz && type dwz >/dev/null 2>&1
fi
fi
+# dwz invalidates .gnu_debuglink CRC32 in the main files.
+cat "$ELFBINSFILE" |
+(cd "$RPM_BUILD_ROOT"; xargs -d '\n' /usr/lib/rpm/sepdebugcrcfix usr/lib/debug)
+
# For each symlink whose target has a .debug file,
# make a .debug symlink to that file.
find "$RPM_BUILD_ROOT" ! -path "${debugdir}/*" -type l -print |
--- rpm-4.11.1-rc1-orig/tools/sepdebugcrcfix.c 1970-01-01 01:00:00.000000000 +0100
+++ rpm-4.11.1-rc1/tools/sepdebugcrcfix.c 2013-06-24 18:31:54.927881439 +0200
@@ -0,0 +1,344 @@
+/* Copyright (C) 2013 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Version 2013-06-24. */
+
+#define _GNU_SOURCE
+#include <string.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <endian.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <error.h>
+#include <libelf.h>
+#include <gelf.h>
+#include <bfd.h>
+
+#define _(x) x
+#define static_assert(expr) \
+ extern int never_defined_just_used_for_checking[(expr) ? 1 : -1]
+#ifndef min
+# define min(a, b) ((a) < (b) ? (a) : (b))
+#endif
+
+static_assert (sizeof (unsigned long) >= sizeof (uint32_t));
+
+typedef int bool;
+static const bool false = 0, true = 1;
+
+/* This is bfd_calc_gnu_debuglink_crc32 from bfd/opncls.c. */
+static unsigned long
+ calc_gnu_debuglink_crc32 (unsigned long crc,
+ const unsigned char *buf,
+ bfd_size_type len)
+{
+ static const unsigned long crc32_table[256] =
+ {
+ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419,
+ 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4,
+ 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07,
+ 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
+ 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856,
+ 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
+ 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4,
+ 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
+ 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3,
+ 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a,
+ 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599,
+ 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
+ 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190,
+ 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f,
+ 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e,
+ 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
+ 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed,
+ 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
+ 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3,
+ 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
+ 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a,
+ 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5,
+ 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010,
+ 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
+ 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17,
+ 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6,
+ 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615,
+ 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
+ 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344,
+ 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
+ 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a,
+ 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
+ 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1,
+ 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c,
+ 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef,
+ 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
+ 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe,
+ 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31,
+ 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c,
+ 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
+ 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b,
+ 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
+ 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1,
+ 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
+ 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278,
+ 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7,
+ 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66,
+ 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
+ 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605,
+ 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8,
+ 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b,
+ 0x2d02ef8d
+ };
+ const unsigned char *end;
+
+ crc = ~crc & 0xffffffff;
+ for (end = buf + len; buf < end; ++ buf)
+ crc = crc32_table[(crc ^ *buf) & 0xff] ^ (crc >> 8);
+ return ~crc & 0xffffffff;
+}
+
+static size_t updated_count, matched_count, failed_count;
+
+static const char *usr_lib_debug;
+
+static bool
+crc32 (const char *fname, const char *base_fname, uint32_t *crcp)
+{
+ char *reldir = strdup (base_fname);
+ if (reldir == NULL)
+ error (1, 0, _("out of memory"));
+ char *s = reldir + strlen (reldir);
+ while (s > reldir && s[-1] != '/')
+ *--s = '\0';
+ char *debugname;
+ if (asprintf (&debugname, "%s/%s/%s", usr_lib_debug, reldir, fname) <= 0)
+ error (1, 0, _("out of memory"));
+ free (reldir);
+ int fd = open (debugname, O_RDONLY);
+ if (fd == -1)
+ {
+ error (0, errno, _("cannot open \"%s\""), debugname);
+ return false;
+ }
+ off64_t size = lseek64 (fd, 0, SEEK_END);
+ if (size == -1)
+ {
+ error (0, errno, _("cannot get size of \"%s\""), debugname);
+ return false;
+ }
+ off_t offset = 0;
+ uint32_t crc = 0;
+ void *buf = NULL;
+ while (offset < size)
+ {
+ const size_t maplen = min (0x10000, size - offset);
+ void *map = NULL;
+ if (buf == NULL)
+ {
+ map = mmap (NULL, maplen, PROT_READ, MAP_PRIVATE | MAP_POPULATE,
+ fd, offset);
+ if (map == MAP_FAILED)
+ {
+ error (0, errno, _("cannot map 0x%llx bytes at offset 0x%llx "
+ "of file \"%s\""),
+ (unsigned long long) maplen, (unsigned long long) offset,
+ debugname);
+ map = NULL;
+ }
+ }
+ if (map == NULL)
+ {
+ if (buf == NULL)
+ {
+ buf = malloc (maplen);
+ if (buf == NULL)
+ error (1, 0, _("out of memory"));
+ }
+ ssize_t got = pread (fd, buf, maplen, offset);
+ if (got != maplen)
+ {
+ error (0, errno, _("cannot read 0x%llx bytes at offset 0x%llx "
+ "of file \"%s\""),
+ (unsigned long long) maplen, (unsigned long long) offset,
+ debugname);
+ free (buf);
+ free (debugname);
+ return false;
+ }
+ }
+ crc = calc_gnu_debuglink_crc32 (crc, map ?: buf, maplen);
+ if (map && munmap (map, maplen) != 0)
+ error (1, errno, _("cannot unmap 0x%llx bytes at offset 0x%llx "
+ "of file \"%s\""),
+ (unsigned long long) maplen, (unsigned long long) offset,
+ debugname);
+ offset += maplen;
+ }
+ free (buf);
+ if (close (fd) != 0)
+ {
+ error (0, errno, _("cannot close \"%s\""), debugname);
+ free (debugname);
+ return false;
+ }
+ free (debugname);
+ *crcp = crc;
+ return true;
+}
+
+static bool
+process (Elf *elf, int fd, const char *fname)
+{
+ GElf_Ehdr ehdr_mem, *ehdr = gelf_getehdr (elf, &ehdr_mem);
+ if (ehdr == NULL)
+ {
+ error (0, 0, _("cannot get ELF header of \"%s\""), fname);
+ return false;
+ }
+ if (ehdr->e_ident[EI_DATA] != ELFDATA2LSB
+ && ehdr->e_ident[EI_DATA] != ELFDATA2MSB)
+ {
+ error (0, 0, _("invalid ELF endianity of \"%s\""), fname);
+ return false;
+ }
+ Elf_Scn *scn = NULL;
+ const char scnname[] = ".gnu_debuglink";
+ while ((scn = elf_nextscn (elf, scn)) != NULL)
+ {
+ GElf_Shdr shdr_mem, *shdr = gelf_getshdr (scn, &shdr_mem);
+ if (shdr == NULL)
+ {
+ error (0, 0, _("cannot get section # %zu in \"%s\""),
+ elf_ndxscn (scn), fname);
+ continue;
+ }
+ const char *sname = elf_strptr (elf, ehdr->e_shstrndx, shdr->sh_name);
+ if (sname == NULL)
+ {
+ error (0, 0, _("cannot get name of section # %zu in \"%s\""),
+ elf_ndxscn (scn), fname);
+ continue;
+ }
+ if (strcmp (sname, scnname) != 0)
+ continue;
+ Elf_Data *data = elf_getdata (scn, NULL);
+ if (data == NULL)
+ {
+ error (0, 0, _("cannot get data of section \"%s\" # %zu in \"%s\""),
+ scnname, elf_ndxscn (scn), fname);
+ continue;
+ }
+ if ((data->d_size & 3) != 0)
+ {
+ error (0, 0, _("invalid size of section \"%s\" # %zu in \"%s\""),
+ scnname, elf_ndxscn (scn), fname);
+ continue;
+ }
+ const uint8_t *zerop = memchr (data->d_buf, '\0', data->d_size);
+ const uint8_t *crcp = (zerop == NULL
+ ? NULL
+ : (const uint8_t *) ((uintptr_t) (zerop + 1 + 3)
+ & -4));
+ if (crcp + 4 != (uint8_t *) data->d_buf + data->d_size)
+ {
+ error (0, 0, _("invalid format of section \"%s\" # %zu in \"%s\""),
+ scnname, elf_ndxscn (scn), fname);
+ continue;
+ }
+ uint32_t had_crc_targetendian = *(const uint32_t *) crcp;
+ uint32_t had_crc = (ehdr->e_ident[EI_DATA] == ELFDATA2LSB
+ ? le32toh (had_crc_targetendian)
+ : be32toh (had_crc_targetendian));
+ uint32_t crc;
+ if (! crc32 (data->d_buf, fname, &crc))
+ return false;
+ if (crc == had_crc)
+ {
+ matched_count++;
+ return true;
+ }
+ updated_count++;
+ off64_t seekto = (shdr->sh_offset + data->d_off
+ + (crcp - (const uint8_t *) data->d_buf));
+ uint32_t crc_targetendian = (ehdr->e_ident[EI_DATA] == ELFDATA2LSB
+ ? htole32 (crc) : htobe32 (crc));
+ ssize_t wrote = pwrite (fd, &crc_targetendian, sizeof (crc_targetendian),
+ seekto);
+ if (wrote != sizeof (crc_targetendian))
+ {
+ error (0, 0, _("cannot write new CRC to 0x%llx "
+ "inside section \"%s\" # %zu in \"%s\""),
+ (unsigned long long) seekto, scnname, elf_ndxscn (scn), fname);
+ return false;
+ }
+ return true;
+ }
+ error (0, 0, _("cannot find section \"%s\" in \"%s\""), scnname, fname);
+ return false;
+}
+
+int
+main (int argc, char **argv)
+{
+ if (argc < 2)
+ error (1, 0, _("usr/lib/debug [<relative filenames>...]"));
+ usr_lib_debug = argv[1];
+ if (elf_version (EV_CURRENT) == EV_NONE)
+ error (1, 0, _("error initializing libelf: %s"), elf_errmsg (-1));
+ for (int argi = 2; argi < argc; argi++)
+ {
+ const char *fname = argv[argi];
+ int fd = open64 (fname, O_RDWR);
+ if (fd == -1)
+ {
+ error (0, errno, _("cannot open \"%s\""), fname);
+ failed_count++;
+ continue;
+ }
+ bool failed = false;
+ Elf *elf = elf_begin (fd, ELF_C_READ_MMAP, NULL);
+ if (elf == NULL)
+ {
+ error (0, 0, _("cannot open \"%s\" as ELF: %s"), fname,
+ elf_errmsg (-1));
+ failed = true;
+ }
+ else
+ {
+ if (! process (elf, fd, fname))
+ failed = true;
+ if (elf_end (elf) != 0)
+ {
+ error (0, 0, _("cannot close \"%s\" as ELF: %s"), fname,
+ elf_errmsg (-1));
+ failed = true;
+ }
+ }
+ if (close (fd) != 0)
+ {
+ error (0, errno, _("cannot close \"%s\""), fname);
+ failed = true;
+ }
+ if (failed)
+ failed_count++;
+ }
+ printf ("%s: Updated %zu CRC32s, %zu CRC32s did match.\n", argv[0],
+ updated_count, matched_count);
+ if (failed_count)
+ printf ("%s: Failed for %zu files.\n", argv[0], failed_count);
+ return failed_count == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
+}

View File

@ -1,16 +0,0 @@
--- rpm-4.12.0.1/lib/fsm.c.orig 2014-12-12 16:05:51.683430313 +0100
+++ rpm-4.12.0.1/lib/fsm.c 2014-12-12 16:08:28.046025597 +0100
@@ -215,7 +215,12 @@ static int expandRegular(rpmfi fi, const
FD_t wfd = NULL;
int rc = 0;
- wfd = Fopen(dest, "w.ufdio");
+ /* Create the file with 000 permissions. */
+ {
+ mode_t old_umask = umask(0777);
+ wfd = Fopen(dest, "w.ufdio");
+ umask(old_umask);
+ }
if (Ferror(wfd)) {
rc = RPMERR_OPEN_FAILED;
goto exit;

View File

@ -1,14 +0,0 @@
diff --git a/lib/cpio.c b/lib/cpio.c
index 253ff0f..600633a 100644
--- a/lib/cpio.c
+++ b/lib/cpio.c
@@ -399,6 +399,9 @@ int rpmcpioHeaderRead(rpmcpio_t cpio, char ** path, int * fx)
GET_NUM_FIELD(hdr.filesize, fsize);
GET_NUM_FIELD(hdr.namesize, nameSize);
+ if (nameSize <= 0 || nameSize > 4096) {
+ return RPMERR_BAD_HEADER;
+ }
char name[nameSize + 1];
read = Fread(name, nameSize, 1, cpio->fd);

View File

@ -1,32 +0,0 @@
From d53499d1565dd7ba6d93939e552cc604b26dccd7 Mon Sep 17 00:00:00 2001
From: Florian Festi <ffesti@redhat.com>
Date: Fri, 26 Feb 2016 11:15:23 +0100
Subject: [PATCH] Use %_build_cpu instead of noarch when evaluating ExcludeArch
and ExclusiveArch
Some noarch packages need build tools not available on all architectures.
By using %_build_cpu you can restrict the architectures those noarch
packages can be build on.
---
build/parsePreamble.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/build/parsePreamble.c b/build/parsePreamble.c
index 13501de..933f734 100644
--- a/build/parsePreamble.c
+++ b/build/parsePreamble.c
@@ -428,6 +428,11 @@ static rpmRC checkForValidArchitectures(rpmSpec spec)
char *arch = rpmExpand("%{_target_cpu}", NULL);
char *os = rpmExpand("%{_target_os}", NULL);
rpmRC rc = RPMRC_FAIL; /* assume failure */
+
+ if (!strcmp(arch, "noarch")) {
+ free(arch);
+ arch = rpmExpand("%{_build_cpu}", NULL);
+ }
if (isMemberInEntry(spec->buildRestrictions,
arch, RPMTAG_EXCLUDEARCH) == 1) {
--
2.5.0

View File

@ -1,63 +0,0 @@
From 2a6926d531ca9aa797db678b648509ca251de3f2 Mon Sep 17 00:00:00 2001
From: Florian Festi <ffesti@redhat.com>
Date: Thu, 25 Feb 2016 16:51:02 +0100
Subject: [PATCH] Use pkg->dpaths during dependency generation instead of
buildRoot + filename
This passes the filenames with the actual file content to the dependency
generators when using RemovePathPostfixes.
---
build/rpmfc.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/build/rpmfc.c b/build/rpmfc.c
index 7c61d9d..59cf472 100644
--- a/build/rpmfc.c
+++ b/build/rpmfc.c
@@ -1267,7 +1267,6 @@ rpmRC rpmfcGenerateDepends(const rpmSpec spec, Package pkg)
{
rpmfi fi = rpmfilesIter(pkg->cpioList, RPMFI_ITER_FWD);
rpmfc fc = NULL;
- ARGV_t av = NULL;
rpm_mode_t * fmode = NULL;
int ac = rpmfiFC(fi);
int genConfigDeps = 0;
@@ -1280,18 +1279,14 @@ rpmRC rpmfcGenerateDepends(const rpmSpec spec, Package pkg)
goto exit;
/* Extract absolute file paths in argv format. */
- av = xcalloc(ac+1, sizeof(*av));
fmode = xcalloc(ac+1, sizeof(*fmode));
fi = rpmfiInit(fi, 0);
while ((idx = rpmfiNext(fi)) >= 0) {
/* Does package have any %config files? */
genConfigDeps |= (rpmfiFFlags(fi) & RPMFILE_CONFIG);
-
- av[idx] = rstrscat(NULL, spec->buildRoot, rpmfiFN(fi), NULL);
fmode[idx] = rpmfiFMode(fi);
}
- av[ac] = NULL;
fc = rpmfcCreate(spec->buildRoot, 0);
free(fc->pkg);
@@ -1316,7 +1311,7 @@ rpmRC rpmfcGenerateDepends(const rpmSpec spec, Package pkg)
}
/* Build file class dictionary. */
- rc = rpmfcClassify(fc, av, fmode);
+ rc = rpmfcClassify(fc, pkg->dpaths, fmode);
if ( rc != RPMRC_OK )
goto exit;
@@ -1371,7 +1366,6 @@ exit:
fc->pkg = NULL;
free(fmode);
rpmfcFree(fc);
- argvFree(av);
rpmfiFree(fi);
return rc;
--
2.5.0

View File

@ -1,52 +0,0 @@
From 22588250baa1bfa5c00f57d39329d0c144fc8112 Mon Sep 17 00:00:00 2001
From: Florian Festi <ffesti@redhat.com>
Date: Thu, 2 Jun 2016 15:54:01 +0200
Subject: [PATCH] Add support for _buildhost macro for setting the build host
manually.
This is useful for reproducible builds. See rhbz#1309367.
---
build/pack.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/build/pack.c b/build/pack.c
index f9fb3a0..82c1262 100644
--- a/build/pack.c
+++ b/build/pack.c
@@ -179,16 +179,25 @@ static const char * buildHost(void)
static char hostname[1024];
static int oneshot = 0;
struct hostent *hbn;
+ char *bhMacro;
if (! oneshot) {
- (void) gethostname(hostname, sizeof(hostname));
- hbn = gethostbyname(hostname);
- if (hbn)
- strcpy(hostname, hbn->h_name);
- else
- rpmlog(RPMLOG_WARNING,
- _("Could not canonicalize hostname: %s\n"), hostname);
- oneshot = 1;
+ bhMacro = rpmExpand("%{?_buildhost}", NULL);
+ if (strcmp(bhMacro, "") != 0 && strlen(bhMacro) < 1024) {
+ strcpy(hostname, bhMacro);
+ } else {
+ if (strcmp(bhMacro, "") != 0)
+ rpmlog(RPMLOG_WARNING, _("The _buildhost macro is too long\n"));
+ (void) gethostname(hostname, sizeof(hostname));
+ hbn = gethostbyname(hostname);
+ if (hbn)
+ strcpy(hostname, hbn->h_name);
+ else
+ rpmlog(RPMLOG_WARNING,
+ _("Could not canonicalize hostname: %s\n"), hostname);
+ }
+ free(bhMacro);
+ oneshot = 1;
}
return(hostname);
}
--
2.5.5

View File

@ -1,193 +0,0 @@
diff -urp rpm-4.13.0-rc1/installplatform r/installplatform
--- rpm-4.13.0-rc1/installplatform 2015-08-26 15:52:41.856044288 +0200
+++ r/installplatform 2015-11-24 21:53:09.146590589 +0100
@@ -138,6 +138,30 @@ for ARCH in noarch `grep ^arch_canon $RP
CANONARCH=mips64el
CANONCOLOR=3
;;
+ mipsr6)
+ ISANAME=mipsr6
+ ISABITS=32
+ CANONARCH=mipsr6
+ CANONCOLOR=0
+ ;;
+ mipsr6el)
+ ISANAME=mipsr6
+ ISABITS=32
+ CANONARCH=mipsr6el
+ CANONCOLOR=0
+ ;;
+ mips64r6)
+ ISANAME=mipsr6
+ ISABITS=64
+ CANONARCH=mips64r6
+ CANONCOLOR=3
+ ;;
+ mips64r6el)
+ ISANAME=mipsr6
+ ISABITS=64
+ CANONARCH=mips64r6el
+ CANONCOLOR=3
+ ;;
m68k)
ISANAME=m68k
ISABITS=32
diff -urp rpm-4.13.0-rc1/lib/rpmrc.c r/lib/rpmrc.c
--- rpm-4.13.0-rc1/lib/rpmrc.c 2015-08-28 15:14:50.593500511 +0200
+++ r/lib/rpmrc.c 2015-11-24 21:37:41.966760327 +0100
@@ -1057,21 +1057,45 @@ static void defaultMachine(rpmrcCtx ctx,
# if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL)
/* little endian */
-# if defined(__LP64__) || defined(_LP64)
+# if defined(__mips64)
/* 64-bit */
- strcpy(un.machine, "mips64el");
+# if !defined(__mips_isa_rev) || __mips_isa_rev < 6
+ /* r1-r5 */
+ strcpy(un.machine, "mips64el");
+# else
+ /* r6 */
+ strcpy(un.machine, "mips64r6el");
+# endif
# else
/* 32-bit */
- strcpy(un.machine, "mipsel");
+# if !defined(__mips_isa_rev) || __mips_isa_rev < 6
+ /* r1-r5 */
+ strcpy(un.machine, "mipsel");
+# else
+ /* r6 */
+ strcpy(un.machine, "mipsr6el");
+# endif
# endif
# elif defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB)
/* big endian */
-# if defined(__LP64__) || defined(_LP64)
+# if defined(__mips64)
/* 64-bit */
- strcpy(un.machine, "mips64");
+# if !defined(__mips_isa_rev) || __mips_isa_rev < 6
+ /* r1-r5 */
+ strcpy(un.machine, "mips64");
+# else
+ /* r6 */
+ strcpy(un.machine, "mips64r6");
+# endif
# else
/* 32-bit */
- strcpy(un.machine, "mips");
+# if !defined(__mips_isa_rev) || __mips_isa_rev < 6
+ /* r1-r5 */
+ strcpy(un.machine, "mips");
+# else
+ /* r6 */
+ strcpy(un.machine, "mipsr6");
+# endif
# endif
# endif
diff -urp rpm-4.13.0-rc1/macros.in r/macros.in
--- rpm-4.13.0-rc1/macros.in 2015-11-24 19:44:16.862367540 +0100
+++ r/macros.in 2015-11-24 19:54:11.208427621 +0100
@@ -1025,8 +1025,24 @@ done \
%arm armv3l armv4b armv4l armv4tl armv5tel armv5tejl armv6l armv6hl armv7l armv7hl armv7hnl
#------------------------------------------------------------------------------
+# arch macro for 32-bit MIPS processors
+%mips32 mips mipsel mipsr6 mipsr6el
+
+#------------------------------------------------------------------------------
+# arch macro for 64-bit MIPS processors
+%mips64 mips64 mips64el mips64r6 mips64r6el
+
+#------------------------------------------------------------------------------
+# arch macro for big endian MIPS processors
+%mipseb mips mipsr6 mips64 mips64r6
+
+#------------------------------------------------------------------------------
+# arch macro for little endian MIPS processors
+%mipsel mipsel mipsr6el mips64el mips64r6el
+
+#------------------------------------------------------------------------------
# arch macro for all supported MIPS processors
-%mips mips mipsel mips64 mips64el
+%mips %{mips32} %{mips64}
#------------------------------------------------------------------------------
# arch macro for all supported Sparc processors
diff -urp rpm-4.13.0-rc1/rpmrc.in r/rpmrc.in
--- rpm-4.13.0-rc1/rpmrc.in 2015-11-24 19:44:16.858367519 +0100
+++ r/rpmrc.in 2015-11-24 19:50:36.544322671 +0100
@@ -62,6 +62,11 @@ optflags: mipsel -O2 -g
optflags: mips64 -O2 -g
optflags: mips64el -O2 -g
+optflags: mipsr6 -O2 -g
+optflags: mipsr6el -O2 -g
+optflags: mips64r6 -O2 -g
+optflags: mips64r6el -O2 -g
+
optflags: armv3l -O2 -g -march=armv3
optflags: armv4b -O2 -g -march=armv4
optflags: armv4l -O2 -g -march=armv4
@@ -121,6 +126,11 @@ archcolor: mipsel 1
archcolor: mips64 2
archcolor: mips64el 2
+archcolor: mipsr6 1
+archcolor: mipsr6el 1
+archcolor: mips64r6 2
+archcolor: mips64r6el 2
+
archcolor: m68k 1
archcolor: m68kmint 1
@@ -228,6 +238,11 @@ arch_canon: sh4a: sh4a 17
arch_canon: xtensa: xtensa 18
arch_canon: aarch64: aarch64 19
+arch_canon: mipsr6: mipsr6 20
+arch_canon: mipsr6el: mipsr6el 20
+arch_canon: mips64r6: mips64r6 21
+arch_canon: mips64r6el: mips64r6el 21
+
#############################################################
# Canonical OS names and numbers
@@ -323,6 +338,11 @@ buildarchtranslate: mipsel: mipsel
buildarchtranslate: mips64: mips64
buildarchtranslate: mips64el: mips64el
+buildarchtranslate: mipsr6: mipsr6
+buildarchtranslate: mipsr6el: mipsr6el
+buildarchtranslate: mips64r6: mips64r6
+buildarchtranslate: mips64r6el: mips64r6el
+
buildarchtranslate: m68k: m68k
buildarchtranslate: atarist: m68kmint
@@ -404,6 +424,11 @@ arch_compat: mipsel: noarch
arch_compat: mips64: mips
arch_compat: mips64el: mipsel
+arch_compat: mipsr6: noarch
+arch_compat: mipsr6el: noarch
+arch_compat: mips64r6: mipsr6
+arch_compat: mips64r6el: mipsr6el
+
arch_compat: hppa2.0: hppa1.2
arch_compat: hppa1.2: hppa1.1
arch_compat: hppa1.1: hppa1.0
@@ -527,6 +552,11 @@ buildarch_compat: mipsel: noarch
buildarch_compat: mips64: noarch
buildarch_compat: mips64el: noarch
+buildarch_compat: mipsr6: noarch
+buildarch_compat: mipsr6el: noarch
+buildarch_compat: mips64r6: noarch
+buildarch_compat: mips64r6el: noarch
+
buildarch_compat: armv4b: noarch
buildarch_compat: armv7l: armv6l
buildarch_compat: armv6l: armv5tejl

View File

@ -1,30 +0,0 @@
From 5d5dd569d01300db833e434ff49beb8b22627310 Mon Sep 17 00:00:00 2001
From: Lubos Kardos <lkardos@redhat.com>
Date: Thu, 19 May 2016 13:01:58 +0200
Subject: [PATCH] Use armv7hl isa for all armhfp (armv7h*l) arches (#1326871)
Patch from Dennis Gilmore <dennis@ausil.us>
---
installplatform | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/installplatform b/installplatform
index 3bcf70c..ebade42 100755
--- a/installplatform
+++ b/installplatform
@@ -96,6 +96,12 @@ for ARCH in noarch `grep ^arch_canon $RPMRC | cut -d: -f2`; do
CANONARCH=${ARCH}
CANONCOLOR=0
;;
+ armv7h*)
+ ISANAME=armv7hl
+ ISABITS=32
+ CANONARCH=arm
+ CANONCOLOR=0
+ ;;
arm*)
ISANAME=`echo ${ARCH} | sed "s/^\([^-]*\)-.*/\1/"`
ISABITS=32
--
1.9.3

View File

@ -1,36 +0,0 @@
From 73ea59e0d53503bb45d5eac9d9792127a6d04c23 Mon Sep 17 00:00:00 2001
From: Thierry Vignaud <thierry.vignaud@gmail.com>
Date: Thu, 17 Sep 2015 04:36:47 -0400
Subject: [PATCH] fix %autopatch when patch do not exist
unlike Mageia's %apply_patches which inspired it, %autopatch continues
when it fails to apply a patch because it doesn't exists. Eg:
+ /usr/bin/cat /home/tv/rpmbuild/SOURCES/test.patch2
+ /usr/bin/patch -p1 -s
/usr/bin/cat: /home/tv/rpmbuild/SOURCES/test.patch2: No such file or directory
+ /usr/bin/cat /home/tv/rpmbuild/SOURCES/test.patch
+ /usr/bin/patch -p1 -s
Let's catch that error
Signed-off-by: Lubos Kardos <lkardos@redhat.com>
---
macros.in | 1 +
1 file changed, 1 insertion(+)
diff --git a/macros.in b/macros.in
index 5dddede..5e0d17b 100644
--- a/macros.in
+++ b/macros.in
@@ -1118,6 +1118,7 @@ done \
# Single patch application
%apply_patch(qp:m:)\
+test -f %{1} || exit 1 ; \
%{uncompress:%{1}} | %{expand:%__scm_apply_%{__scm} %{-q} %{-p:-p%{-p*}} %{-m:-m%{-m*}}}
# Automatically apply all patches
--
1.9.3

View File

@ -1,42 +0,0 @@
From 231a7213b90a8dfba426737732e2dc6e62acfbad Mon Sep 17 00:00:00 2001
From: Lubos Kardos <lkardos@redhat.com>
Date: Tue, 19 Jan 2016 14:37:07 +0100
Subject: [PATCH] Fix %autosetup to not cause errors during run of rpmspec tool
Firstly %autosetup showed an error during its expansion if some patch
wasn't available, that is an error was showed during parsing of a spec
file. This caused showing an error during execution of rpmspec
tool (rhbz:1293687).
Now %autosetup doesn't cause an error during parsing of a spec file but
it causes an error during building of specfile if some patch is not
available. Also old macro %patch behaves similarly.
---
macros.in | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/macros.in b/macros.in
index 319a1a3..f11affe 100644
--- a/macros.in
+++ b/macros.in
@@ -1122,8 +1122,15 @@ done \
# Single patch application
%apply_patch(qp:m:)\
-test -f %{1} || exit 1 ; \
-%{uncompress:%{1}} | %{expand:%__scm_apply_%{__scm} %{-q} %{-p:-p%{-p*}} %{-m:-m%{-m*}}}
+%{lua:\
+local file = rpm.expand("%{1}")\
+if posix.access(file, "r") then\
+ local options = rpm.expand("%{-q} %{-p:-p%{-p*}} %{-m:-m%{-m*}}")\
+ local scm_apply = rpm.expand("%__scm_apply_%{__scm}")\
+ print(rpm.expand("%{uncompress:"..file.."} | "..scm_apply.." "..options.."\\n"))\
+else\
+ print("echo 'Cannot read "..file.."'; exit 1;".."\\n")\
+end}
# Automatically apply all patches
%autopatch(vp:)\
--
1.9.3

View File

@ -1,71 +0,0 @@
From 9aff39d0d530332e8cae376f2390b6546239a20e Mon Sep 17 00:00:00 2001
From: Lubos Kardos <lkardos@redhat.com>
Date: Thu, 14 Jan 2016 13:35:28 +0100
Subject: [PATCH] Fix not chrooting transaction file triggers
previously those filetriggers would call tools out of the chroot, which
breaks installers such as DrakX or Anaconda.
See https://bugs.mageia.org/show_bug.cgi?id=17217
Thanks Thierry Vignaud for finding and helping to solve this.
---
lib/rpmtriggers.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/lib/rpmtriggers.c b/lib/rpmtriggers.c
index 211e62f..4c6e821 100644
--- a/lib/rpmtriggers.c
+++ b/lib/rpmtriggers.c
@@ -11,6 +11,7 @@
#include "lib/rpmdb_internal.h"
#include "lib/rpmds_internal.h"
#include "lib/rpmfi_internal.h"
+#include "lib/rpmchroot.h"
#define TRIGGER_PRIORITY_BOUND 10000
@@ -157,6 +158,9 @@ int runPostUnTransFileTrigs(rpmts ts)
rpmtriggers trigs = ts->trigs2run;
int nerrors = 0;
+ if (rpmChrootIn() != 0)
+ return -1;
+
rpmtriggersSortAndUniq(trigs);
/* Iterate over stored triggers */
for (i = 0; i < trigs->count; i++) {
@@ -180,6 +184,9 @@ int runPostUnTransFileTrigs(rpmts ts)
rpmScriptFree(script);
headerFree(trigH);
}
+
+ rpmChrootOut();
+
return nerrors;
}
@@ -530,6 +537,11 @@ rpmRC runFileTriggers(rpmts ts, rpmte te, rpmsenseFlags sense,
/* Sort triggers by priority, offset, trigger index */
rpmtriggersSortAndUniq(triggers);
+ if (rpmChrootIn() != 0) {
+ rpmtriggersFree(triggers);
+ return RPMRC_FAIL;
+ }
+
/* Handle stored triggers */
for (i = 0; i < triggers->count; i++) {
if (priorityClass == 1) {
@@ -550,6 +562,8 @@ rpmRC runFileTriggers(rpmts ts, rpmte te, rpmsenseFlags sense,
headerFree(trigH);
}
rpmtriggersFree(triggers);
+ /* XXX an error here would require a full abort */
+ (void) rpmChrootOut();
return (nerrors == 0) ? RPMRC_OK : RPMRC_FAIL;
}
--
1.9.3

View File

@ -1,212 +0,0 @@
From 31996808c140496c35e3c9543750026292b72287 Mon Sep 17 00:00:00 2001
From: Lubos Kardos <lkardos@redhat.com>
Date: Mon, 23 Nov 2015 15:05:13 +0100
Subject: [PATCH] Add possibility to disable file triggers.
Now options --notriggers, --notriggerin, --notriggerun, --notriggerpostun
disable also file triggers and not only normal trigges. Transaction file
triggers can be also disabled with --nopretrans and --nopostrans options.
Before this patch file triggers weren't disabled when option --test was
specified. That caused unwanted multiple execution of file triggers
in dnf because dnf executes transaction with flag test before executing
transaction for real (rhbz:1282115).
---
lib/psm.c | 97 ++++++++++++++++++++++++++++++-------------------------
lib/transaction.c | 16 ++++++---
2 files changed, 65 insertions(+), 48 deletions(-)
diff --git a/lib/psm.c b/lib/psm.c
index 154237e..08d4919 100644
--- a/lib/psm.c
+++ b/lib/psm.c
@@ -682,21 +682,24 @@ static rpmRC rpmPackageInstall(rpmts ts, rpmpsm psm)
rc = dbAdd(ts, psm->te);
if (rc) break;
- /* Run upper file triggers i. e. with higher priorities */
- /* Run file triggers in other package(s) this package sets off. */
- rc = runFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERIN,
- RPMSCRIPT_FILETRIGGER, 1);
- if (rc) break;
-
- /* Run file triggers in this package other package(s) set off. */
- rc = runImmedFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERIN,
+ if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_NOTRIGGERIN)) {
+ /* Run upper file triggers i. e. with higher priorities */
+ /* Run file triggers in other package(s) this package sets off. */
+ rc = runFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERIN,
RPMSCRIPT_FILETRIGGER, 1);
- if (rc) break;
+ if (rc) break;
+
+ /* Run file triggers in this package other package(s) set off. */
+ rc = runImmedFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERIN,
+ RPMSCRIPT_FILETRIGGER, 1);
+ if (rc) break;
+ }
if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_NOPOST)) {
rc = runInstScript(psm, RPMTAG_POSTIN);
if (rc) break;
}
+
if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_NOTRIGGERIN)) {
/* Run triggers in other package(s) this package sets off. */
rc = runTriggers(psm, RPMSENSE_TRIGGERIN);
@@ -705,18 +708,18 @@ static rpmRC rpmPackageInstall(rpmts ts, rpmpsm psm)
/* Run triggers in this package other package(s) set off. */
rc = runImmedTriggers(psm, RPMSENSE_TRIGGERIN);
if (rc) break;
- }
- /* Run lower file triggers i. e. with lower priorities */
- /* Run file triggers in other package(s) this package sets off. */
- rc = runFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERIN,
- RPMSCRIPT_FILETRIGGER, 2);
- if (rc) break;
-
- /* Run file triggers in this package other package(s) set off. */
- rc = runImmedFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERIN,
+ /* Run lower file triggers i. e. with lower priorities */
+ /* Run file triggers in other package(s) this package sets off. */
+ rc = runFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERIN,
RPMSCRIPT_FILETRIGGER, 2);
- if (rc) break;
+ if (rc) break;
+
+ /* Run file triggers in this package other package(s) set off. */
+ rc = runImmedFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERIN,
+ RPMSCRIPT_FILETRIGGER, 2);
+ if (rc) break;
+ }
rc = markReplacedFiles(psm);
}
@@ -734,17 +737,17 @@ static rpmRC rpmPackageErase(rpmts ts, rpmpsm psm)
rpmswEnter(rpmtsOp(psm->ts, RPMTS_OP_ERASE), 0);
while (once--) {
- /* Run file triggers in this package other package(s) set off. */
- rc = runImmedFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERUN,
- RPMSCRIPT_FILETRIGGER, 1);
- if (rc) break;
+ if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_NOTRIGGERUN)) {
+ /* Run file triggers in this package other package(s) set off. */
+ rc = runImmedFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERUN,
+ RPMSCRIPT_FILETRIGGER, 1);
+ if (rc) break;
- /* Run file triggers in other package(s) this package sets off. */
- rc = runFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERUN,
- RPMSCRIPT_FILETRIGGER, 1);
- if (rc) break;
+ /* Run file triggers in other package(s) this package sets off. */
+ rc = runFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERUN,
+ RPMSCRIPT_FILETRIGGER, 1);
+ if (rc) break;
- if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_NOTRIGGERUN)) {
/* Run triggers in this package other package(s) set off. */
rc = runImmedTriggers(psm, RPMSENSE_TRIGGERUN);
if (rc) break;
@@ -757,22 +760,26 @@ static rpmRC rpmPackageErase(rpmts ts, rpmpsm psm)
if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_NOPREUN))
rc = runInstScript(psm, RPMTAG_PREUN);
- /* Run file triggers in this package other package(s) set off. */
- rc = runImmedFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERUN,
- RPMSCRIPT_FILETRIGGER, 2);
- if (rc) break;
+ if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_NOTRIGGERUN)) {
+ /* Run file triggers in this package other package(s) set off. */
+ rc = runImmedFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERUN,
+ RPMSCRIPT_FILETRIGGER, 2);
+ if (rc) break;
- /* Run file triggers in other package(s) this package sets off. */
- rc = runFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERUN,
- RPMSCRIPT_FILETRIGGER, 2);
- if (rc) break;
+ /* Run file triggers in other package(s) this package sets off. */
+ rc = runFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERUN,
+ RPMSCRIPT_FILETRIGGER, 2);
+ if (rc) break;
+ }
rc = rpmpsmRemove(psm);
if (rc) break;
/* Run file triggers in other package(s) this package sets off. */
- rc = runFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERPOSTUN,
- RPMSCRIPT_FILETRIGGER, 1);
+ if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_NOTRIGGERPOSTUN)) {
+ rc = runFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERPOSTUN,
+ RPMSCRIPT_FILETRIGGER, 1);
+ }
if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_NOPOSTUN)) {
rc = runInstScript(psm, RPMTAG_POSTUN);
@@ -783,15 +790,17 @@ static rpmRC rpmPackageErase(rpmts ts, rpmpsm psm)
/* Run triggers in other package(s) this package sets off. */
rc = runTriggers(psm, RPMSENSE_TRIGGERPOSTUN);
if (rc) break;
- }
- /* Run file triggers in other package(s) this package sets off. */
- rc = runFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERPOSTUN,
- RPMSCRIPT_FILETRIGGER, 2);
+ /* Run file triggers in other package(s) this package sets off. */
+ rc = runFileTriggers(psm->ts, psm->te, RPMSENSE_TRIGGERPOSTUN,
+ RPMSCRIPT_FILETRIGGER, 2);
+ }
if (rc) break;
- /* Prepare post transaction uninstall triggers */
- rpmtriggersPrepPostUnTransFileTrigs(psm->ts, psm->te);
+ if (!(rpmtsFlags(ts) & (RPMTRANS_FLAG_NOPOSTTRANS|RPMTRANS_FLAG_NOTRIGGERPOSTUN))) {
+ /* Prepare post transaction uninstall triggers */
+ rpmtriggersPrepPostUnTransFileTrigs(psm->ts, psm->te);
+ }
rc = dbRemove(ts, psm->te);
}
diff --git a/lib/transaction.c b/lib/transaction.c
index 8f440b7..66888af 100644
--- a/lib/transaction.c
+++ b/lib/transaction.c
@@ -1488,7 +1488,9 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
goto exit;
}
- if (!rpmpsNumProblems(tsprobs)) {
+ if (!(rpmtsFlags(ts) & (RPMTRANS_FLAG_BUILD_PROBS|RPMTRANS_FLAG_NOPRETRANS|
+ RPMTRANS_FLAG_NOTRIGGERUN) || rpmpsNumProblems(tsprobs))) {
+
/* Run file triggers in this package other package(s) set off. */
runFileTriggers(ts, NULL, RPMSENSE_TRIGGERUN,
RPMSCRIPT_TRANSFILETRIGGER, 0);
@@ -1541,11 +1543,17 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
}
/* Run file triggers in other package(s) this package sets off. */
- runFileTriggers(ts, NULL, RPMSENSE_TRIGGERIN, RPMSCRIPT_TRANSFILETRIGGER, 0);
- runPostUnTransFileTrigs(ts);
+ if (!(rpmtsFlags(ts) & (RPMTRANS_FLAG_NOPOSTTRANS|RPMTRANS_FLAG_NOTRIGGERIN))) {
+ runFileTriggers(ts, NULL, RPMSENSE_TRIGGERIN, RPMSCRIPT_TRANSFILETRIGGER, 0);
+ }
+ if (!(rpmtsFlags(ts) & (RPMTRANS_FLAG_NOPOSTTRANS|RPMTRANS_FLAG_NOTRIGGERPOSTUN))) {
+ runPostUnTransFileTrigs(ts);
+ }
/* Run file triggers in this package other package(s) set off. */
- runTransScripts(ts, PKG_TRANSFILETRIGGERIN);
+ if (!(rpmtsFlags(ts) & (RPMTRANS_FLAG_NOPOSTTRANS|RPMTRANS_FLAG_NOTRIGGERIN))) {
+ runTransScripts(ts, PKG_TRANSFILETRIGGERIN);
+ }
exit:
/* Run post transaction hook for all plugins */
if (TsmPreDone) /* If TsmPre hook has been called, call the TsmPost hook */
--
1.9.3

View File

@ -1,75 +0,0 @@
From 448db68ceb5be3c7171b7ec0ea908d905792dc2f Mon Sep 17 00:00:00 2001
From: Michal Domonkos <mdomonko@redhat.com>
Date: Mon, 7 Dec 2015 17:13:26 +0100
Subject: [PATCH] Add RPMCALLBACK_ELEM_PROGRESS callback type
Currently, there's no callback type that would be issued per each
transaction element. RPMCALLBACK_TRANS_PROGRESS is only issued during
the prepare phase but not when packages are actually installed or
erased. Likewise, RPMCALLBACK_INST_ST* and RPMCALLBACK_UNINST_ST* won't
be issued if an install or erase operation is skipped for some reason (a
script or package upgrade failure).
Having such a callback would allow the Python API consumers to always
know upfront which element is about to be processed, before any other
callbacks are issued. This is important since not every callback type
carries enough data about the subject package; while the INST types
provide the user object passed to a former addInstall call, the UNINST
types only provide the package name (which may not be unique within the
transaction set).
This commit adds such a callback.
---
lib/rpmcallback.h | 1 +
lib/transaction.c | 4 ++++
python/rpmmodule.c | 1 +
3 files changed, 6 insertions(+)
diff --git a/lib/rpmcallback.h b/lib/rpmcallback.h
index dfc22ab..f07892d 100644
--- a/lib/rpmcallback.h
+++ b/lib/rpmcallback.h
@@ -37,6 +37,7 @@ typedef enum rpmCallbackType_e {
RPMCALLBACK_SCRIPT_START = (1 << 16),
RPMCALLBACK_SCRIPT_STOP = (1 << 17),
RPMCALLBACK_INST_STOP = (1 << 18),
+ RPMCALLBACK_ELEM_PROGRESS = (1 << 19),
} rpmCallbackType;
/** \ingroup rpmts
diff --git a/lib/transaction.c b/lib/transaction.c
index 66888af..4f90782 100644
--- a/lib/transaction.c
+++ b/lib/transaction.c
@@ -1345,12 +1345,16 @@ exit:
static int rpmtsProcess(rpmts ts)
{
rpmtsi pi; rpmte p;
+ tsMembers tsmem = rpmtsMembers(ts);
int rc = 0;
+ int i = 0;
pi = rpmtsiInit(ts);
while ((p = rpmtsiNext(pi, 0)) != NULL) {
int failed;
+ rpmtsNotify(ts, NULL, RPMCALLBACK_ELEM_PROGRESS, i++,
+ tsmem->orderCount);
rpmlog(RPMLOG_DEBUG, "========== +++ %s %s-%s 0x%x\n",
rpmteNEVR(p), rpmteA(p), rpmteO(p), rpmteColor(p));
diff --git a/python/rpmmodule.c b/python/rpmmodule.c
index 0e3ab18..29753fd 100644
--- a/python/rpmmodule.c
+++ b/python/rpmmodule.c
@@ -512,6 +512,7 @@ static int initModule(PyObject *m)
REGISTER_ENUM(RPMCALLBACK_SCRIPT_START);
REGISTER_ENUM(RPMCALLBACK_SCRIPT_STOP);
REGISTER_ENUM(RPMCALLBACK_INST_STOP);
+ REGISTER_ENUM(RPMCALLBACK_ELEM_PROGRESS);
REGISTER_ENUM(RPMPROB_BADARCH);
REGISTER_ENUM(RPMPROB_BADOS);
--
1.9.3

View File

@ -1,277 +0,0 @@
From 6ac793b215ac8d9db99d9632cbf71b014c7ffee0 Mon Sep 17 00:00:00 2001
From: Lubos Kardos <lkardos@redhat.com>
Date: Thu, 12 May 2016 16:28:09 +0200
Subject: [PATCH] Filter unversioned deps if corresponding versioned deps exist
(rhbz:678605)
After automatic dependencies are generated filter out from them
unversioned dependencies if versioned dependencies with the same name,
type and color already exist.
---
build/rpmfc.c | 173 +++++++++++++++++++++++++++++++++++++++-------------------
1 file changed, 118 insertions(+), 55 deletions(-)
diff --git a/build/rpmfc.c b/build/rpmfc.c
index 73996e8..10fbd68 100644
--- a/build/rpmfc.c
+++ b/build/rpmfc.c
@@ -34,6 +34,17 @@ typedef struct rpmfcAttr_s {
struct matchRule excl;
} * rpmfcAttr;
+typedef struct {
+ int fileIx;
+ rpmds dep;
+} rpmfcFileDep;
+
+typedef struct {
+ rpmfcFileDep *data;
+ int size;
+ int alloced;
+} rpmfcFileDeps;
+
/**
*/
struct rpmfc_s {
@@ -56,7 +67,7 @@ struct rpmfc_s {
ARGI_t fddictn; /*!< (no. files) file depends dictionary no. entries */
ARGI_t ddictx; /*!< (no. dependencies) file->dependency mapping */
rpmstrPool cdict; /*!< file class dictionary */
- rpmstrPool ddict; /*!< file depends dictionary */
+ rpmfcFileDeps fileDeps; /*!< file dependency mapping */
rpmstrPool pool; /*!< general purpose string storage */
};
@@ -398,15 +409,15 @@ static void argvAddUniq(ARGV_t * argvp, const char * key)
#define hasAttr(_a, _n) (argvSearch((_a), (_n), NULL) != NULL)
-static void rpmfcAddFileDep(rpmstrPool ddict, int ix, rpmds ds, char deptype)
+static void rpmfcAddFileDep(rpmfcFileDeps *fileDeps, rpmds ds, int ix)
{
- if (ds) {
- char *key = NULL;
- rasprintf(&key, "%08d%c %s %s 0x%08x", ix, deptype,
- rpmdsN(ds), rpmdsEVR(ds), rpmdsFlags(ds));
- rpmstrPoolId(ddict, key, 1);
- free(key);
+ if (fileDeps->size == fileDeps->alloced) {
+ fileDeps->alloced <<= 2;
+ fileDeps->data = xrealloc(fileDeps->data,
+ fileDeps->alloced * sizeof(fileDeps->data[0]));
}
+ fileDeps->data[fileDeps->size].fileIx = ix;
+ fileDeps->data[fileDeps->size++].dep = ds;
}
static ARGV_t runCmd(const char *nsdep, const char *depname,
@@ -531,11 +542,9 @@ static int rpmfcHelper(rpmfc fc, int ix,
/* Add to package and file dependencies unless filtered */
if (regMatch(exclude, rpmdsDNEVR(ds)+2) == 0) {
- (void) rpmdsMerge(packageDependencies(fc->pkg, tagN), ds);
- rpmfcAddFileDep(fc->ddict, ix, ds,
- tagN == RPMTAG_PROVIDENAME ? 'P' : 'R');
+ //rpmdsMerge(packageDependencies(fc->pkg, tagN), ds);
+ rpmfcAddFileDep(&fc->fileDeps, ds, ix);
}
- rpmdsFree(ds);
} else {
rpmlog(RPMLOG_ERR, _("invalid dependency (%s): %s\n"),
err, pav[i]);
@@ -745,7 +754,11 @@ rpmfc rpmfcFree(rpmfc fc)
argiFree(fc->fddictn);
argiFree(fc->ddictx);
- rpmstrPoolFree(fc->ddict);
+ for (int i = 0; i < fc->fileDeps.size; i++) {
+ rpmdsFree(fc->fileDeps.data[i].dep);
+ }
+ free(fc->fileDeps.data);
+
rpmstrPoolFree(fc->cdict);
rpmstrPoolFree(fc->pool);
@@ -764,6 +777,9 @@ rpmfc rpmfcCreate(const char *buildRoot, rpmFlags flags)
}
fc->pool = rpmstrPoolCreate();
fc->pkg = xcalloc(1, sizeof(*fc->pkg));
+ fc->fileDeps.alloced = 10;
+ fc->fileDeps.data = xmalloc(fc->fileDeps.alloced *
+ sizeof(fc->fileDeps.data[0]));
return fc;
}
@@ -820,17 +836,82 @@ rpmds rpmfcObsoletes(rpmfc fc)
return rpmfcDependencies(fc, RPMTAG_OBSOLETENAME);
}
+
+/* Versioned deps are less than unversioned deps */
+static int cmpVerDeps(const void *a, const void *b)
+{
+ rpmfcFileDep *fDepA = (rpmfcFileDep *) a;
+ rpmfcFileDep *fDepB = (rpmfcFileDep *) b;
+
+ int aIsVersioned = rpmdsFlags(fDepA->dep) & RPMSENSE_SENSEMASK ? 1 : 0;
+ int bIsVersioned = rpmdsFlags(fDepB->dep) & RPMSENSE_SENSEMASK ? 1 : 0;
+
+ return bIsVersioned - aIsVersioned;
+}
+
+/* Sort by index */
+static int cmpIndexDeps(const void *a, const void *b)
+{
+ rpmfcFileDep *fDepA = (rpmfcFileDep *) a;
+ rpmfcFileDep *fDepB = (rpmfcFileDep *) b;
+
+ return fDepA->fileIx - fDepB->fileIx;
+}
+
+/*
+ * Remove unversioned deps if corresponding versioned deps exist but only
+ * if the versioned dependency has the same type and the same color as the versioned.
+ */
+static void rpmfcNormalizeFDeps(rpmfc fc)
+{
+ rpmstrPool versionedDeps = rpmstrPoolCreate();
+ rpmfcFileDep *normalizedFDeps = xmalloc(fc->fileDeps.size *
+ sizeof(normalizedFDeps[0]));
+ int ix = 0;
+ char *depStr;
+
+ /* Sort. Versioned dependencies first */
+ qsort(fc->fileDeps.data, fc->fileDeps.size, sizeof(fc->fileDeps.data[0]),
+ cmpVerDeps);
+
+ for (int i = 0; i < fc->fileDeps.size; i++) {
+ switch (rpmdsTagN(fc->fileDeps.data[i].dep)) {
+ case RPMTAG_REQUIRENAME:
+ case RPMTAG_RECOMMENDNAME:
+ case RPMTAG_SUGGESTNAME:
+ rasprintf(&depStr, "%08x_%c_%s",
+ fc->fcolor[fc->fileDeps.data[i].fileIx],
+ rpmdsD(fc->fileDeps.data[i].dep),
+ rpmdsN(fc->fileDeps.data[i].dep));
+
+ if (rpmdsFlags(fc->fileDeps.data[i].dep) & RPMSENSE_SENSEMASK) {
+ /* preserve versioned require dependency */
+ normalizedFDeps[ix++] = fc->fileDeps.data[i];
+ rpmstrPoolId(versionedDeps, depStr, 1);
+ } else if (!rpmstrPoolId(versionedDeps, depStr, 0)) {
+ /* preserve unversioned require dep only if versioned dep doesn't exist */
+ normalizedFDeps[ix++] =fc-> fileDeps.data[i];
+ } else {
+ rpmdsFree(fc->fileDeps.data[i].dep);
+ }
+ free(depStr);
+ break;
+ default:
+ /* Preserve all non-require dependencies */
+ normalizedFDeps[ix++] = fc->fileDeps.data[i];
+ break;
+ }
+ }
+ rpmstrPoolFree(versionedDeps);
+
+ free(fc->fileDeps.data);
+ fc->fileDeps.data = normalizedFDeps;
+ fc->fileDeps.size = ix;
+}
+
static rpmRC rpmfcApplyInternal(rpmfc fc)
{
- const char * s;
- char * se;
rpmds ds, * dsp;
- rpmTagVal tagN;
- const char * N;
- const char * EVR;
- rpmsenseFlags Flags;
- unsigned char deptype;
- int nddict;
int previx;
unsigned int val;
int dix;
@@ -862,45 +943,28 @@ static rpmRC rpmfcApplyInternal(rpmfc fc)
}
}
/* No more additions after this, freeze pool to minimize memory use */
- rpmstrPoolFreeze(fc->ddict, 0);
+
+ rpmfcNormalizeFDeps(fc);
+ for (int i = 0; i < fc->fileDeps.size; i++) {
+ ds = fc->fileDeps.data[i].dep;
+ rpmdsMerge(packageDependencies(fc->pkg, rpmdsTagN(ds)), ds);
+ }
+
+ /* Sort by index */
+ qsort(fc->fileDeps.data, fc->fileDeps.size,
+ sizeof(fc->fileDeps.data[0]), cmpIndexDeps);
/* Generate per-file indices into package dependencies. */
- nddict = rpmstrPoolNumStr(fc->ddict);
previx = -1;
- for (rpmsid id = 1; id <= nddict; id++) {
- s = rpmstrPoolStr(fc->ddict, id);
-
- /* Parse out (file#,deptype,N,EVR,Flags) */
- ix = strtol(s, &se, 10);
- if ( se == NULL ) {
- rpmlog(RPMLOG_ERR, _("Conversion of %s to long integer failed.\n"), s);
- return RPMRC_FAIL;
- }
-
- deptype = *se++;
- se++;
- N = se;
- while (*se && *se != ' ')
- se++;
- *se++ = '\0';
- EVR = se;
- while (*se && *se != ' ')
- se++;
- *se++ = '\0';
- Flags = strtol(se, NULL, 16);
-
- dix = -1;
-
- tagN = rpmdsDToTagN(deptype);
- dsp = packageDependencies(fc->pkg, tagN);
- ds = rpmdsSinglePool(fc->pool, tagN, N, EVR, Flags);
+ for (int i = 0; i < fc->fileDeps.size; i++) {
+ ds = fc->fileDeps.data[i].dep;
+ ix = fc->fileDeps.data[i].fileIx;
+ dsp = packageDependencies(fc->pkg, rpmdsTagN(ds));
dix = rpmdsFind(*dsp, ds);
- rpmdsFree(ds);
-
if (dix < 0)
continue;
- val = (deptype << 24) | (dix & 0x00ffffff);
+ val = (rpmdsD(ds) << 24) | (dix & 0x00ffffff);
argiAdd(&fc->ddictx, -1, val);
if (previx != ix) {
@@ -909,8 +973,8 @@ static rpmRC rpmfcApplyInternal(rpmfc fc)
}
if (fc->fddictn && fc->fddictn->vals)
fc->fddictn->vals[ix]++;
- }
+ }
return RPMRC_OK;
}
@@ -968,7 +1032,6 @@ rpmRC rpmfcClassify(rpmfc fc, ARGV_t argv, rpm_mode_t * fmode)
/* Build (sorted) file class dictionary. */
fc->cdict = rpmstrPoolCreate();
- fc->ddict = rpmstrPoolCreate();
ms = magic_open(msflags);
if (ms == NULL) {
--
1.9.3

View File

@ -1,59 +0,0 @@
From 9c36ca411332d2718eca339e867561c39abc256b Mon Sep 17 00:00:00 2001
From: Lubos Kardos <lkardos@redhat.com>
Date: Fri, 6 Nov 2015 14:49:59 +0100
Subject: [PATCH] Fix crash when parsing corrupted RPM file (rhbz:1273360)
---
lib/legacy.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/lib/legacy.c b/lib/legacy.c
index 422c2b0..8ba7bbd 100644
--- a/lib/legacy.c
+++ b/lib/legacy.c
@@ -25,7 +25,7 @@ static void compressFilelist(Header h)
char ** dirNames;
const char ** baseNames;
uint32_t * dirIndexes;
- rpm_count_t count;
+ rpm_count_t count, realCount = 0;
int i;
int dirIndex = -1;
@@ -58,6 +58,7 @@ static void compressFilelist(Header h)
while ((i = rpmtdNext(&fileNames)) >= 0) {
dirIndexes[i] = dirIndex;
baseNames[i] = rpmtdGetString(&fileNames);
+ realCount++;
}
goto exit;
}
@@ -87,19 +88,20 @@ static void compressFilelist(Header h)
(needle = bsearch(&filename, dirNames, dirIndex + 1, sizeof(dirNames[0]), dncmp)) == NULL) {
char *s = xmalloc(len + 1);
rstrlcpy(s, filename, len + 1);
- dirIndexes[i] = ++dirIndex;
+ dirIndexes[realCount] = ++dirIndex;
dirNames[dirIndex] = s;
} else
- dirIndexes[i] = needle - dirNames;
+ dirIndexes[realCount] = needle - dirNames;
*baseName = savechar;
- baseNames[i] = baseName;
+ baseNames[realCount] = baseName;
+ realCount++;
}
exit:
if (count > 0) {
- headerPutUint32(h, RPMTAG_DIRINDEXES, dirIndexes, count);
- headerPutStringArray(h, RPMTAG_BASENAMES, baseNames, count);
+ headerPutUint32(h, RPMTAG_DIRINDEXES, dirIndexes, realCount);
+ headerPutStringArray(h, RPMTAG_BASENAMES, baseNames, realCount);
headerPutStringArray(h, RPMTAG_DIRNAMES,
(const char **) dirNames, dirIndex + 1);
}
--
1.9.3

View File

@ -1,31 +0,0 @@
From 50905f4a599f167622736fab24800fe062551809 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Neal=20Gompa=20=28=E3=83=8B=E3=83=BC=E3=83=AB=E3=83=BB?=
=?UTF-8?q?=E3=82=B3=E3=82=99=E3=83=B3=E3=83=8F=E3=82=9A=29?=
<ngompa13@gmail.com>
Date: Sun, 13 Mar 2016 09:05:00 -0400
Subject: [PATCH] Use fuzz settings for %autopatch/%autosetup
In the %apply_patches that inspired %autopatch, patch application
respects the fuzz settings that are used for %patch. %autopatch
and %autosetup weren't using this, which led to an inconsistent
patch application behavior.
---
macros.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/macros.in b/macros.in
index 7b807f9..ce252d4 100644
--- a/macros.in
+++ b/macros.in
@@ -1085,7 +1085,7 @@ done \
# Plain patch (-m is unused)
%__scm_setup_patch(q) %{nil}
%__scm_apply_patch(qp:m:)\
-%{__patch} %{-p:-p%{-p*}} %{-q:-s}
+%{__patch} %{-p:-p%{-p*}} %{-q:-s} --fuzz=%{_default_patch_fuzz}
# Mercurial (aka hg)
%__scm_setup_hg(q)\
--
1.9.3

View File

@ -1,27 +0,0 @@
From 83219d023b5b21826c7482d4aa3f6372f520825d Mon Sep 17 00:00:00 2001
From: Florian Festi <ffesti@redhat.com>
Date: Fri, 19 Feb 2016 09:56:31 +0100
Subject: [PATCH] Also block idle and sleep in the systemd-inhibit plugin
We really should not suspend or hibernate during rpm operations. Chances are
too high to not wake up properly and damage the system (see rhbz#1297984).
---
plugins/systemd_inhibit.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugins/systemd_inhibit.c b/plugins/systemd_inhibit.c
index b05d3d2..4a90c44 100644
--- a/plugins/systemd_inhibit.c
+++ b/plugins/systemd_inhibit.c
@@ -27,7 +27,7 @@ static int inhibit(void)
}
if (msg) {
- const char *what = "shutdown";
+ const char *what = "idle:sleep:shutdown";
const char *mode = "block";
const char *who = "RPM";
const char *reason = "Transaction running";
--
2.5.0

View File

@ -1,49 +0,0 @@
From 90d8cc16486479441477e89c2e09bd4f9f7604bb Mon Sep 17 00:00:00 2001
From: Lubos Kardos <lkardos@redhat.com>
Date: Fri, 30 Oct 2015 14:42:32 +0100
Subject: [PATCH] Ignore SIGPIPE signals during execucton of scriptlets
(rhbz:1264198)
---
lib/rpmscript.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/lib/rpmscript.c b/lib/rpmscript.c
index 493f4f2..98d3f42 100644
--- a/lib/rpmscript.c
+++ b/lib/rpmscript.c
@@ -271,6 +271,7 @@ static rpmRC runExtScript(rpmPlugins plugins, ARGV_const_t prefixes,
const char *line;
char *mline = NULL;
rpmRC rc = RPMRC_FAIL;
+ struct sigaction newact, oldact;
rpmlog(RPMLOG_DEBUG, "%s: scriptlet start\n", sname);
@@ -318,6 +319,12 @@ static rpmRC runExtScript(rpmPlugins plugins, ARGV_const_t prefixes,
goto exit;
}
+ /* Ignore SIGPIPE during execution of scriptlets */
+ sigemptyset(&newact.sa_mask);
+ newact.sa_flags = 0;
+ newact.sa_handler = SIG_IGN;
+ sigaction(SIGPIPE, &newact, &oldact);
+
pid = fork();
if (pid == (pid_t) -1) {
rpmlog(RPMLOG_ERR, _("Couldn't fork %s: %s\n"),
@@ -428,6 +435,10 @@ exit:
free(fn);
}
free(mline);
+
+ /* Restore SIGPIPE handler */
+ sigaction(SIGPIPE, &oldact, NULL);
+
return rc;
}
--
1.9.3

View File

@ -1,194 +0,0 @@
From 877d5b130cbfdfd93ad39c1f0f1505790eba264e Mon Sep 17 00:00:00 2001
From: Lubos Kardos <lkardos@redhat.com>
Date: Wed, 16 Mar 2016 17:15:14 +0100
Subject: [PATCH] Fix non-working combination of %lang and %doc directive
(rhbz:1254483)
---
build/files.c | 99 +++++++++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 76 insertions(+), 23 deletions(-)
diff --git a/build/files.c b/build/files.c
index 81bb600..3976fb6 100644
--- a/build/files.c
+++ b/build/files.c
@@ -103,14 +103,6 @@ typedef struct AttrRec_s {
/* list of files */
static StringBuf check_fileList = NULL;
-typedef struct specialDir_s {
- char * dirname;
- ARGV_t files;
- struct AttrRec_s ar;
- struct AttrRec_s def_ar;
- rpmFlags sdtype;
-} * specialDir;
-
typedef struct FileEntry_s {
rpmfileAttrs attrFlags;
specfFlags specdFlags;
@@ -127,6 +119,23 @@ typedef struct FileEntry_s {
int isDir;
} * FileEntry;
+typedef struct specialDir_s {
+ char * dirname;
+ ARGV_t files;
+ struct AttrRec_s ar;
+ struct AttrRec_s def_ar;
+ rpmFlags sdtype;
+
+ int entriesCount;
+ int entriesAlloced;
+
+ struct {
+ struct FileEntry_s defEntry;
+ struct FileEntry_s curEntry;
+ } *entries;
+
+} * specialDir;
+
typedef struct FileRecords_s {
FileListRec recs;
int alloced;
@@ -169,6 +178,22 @@ static void dupAttrRec(const AttrRec oar, AttrRec nar)
*nar = *oar; /* struct assignment */
}
+static void copyFileEntry(FileEntry src, FileEntry dest)
+{
+ /* Copying struct makes just shallow copy */
+ *dest = *src;
+
+ /* Do also deep copying */
+ if (src->langs != NULL) {
+ dest->langs = argvNew();
+ argvAppend(&dest->langs, src->langs);
+ }
+
+ if (src->caps != NULL) {
+ dest->caps = xstrdup(src->caps);
+ }
+}
+
static void FileEntryFree(FileEntry entry)
{
argvFree(entry->langs);
@@ -1683,22 +1708,47 @@ static char * getSpecialDocDir(Header h, rpmFlags sdtype)
return res;
}
-static specialDir specialDirNew(Header h, rpmFlags sdtype,
- AttrRec ar, AttrRec def_ar)
+static specialDir specialDirNew(Header h, rpmFlags sdtype)
{
specialDir sd = xcalloc(1, sizeof(*sd));
- dupAttrRec(ar, &(sd->ar));
- dupAttrRec(def_ar, &(sd->def_ar));
+
+ sd->entriesCount = 0;
+ sd->entriesAlloced = 10;
+ sd->entries = xcalloc(sd->entriesAlloced, sizeof(sd->entries[0]));
+
sd->dirname = getSpecialDocDir(h, sdtype);
sd->sdtype = sdtype;
return sd;
}
+static void addSpecialFile(specialDir sd, const char *path, FileEntry cur,
+ FileEntry def)
+{
+ argvAdd(&sd->files, path);
+
+ if (sd->entriesCount >= sd->entriesAlloced) {
+ sd->entriesAlloced <<= 1;
+ sd->entries = xrealloc(sd->entries, sd->entriesAlloced *
+ sizeof(sd->entries[0]));
+ }
+
+ copyFileEntry(cur, &sd->entries[sd->entriesCount].curEntry);
+ copyFileEntry(def, &sd->entries[sd->entriesCount].defEntry);
+ sd->entriesCount++;
+}
+
static specialDir specialDirFree(specialDir sd)
{
+ int i = 0;
+
if (sd) {
argvFree(sd->files);
free(sd->dirname);
+ for (i = 0; i < sd->entriesCount; i++) {
+ FileEntryFree(&sd->entries[i].curEntry);
+ FileEntryFree(&sd->entries[i].defEntry);
+ }
+ free(sd->entries);
free(sd);
}
return NULL;
@@ -1712,6 +1762,7 @@ static void processSpecialDir(rpmSpec spec, Package pkg, FileList fl,
char *mkdocdir = rpmExpand("%{__mkdir_p} $", sdenv, NULL);
StringBuf docScript = newStringBuf();
char *basepath, **files;
+ int fi;
appendStringBuf(docScript, sdenv);
appendStringBuf(docScript, "=$RPM_BUILD_ROOT");
@@ -1739,16 +1790,9 @@ static void processSpecialDir(rpmSpec spec, Package pkg, FileList fl,
fl->processingFailed = 1;
}
- /* Reset for %doc */
- FileEntryFree(&fl->cur);
-
- fl->cur.attrFlags |= sd->sdtype;
- fl->cur.verifyFlags = fl->def.verifyFlags;
- dupAttrRec(&(sd->ar), &(fl->cur.ar));
- dupAttrRec(&(sd->def_ar), &(fl->def.ar));
-
basepath = rpmGenPath(spec->rootDir, "%{_builddir}", spec->buildSubdir);
files = sd->files;
+ fi = 0;
while (*files != NULL) {
char *origfile = rpmGenPath(basepath, *files, NULL);
char *eorigfile = rpmEscapeSpaces(origfile);
@@ -1756,6 +1800,12 @@ static void processSpecialDir(rpmSpec spec, Package pkg, FileList fl,
int globFilesCount, i;
char *newfile;
+ FileEntryFree(&fl->cur);
+ FileEntryFree(&fl->def);
+ copyFileEntry(&sd->entries[fi].curEntry, &fl->cur);
+ copyFileEntry(&sd->entries[fi].defEntry, &fl->def);
+ fi++;
+
if (rpmGlob(eorigfile, &globFilesCount, &globFiles) == 0) {
for (i = 0; i < globFilesCount; i++) {
rasprintf(&newfile, "%s/%s", sd->dirname, basename(globFiles[i]));
@@ -1773,6 +1823,10 @@ static void processSpecialDir(rpmSpec spec, Package pkg, FileList fl,
}
free(basepath);
+ FileEntryFree(&fl->cur);
+ FileEntryFree(&fl->def);
+ copyFileEntry(&sd->entries[0].defEntry, &fl->def);
+ copyFileEntry(&sd->entries[0].defEntry, &fl->cur);
fl->cur.isDir = 1;
(void) processBinaryFile(pkg, fl, sd->dirname);
@@ -1867,10 +1921,9 @@ static rpmRC processPackageFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags,
/* save attributes on first special doc/license for later use */
if (*sdp == NULL) {
- *sdp = specialDirNew(pkg->header, oattrs,
- &fl.cur.ar, &fl.def.ar);
+ *sdp = specialDirNew(pkg->header, oattrs);
}
- argvAdd(&(*sdp)->files, *fn);
+ addSpecialFile(*sdp, *fn, &fl.cur, &fl.def);
continue;
}
--
1.9.3

View File

@ -1,29 +0,0 @@
From 54f24ec5486bdacde9419466a2c27defaddf508e Mon Sep 17 00:00:00 2001
From: Lubos Kardos <lkardos@redhat.com>
Date: Mon, 21 Sep 2015 11:02:45 +0200
Subject: [PATCH] Fix reading a memory right after the end of an allocated
area.
The problem evinced itself when somebody tried to use the macro
expansion on the string "%!". The problem was revealed by compiling
with "--fsanitize=memory" (rhbz:#1260248).
---
rpmio/macro.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rpmio/macro.c b/rpmio/macro.c
index 46e6b87..4b3c41b 100644
--- a/rpmio/macro.c
+++ b/rpmio/macro.c
@@ -993,7 +993,7 @@ expandMacro(MacroBuf mb, const char *src, size_t slen)
chkexist = 0;
switch ((c = *s)) {
default: /* %name substitution */
- while (strchr("!?", *s) != NULL) {
+ while (*s != '\0' && strchr("!?", *s) != NULL) {
switch(*s++) {
case '!':
negate = ((negate + 1) % 2);
--
1.9.3

View File

@ -1,24 +0,0 @@
From 8efe51e8c24b7739f0bf7680e21083c8964633f5 Mon Sep 17 00:00:00 2001
From: Florian Festi <ffesti@redhat.com>
Date: Fri, 15 Jan 2016 14:32:47 +0100
Subject: [PATCH] Add support for %missingok as a standalone file attribute
---
build/files.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/build/files.c b/build/files.c
index d00a785..2d72633 100644
--- a/build/files.c
+++ b/build/files.c
@@ -783,6 +783,7 @@ static VFA_t const virtualAttrs[] = {
{ "%readme", RPMFILE_README },
{ "%license", RPMFILE_LICENSE },
{ "%pubkey", RPMFILE_PUBKEY },
+ { "%missingok", RPMFILE_MISSINGOK },
{ NULL, 0 }
};
--
2.1.0

View File

@ -1,25 +0,0 @@
From 69ed95eb422c59f9d99f75ccb78f32311a31702d Mon Sep 17 00:00:00 2001
From: Lubos Kardos <lkardos@redhat.com>
Date: Fri, 15 Apr 2016 10:45:47 +0200
Subject: [PATCH 2/2] Enable --no-backup-if-mismatch by default in %patch macro
(rhbz:884755)
---
macros.in | 1 +
1 file changed, 1 insertion(+)
diff --git a/macros.in b/macros.in
index bbff0c1..f9172d0 100644
--- a/macros.in
+++ b/macros.in
@@ -364,6 +364,7 @@ package or when debugging this package.\
# Default patch flags
#%_default_patch_flags -s
+%_default_patch_flags --no-backup-if-mismatch
#==============================================================================
# ---- Build configuration macros.
--
1.9.3

View File

@ -1,31 +0,0 @@
From 258e3065687c9e6b53b6f2b6c7fa6c5694508791 Mon Sep 17 00:00:00 2001
From: Lubos Kardos <lkardos@redhat.com>
Date: Mon, 23 May 2016 10:19:39 +0200
Subject: [PATCH] Fix signing with non-ASCII uid keys (rhbz:1243963)
Removed setting LC_ALL to "C" because since commit [1] the gpg program
gets password by yourself from terminal so there is no sense in
setting LC_ALL to "C" if the terminal settings is e. g. UTF-8. That was
only confusing gpg program and it was not able to properly get and
display non-ASCII characters.
[1] 0bce5fcf270711a2e077fba0fb7c5979ea007eb5
---
sign/rpmgensig.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/sign/rpmgensig.c b/sign/rpmgensig.c
index 2310f14..321d19c 100644
--- a/sign/rpmgensig.c
+++ b/sign/rpmgensig.c
@@ -267,7 +267,6 @@ static int runGPG(sigTarget sigt, const char *sigfile)
if (gpg_path && *gpg_path != '\0')
(void) setenv("GNUPGHOME", gpg_path, 1);
- (void) setenv("LC_ALL", "C", 1);
unsetenv("MALLOC_CHECK_");
cmd = rpmExpand("%{?__gpg_sign_cmd}", NULL);
--
1.9.3

View File

@ -1,48 +0,0 @@
From f5bab7c054de3607d43dcc5ee8a04c2e3cd46926 Mon Sep 17 00:00:00 2001
From: Lubos Kardos <lkardos@redhat.com>
Date: Fri, 23 Oct 2015 12:20:45 +0200
Subject: [PATCH] Warn if epoch is not unsigned integer (rhbz:1251453)
---
build/parseReqs.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/build/parseReqs.c b/build/parseReqs.c
index bef0a2b..acdfeb9 100644
--- a/build/parseReqs.c
+++ b/build/parseReqs.c
@@ -25,6 +25,22 @@ static rpmRC checkSep(const char *s, char c, char **emsg)
return RPMRC_OK;
}
+static rpmRC checkEpoch(const char *s, char **emsg)
+{
+ const char *si, *sep = strchr(s, ':');
+
+ if (!sep)
+ return RPMRC_OK;
+
+ for (si = s; si != sep; si++) {
+ if (!risdigit(*si)) {
+ rasprintf(emsg, "Invalid version (epoch must be unsigned integer): %s", s);
+ break;
+ }
+ }
+ return RPMRC_OK;
+}
+
static rpmRC checkDep(rpmSpec spec, char *N, char *EVR, char **emsg)
{
/*
@@ -44,6 +60,8 @@ static rpmRC checkDep(rpmSpec spec, char *N, char *EVR, char **emsg)
return RPMRC_FAIL;
if (checkSep(EVR, '-', emsg) != RPMRC_OK || checkSep(EVR, ':', emsg) != RPMRC_OK)
return RPMRC_FAIL;
+ if (checkEpoch(EVR, emsg) != RPMRC_OK)
+ return RPMRC_FAIL;
}
return RPMRC_OK;
}
--
1.9.3

View File

@ -1,29 +0,0 @@
From 66a6082634687e45b321a5ade9887420d5830162 Mon Sep 17 00:00:00 2001
From: Lubos Kardos <lkardos@redhat.com>
Date: Fri, 15 Apr 2016 10:47:57 +0200
Subject: [PATCH 1/2] Add %{_default_patch_flags} to %__patch which is used in
%autosetup
%{_default_patch_flags} is used in %patch spec directive and now it is
used also in %__patch macro which is used in %autosetup macro. This make
consitent using newer %autosetup macro and older %patch directives.
---
macros.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/macros.in b/macros.in
index ce252d4..bbff0c1 100644
--- a/macros.in
+++ b/macros.in
@@ -1085,7 +1085,7 @@ done \
# Plain patch (-m is unused)
%__scm_setup_patch(q) %{nil}
%__scm_apply_patch(qp:m:)\
-%{__patch} %{-p:-p%{-p*}} %{-q:-s} --fuzz=%{_default_patch_fuzz}
+%{__patch} %{-p:-p%{-p*}} %{-q:-s} --fuzz=%{_default_patch_fuzz} %{_default_patch_flags}
# Mercurial (aka hg)
%__scm_setup_hg(q)\
--
1.9.3

View File

@ -1,35 +0,0 @@
From d20b7d2b00e349610f3cf08d9ff3723cc7c56e32 Mon Sep 17 00:00:00 2001
From: Florian Festi <ffesti@redhat.com>
Date: Mon, 7 Sep 2015 11:39:36 +0200
Subject: [PATCH] Fix rpmrichOpStr to use the new syntax
You need to rebuild all packages using rich deps build with previous versions of rpm as the richdeps are converted to the old syntax.
---
lib/rpmds.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/rpmds.c b/lib/rpmds.c
index 77733bc..ba6e244 100644
--- a/lib/rpmds.c
+++ b/lib/rpmds.c
@@ -1390,13 +1390,13 @@ const char *rpmrichOpStr(rpmrichOp op)
if (op == RPMRICHOP_SINGLE)
return "SINGLE";
if (op == RPMRICHOP_AND)
- return "&";
+ return "and";
if (op == RPMRICHOP_OR)
- return "|";
+ return "or";
if (op == RPMRICHOP_IF)
- return "IF";
+ return "if";
if (op == RPMRICHOP_ELSE)
- return "ELSE";
+ return "else";
return NULL;
}
--
2.1.0

View File

@ -1,31 +0,0 @@
From 33158b3b009e830036d05c138a6b308c1574effe Mon Sep 17 00:00:00 2001
From: Lubos Kardos <lkardos@redhat.com>
Date: Fri, 15 Jan 2016 15:41:52 +0100
Subject: [PATCH] Fix recursive calling of rpmdeps tool (rhbz:1297557)
---
scripts/find-provides | 2 +-
scripts/find-requires | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/find-provides b/scripts/find-provides
index c5cf93b..817f5ee 100755
--- a/scripts/find-provides
+++ b/scripts/find-provides
@@ -1,3 +1,3 @@
#!/bin/sh
-/usr/lib/rpm/rpmdeps --provides
+/usr/lib/rpm/rpmdeps --define="_use_internal_dependency_generator 1" --provides
diff --git a/scripts/find-requires b/scripts/find-requires
index 9d192dd..fa5bc88 100755
--- a/scripts/find-requires
+++ b/scripts/find-requires
@@ -1,3 +1,3 @@
#!/bin/sh
-/usr/lib/rpm/rpmdeps --requires
+/usr/lib/rpm/rpmdeps --define="_use_internal_dependency_generator 1" --requires
--
1.9.3

View File

@ -1,71 +0,0 @@
From 19fe0d9ae12644b8af9513aa2a8cf7d16f7caa61 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Fri, 4 Mar 2016 16:40:30 -0500
Subject: [PATCH] Add posix.redirect2null
This is useful to silence output in forked programs:
https://bugzilla.redhat.com/show_bug.cgi?id=1287918
Tested with the following scriptlet:
%post -p <lua>
pid = posix.fork()
if pid == 0 then
assert(posix.exec("/bin/sed"))
elseif pid > 0 then
posix.wait(pid)
end
pid = posix.fork()
if pid == 0 then
posix.redirect2null(2)
assert(posix.exec("/bin/awk"))
elseif pid > 0 then
posix.wait(pid)
end
As expected, the error message from sed is printed, the error message
from awk is not.
---
luaext/lposix.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/luaext/lposix.c b/luaext/lposix.c
index 51ea2b3..c578c5a 100644
--- a/luaext/lposix.c
+++ b/luaext/lposix.c
@@ -819,6 +819,25 @@ static int Pmkstemp(lua_State *L)
return 2;
}
+static int Predirect2null(lua_State *L)
+{
+ int target_fd, fd, r, e;
+
+ if (!have_forked)
+ return luaL_error(L, "silence_file_descriptor not permitted in this context");
+
+ target_fd = luaL_checkinteger(L, 1);
+
+ r = fd = open("/dev/null", O_WRONLY);
+ if (fd >= 0 && fd != target_fd) {
+ r = dup2(fd, target_fd);
+ e = errno;
+ (void) close(fd);
+ errno = e;
+ }
+ return pushresult(L, r, NULL);
+}
+
static const luaL_Reg R[] =
{
{"access", Paccess},
@@ -861,6 +880,7 @@ static const luaL_Reg R[] =
{"wait", Pwait},
{"setenv", Psetenv},
{"unsetenv", Punsetenv},
+ {"redirect2null", Predirect2null},
{NULL, NULL}
};
--
1.9.3

View File

@ -1,176 +0,0 @@
From 7a84b45c62cd25c4c68ad295ac5f360b1daebf6a Mon Sep 17 00:00:00 2001
From: Lubos Kardos <lkardos@redhat.com>
Date: Mon, 21 Sep 2015 14:13:22 +0200
Subject: [PATCH] Add support for various types of dependencies to rpmdeps tool
Options added to rpmdeps tool:
--recommends
--suggests
--supplements
--enhances
--conflicts
--obsoletes
---
build/rpmfc.c | 30 ++++++++++++++++++++++++++++++
build/rpmfc.h | 42 ++++++++++++++++++++++++++++++++++++++++++
tools/rpmdeps.c | 36 ++++++++++++++++++++++++++++++++++++
3 files changed, 108 insertions(+)
diff --git a/build/rpmfc.c b/build/rpmfc.c
index 7565b18..3637f5c 100644
--- a/build/rpmfc.c
+++ b/build/rpmfc.c
@@ -789,6 +789,36 @@ rpmds rpmfcRequires(rpmfc fc)
return rpmfcDependencies(fc, RPMTAG_REQUIRENAME);
}
+rpmds rpmfcRecommends(rpmfc fc)
+{
+ return rpmfcDependencies(fc, RPMTAG_RECOMMENDNAME);
+}
+
+rpmds rpmfcSuggests(rpmfc fc)
+{
+ return rpmfcDependencies(fc, RPMTAG_SUGGESTNAME);
+}
+
+rpmds rpmfcSupplements(rpmfc fc)
+{
+ return rpmfcDependencies(fc, RPMTAG_SUPPLEMENTNAME);
+}
+
+rpmds rpmfcEnhances(rpmfc fc)
+{
+ return rpmfcDependencies(fc, RPMTAG_ENHANCENAME);
+}
+
+rpmds rpmfcConflicts(rpmfc fc)
+{
+ return rpmfcDependencies(fc, RPMTAG_CONFLICTNAME);
+}
+
+rpmds rpmfcObsoletes(rpmfc fc)
+{
+ return rpmfcDependencies(fc, RPMTAG_OBSOLETENAME);
+}
+
static rpmRC rpmfcApplyInternal(rpmfc fc)
{
const char * s;
diff --git a/build/rpmfc.h b/build/rpmfc.h
index bd1c660..dae8ea5 100644
--- a/build/rpmfc.h
+++ b/build/rpmfc.h
@@ -107,6 +107,48 @@ rpmds rpmfcProvides(rpmfc fc);
rpmds rpmfcRequires(rpmfc fc);
/** \ingroup rpmfc
+ * Retrieve file classification recommends
+ * @param fc file classifier
+ * @return rpmds dependency set of fc recommends
+ */
+rpmds rpmfcRecommends(rpmfc fc);
+
+/** \ingroup rpmfc
+ * Retrieve file classification suggests
+ * @param fc file classifier
+ * @return rpmds dependency set of fc suggests
+ */
+rpmds rpmfcSuggests(rpmfc fc);
+
+/** \ingroup rpmfc
+ * Retrieve file classification supplements
+ * @param fc file classifier
+ * @return rpmds dependency set of fc supplements
+ */
+rpmds rpmfcSupplements(rpmfc fc);
+
+/** \ingroup rpmfc
+ * Retrieve file classification enhances
+ * @param fc file classifier
+ * @return rpmds dependency set of fc enhances
+ */
+rpmds rpmfcEnhances(rpmfc fc);
+
+/** \ingroup rpmfc
+ * Retrieve file classification conflicts
+ * @param fc file classifier
+ * @return rpmds dependency set of fc conflicts
+ */
+rpmds rpmfcConflicts(rpmfc fc);
+
+/** \ingroup rpmfc
+ * Retrieve file classification obsoletes
+ * @param fc file classifier
+ * @return rpmds dependency set of fc obsoletes
+ */
+rpmds rpmfcObsoletes(rpmfc fc);
+
+/** \ingroup rpmfc
* Retrieve file classification dependencies
* @param fc file classifier
* @param tagN name tag of the wanted dependency
diff --git a/tools/rpmdeps.c b/tools/rpmdeps.c
index c3112eb..ff785f0 100644
--- a/tools/rpmdeps.c
+++ b/tools/rpmdeps.c
@@ -14,6 +14,18 @@ static int print_provides;
static int print_requires;
+static int print_recommends;
+
+static int print_suggests;
+
+static int print_supplements;
+
+static int print_enhances;
+
+static int print_conflicts;
+
+static int print_obsoletes;
+
static void rpmdsPrint(const char * msg, rpmds ds, FILE * fp)
{
if (fp == NULL) fp = stderr;
@@ -36,6 +48,18 @@ static struct poptOption optionsTable[] = {
NULL, NULL },
{ "requires", 'R', POPT_ARG_VAL, &print_requires, -1,
NULL, NULL },
+ { "recommends", '\0', POPT_ARG_VAL, &print_recommends, -1,
+ NULL, NULL },
+ { "suggests", '\0', POPT_ARG_VAL, &print_suggests, -1,
+ NULL, NULL },
+ { "supplements", '\0', POPT_ARG_VAL, &print_supplements, -1,
+ NULL, NULL },
+ { "enhances", '\0', POPT_ARG_VAL, &print_enhances, -1,
+ NULL, NULL },
+ { "conflicts", '\0', POPT_ARG_VAL, &print_conflicts, -1,
+ NULL, NULL },
+ { "obsoletes", '\0', POPT_ARG_VAL, &print_obsoletes, -1,
+ NULL, NULL },
POPT_AUTOALIAS
POPT_AUTOHELP
@@ -89,6 +113,18 @@ main(int argc, char *argv[])
rpmdsPrint(NULL, rpmfcProvides(fc), stdout);
if (print_requires)
rpmdsPrint(NULL, rpmfcRequires(fc), stdout);
+ if (print_recommends)
+ rpmdsPrint(NULL, rpmfcRecommends(fc), stdout);
+ if (print_suggests)
+ rpmdsPrint(NULL, rpmfcSuggests(fc), stdout);
+ if (print_supplements)
+ rpmdsPrint(NULL, rpmfcSupplements(fc), stdout);
+ if (print_enhances)
+ rpmdsPrint(NULL, rpmfcEnhances(fc), stdout);
+ if (print_conflicts)
+ rpmdsPrint(NULL, rpmfcConflicts(fc), stdout);
+ if (print_obsoletes)
+ rpmdsPrint(NULL, rpmfcObsoletes(fc), stdout);
ec = 0;
--
1.9.3

View File

@ -1,27 +0,0 @@
From b722cf86200505b3e3fcbb2095c4ff61f1f5a2ab Mon Sep 17 00:00:00 2001
From: Lubos Kardos <lkardos@redhat.com>
Date: Mon, 25 Apr 2016 13:31:08 +0200
Subject: [PATCH 1/2] Fix reading rpmtd behind its size in formatValue()
(rhbz:1316896)
When it is read from index higher than size of rpmtd, return "(none)".
---
lib/headerfmt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/headerfmt.c b/lib/headerfmt.c
index fb29d6f..f6fd707 100644
--- a/lib/headerfmt.c
+++ b/lib/headerfmt.c
@@ -623,7 +623,7 @@ static char * formatValue(headerSprintfArgs hsa, sprintfTag tag, int element)
char * t, * te;
rpmtd td;
- if ((td = getData(hsa, tag->tag))) {
+ if ((td = getData(hsa, tag->tag)) && td->count > element) {
td->ix = element; /* Ick, use iterators instead */
val = tag->fmt(td);
} else {
--
1.9.3

View File

@ -1,40 +0,0 @@
From 0d214a17e412bffa00cfede2d884f02ac78b8434 Mon Sep 17 00:00:00 2001
From: Florian Festi <ffesti@redhat.com>
Date: Mon, 12 Oct 2015 12:47:45 +0200
Subject: [PATCH] Permit scriptlet exec context setting to fail in
non-enforcing modes
for new code path, too.
See also 9c082fb8689efdaa5a595d3043e67ccec4ed930c
---
plugins/selinux.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/plugins/selinux.c b/plugins/selinux.c
index ea6853b..2751815 100644
--- a/plugins/selinux.c
+++ b/plugins/selinux.c
@@ -134,9 +134,6 @@ exit:
freecon(fcon);
freecon(mycon);
- /* If selinux is not enforcing, we don't care either */
- if (rc && security_getenforce() < 1)
- rc = RPMRC_OK;
#else
if (sehandle == NULL)
return RPMRC_OK;
@@ -149,6 +146,9 @@ exit:
path, (xx < 0 ? strerror(errno) : ""));
}
#endif
+ /* If selinux is not enforcing, we don't care either */
+ if (rc && security_getenforce() < 1)
+ rc = RPMRC_OK;
return rc;
}
--
2.1.0

View File

@ -1,33 +0,0 @@
From cddf43a56f19711866371f02f378dc4095b0fadd Mon Sep 17 00:00:00 2001
From: Lubos Kardos <lkardos@redhat.com>
Date: Mon, 25 Apr 2016 14:38:47 +0200
Subject: [PATCH 2/2] Fix sigsegv in stringFormat() (rhbz:1316903)
Just skip duping of NULL and return it. Returned NULL is handled in
upper layer.
---
lib/formats.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/lib/formats.c b/lib/formats.c
index e3626ed..bad0b2d 100644
--- a/lib/formats.c
+++ b/lib/formats.c
@@ -44,9 +44,12 @@ static char * stringFormat(rpmtd td)
case RPM_NUMERIC_CLASS:
rasprintf(&val, "%" PRIu64, rpmtdGetNumber(td));
break;
- case RPM_STRING_CLASS:
- val = xstrdup(rpmtdGetString(td));
+ case RPM_STRING_CLASS: {
+ const char *str = rpmtdGetString(td);
+ if (str)
+ val = xstrdup(str);
break;
+ }
case RPM_BINARY_CLASS:
val = pgpHexStr(td->data, td->count);
break;
--
1.9.3

View File

@ -1,388 +0,0 @@
From 61838b0fdacb71a881baac164043b8e40ddfbec5 Mon Sep 17 00:00:00 2001
From: Tom Hughes <tom@compton.nu>
Date: Tue, 17 Nov 2015 17:36:16 +0000
Subject: [PATCH] Remove size limit when expanding macros
This removes a seemingly undocumented, and not even well defined, limit
on the size of a macro expansion when parsing a spec file.
[lkardos@redhat.com: created new funtion expandMacrosU() (Unlimited)
instead of modifying expandMacros() in order not to change API/ABI]
Signed-off-by: Lubos Kardos <lkardos@redhat.com>
---
build/files.c | 6 ++++--
build/pack.c | 6 ++++--
build/parseSpec.c | 10 ++++++----
rpmio/macro.c | 17 +++++++++++++++++
rpmio/rpmmacro.h | 12 ++++++++++++
5 files changed, 43 insertions(+), 8 deletions(-)
diff --git a/build/files.c b/build/files.c
index ea595b9..2fc434e 100644
--- a/build/files.c
+++ b/build/files.c
@@ -1631,11 +1631,13 @@ static rpmRC readFilesManifest(rpmSpec spec, Package pkg, const char *path)
while (fgets(buf, sizeof(buf), fd)) {
if (handleComments(buf))
continue;
- if (expandMacros(spec, spec->macros, buf, sizeof(buf))) {
+ char *expanded = expandMacrosU(spec, spec->macros, buf);
+ if (expanded == NULL) {
rpmlog(RPMLOG_ERR, _("line: %s\n"), buf);
goto exit;
}
- argvAdd(&(pkg->fileList), buf);
+ argvAdd(&(pkg->fileList), expanded);
+ free(expanded);
nlines++;
}
diff --git a/build/pack.c b/build/pack.c
index 213d85e..6ffe450 100644
--- a/build/pack.c
+++ b/build/pack.c
@@ -132,11 +132,13 @@ static rpmRC addFileToTag(rpmSpec spec, const char * file,
}
while (fgets(buf, sizeof(buf), f)) {
- if (expandMacros(spec, spec->macros, buf, sizeof(buf))) {
+ char *expanded = expandMacrosU(spec, spec->macros, buf);
+ if (expanded == NULL) {
rpmlog(RPMLOG_ERR, _("%s: line: %s\n"), fn, buf);
goto exit;
}
- appendStringBuf(sb, buf);
+ appendStringBuf(sb, expanded);
+ free(expanded);
}
headerPutString(h, tag, getStringBuf(sb));
rc = RPMRC_OK;
diff --git a/build/parseSpec.c b/build/parseSpec.c
index edc3d00..610e371 100644
--- a/build/parseSpec.c
+++ b/build/parseSpec.c
@@ -180,13 +180,15 @@ static int expandMacrosInSpecBuf(rpmSpec spec, int strip)
if (lbuf[0] == '#')
isComment = 1;
- lbuf = xstrdup(spec->lbuf);
+ lbuf = spec->lbuf;
- rc = expandMacros(spec, spec->macros, spec->lbuf, spec->lbufSize);
- if (rc) {
+ spec->lbuf = expandMacrosU(spec, spec->macros, lbuf);
+ if (spec->lbuf == NULL) {
rpmlog(RPMLOG_ERR, _("line %d: %s\n"),
- spec->lineNum, spec->lbuf);
+ spec->lineNum, lbuf);
goto exit;
+ } else {
+ spec->lbufSize = strlen(spec->lbuf) + 1;
}
if (strip & STRIP_COMMENTS && isComment) {
diff --git a/rpmio/macro.c b/rpmio/macro.c
index 4b3c41b..4c8934e 100644
--- a/rpmio/macro.c
+++ b/rpmio/macro.c
@@ -1471,6 +1471,23 @@ int expandMacros(void * spec, rpmMacroContext mc, char * sbuf, size_t slen)
return rc;
}
+char *expandMacrosU(void * spec, rpmMacroContext mc, char * sbuf)
+{
+ char *target = NULL;
+ int rc;
+
+ mc = rpmmctxAcquire(mc);
+ rc = doExpandMacros(mc, sbuf, &target);
+ rpmmctxRelease(mc);
+
+ if (rc) {
+ free(target);
+ target = NULL;
+ }
+
+ return target;
+}
+
void
rpmDumpMacroTable(rpmMacroContext mc, FILE * fp)
{
diff --git a/rpmio/rpmmacro.h b/rpmio/rpmmacro.h
index 765c78c..a4884b0 100644
--- a/rpmio/rpmmacro.h
+++ b/rpmio/rpmmacro.h
@@ -66,6 +66,18 @@ int expandMacros (void * spec, rpmMacroContext mc,
size_t slen);
/** \ingroup rpmmacro
+ * Expand macro into buffer.
+ * @deprecated Use rpmExpand().
+ * @todo Eliminate from API.
+ * @param spec cookie (unused)
+ * @param mc macro context (NULL uses global context).
+ * @retval sbuf input macro to expand
+ * @return macro expansion (malloc'ed) or NULL on failure
+ */
+char *expandMacrosU (void * spec, rpmMacroContext mc,
+ char * sbuf);
+
+/** \ingroup rpmmacro
* Add macro to context.
* @deprecated Use rpmDefineMacro().
* @param mc macro context (NULL uses global context).
--
1.9.3
From aee8446eb498fec7bfd7a2848ab97440b7bb7226 Mon Sep 17 00:00:00 2001
From: Tom Hughes <tom@compton.nu>
Date: Mon, 23 Nov 2015 09:38:37 +0000
Subject: [PATCH 1/2] Rename expandMacrosU to rpmExpandMacros
Address review issues from #32 by renaming the function and
cleaning up the comment and parameter list.
---
build/files.c | 2 +-
build/pack.c | 2 +-
build/parseSpec.c | 2 +-
rpmio/macro.c | 2 +-
rpmio/rpmmacro.h | 10 ++++------
5 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/build/files.c b/build/files.c
index 4d49449..0bc4acc 100644
--- a/build/files.c
+++ b/build/files.c
@@ -1624,7 +1624,7 @@ static rpmRC readFilesManifest(rpmSpec spec, Package pkg, const char *path)
while (fgets(buf, sizeof(buf), fd)) {
if (handleComments(buf))
continue;
- char *expanded = expandMacrosU(spec, spec->macros, buf);
+ char *expanded = rpmExpandMacros(spec->macros, buf, 0);
if (expanded == NULL) {
rpmlog(RPMLOG_ERR, _("line: %s\n"), buf);
goto exit;
diff --git a/build/pack.c b/build/pack.c
index 6ffe450..ec06bc8 100644
--- a/build/pack.c
+++ b/build/pack.c
@@ -132,7 +132,7 @@ static rpmRC addFileToTag(rpmSpec spec, const char * file,
}
while (fgets(buf, sizeof(buf), f)) {
- char *expanded = expandMacrosU(spec, spec->macros, buf);
+ char *expanded = rpmExpandMacros(spec->macros, buf, 0);
if (expanded == NULL) {
rpmlog(RPMLOG_ERR, _("%s: line: %s\n"), fn, buf);
goto exit;
diff --git a/build/parseSpec.c b/build/parseSpec.c
index 610e371..6171bb0 100644
--- a/build/parseSpec.c
+++ b/build/parseSpec.c
@@ -182,7 +182,7 @@ static int expandMacrosInSpecBuf(rpmSpec spec, int strip)
lbuf = spec->lbuf;
- spec->lbuf = expandMacrosU(spec, spec->macros, lbuf);
+ spec->lbuf = rpmExpandMacros(spec->macros, lbuf, 0);
if (spec->lbuf == NULL) {
rpmlog(RPMLOG_ERR, _("line %d: %s\n"),
spec->lineNum, lbuf);
diff --git a/rpmio/macro.c b/rpmio/macro.c
index 4c8934e..f9ca027 100644
--- a/rpmio/macro.c
+++ b/rpmio/macro.c
@@ -1471,7 +1471,7 @@ int expandMacros(void * spec, rpmMacroContext mc, char * sbuf, size_t slen)
return rc;
}
-char *expandMacrosU(void * spec, rpmMacroContext mc, char * sbuf)
+char *rpmExpandMacros(rpmMacroContext mc, const char * sbuf, int flags)
{
char *target = NULL;
int rc;
diff --git a/rpmio/rpmmacro.h b/rpmio/rpmmacro.h
index a4884b0..f5ddcac 100644
--- a/rpmio/rpmmacro.h
+++ b/rpmio/rpmmacro.h
@@ -67,15 +67,13 @@ int expandMacros (void * spec, rpmMacroContext mc,
/** \ingroup rpmmacro
* Expand macro into buffer.
- * @deprecated Use rpmExpand().
- * @todo Eliminate from API.
- * @param spec cookie (unused)
* @param mc macro context (NULL uses global context).
- * @retval sbuf input macro to expand
+ * @param sbuf input macro to expand
+ * @param flags flags (currently unused)
* @return macro expansion (malloc'ed) or NULL on failure
*/
-char *expandMacrosU (void * spec, rpmMacroContext mc,
- char * sbuf);
+char *rpmExpandMacros (rpmMacroContext mc, const char * sbuf,
+ int flags);
/** \ingroup rpmmacro
* Add macro to context.
--
1.9.3
From ddf9ec7befe83ba1a12453a56e4e471aa9bcf4d3 Mon Sep 17 00:00:00 2001
From: Lubos Kardos <lkardos@redhat.com>
Date: Thu, 26 Nov 2015 15:20:05 +0100
Subject: [PATCH 2/2] rpmExpandMacros() is modified to be able to return more
return codes
Now rpmExpandMacros() returns integer as a return value. Negative return
value implies failure. Return values can be more utilized in the future.
E. g. return value could specify how many macros were expanded in given
string.
---
build/files.c | 4 ++--
build/pack.c | 4 ++--
build/parseSpec.c | 21 +++++++++------------
rpmio/macro.c | 9 +++++----
rpmio/rpmmacro.h | 7 ++++---
5 files changed, 22 insertions(+), 23 deletions(-)
diff --git a/build/files.c b/build/files.c
index 0bc4acc..d00a785 100644
--- a/build/files.c
+++ b/build/files.c
@@ -1604,6 +1604,7 @@ static rpmRC readFilesManifest(rpmSpec spec, Package pkg, const char *path)
FILE *fd = NULL;
rpmRC rc = RPMRC_FAIL;
unsigned int nlines = 0;
+ char *expanded;
if (*path == '/') {
fn = rpmGetPath(path, NULL);
@@ -1624,8 +1625,7 @@ static rpmRC readFilesManifest(rpmSpec spec, Package pkg, const char *path)
while (fgets(buf, sizeof(buf), fd)) {
if (handleComments(buf))
continue;
- char *expanded = rpmExpandMacros(spec->macros, buf, 0);
- if (expanded == NULL) {
+ if(rpmExpandMacros(spec->macros, buf, &expanded, 0) < 0) {
rpmlog(RPMLOG_ERR, _("line: %s\n"), buf);
goto exit;
}
diff --git a/build/pack.c b/build/pack.c
index ec06bc8..bfb4c73 100644
--- a/build/pack.c
+++ b/build/pack.c
@@ -132,8 +132,8 @@ static rpmRC addFileToTag(rpmSpec spec, const char * file,
}
while (fgets(buf, sizeof(buf), f)) {
- char *expanded = rpmExpandMacros(spec->macros, buf, 0);
- if (expanded == NULL) {
+ char *expanded;
+ if(rpmExpandMacros(spec->macros, buf, &expanded, 0) < 0) {
rpmlog(RPMLOG_ERR, _("%s: line: %s\n"), fn, buf);
goto exit;
}
diff --git a/build/parseSpec.c b/build/parseSpec.c
index 6171bb0..9fff0e2 100644
--- a/build/parseSpec.c
+++ b/build/parseSpec.c
@@ -169,7 +169,7 @@ static int restoreFirstChar(rpmSpec spec)
static int expandMacrosInSpecBuf(rpmSpec spec, int strip)
{
char *lbuf = NULL;
- int rc = 0, isComment = 0;
+ int isComment = 0;
/* Don't expand macros (eg. %define) in false branch of %if clause */
if (!spec->readStack->reading)
@@ -180,17 +180,17 @@ static int expandMacrosInSpecBuf(rpmSpec spec, int strip)
if (lbuf[0] == '#')
isComment = 1;
- lbuf = spec->lbuf;
- spec->lbuf = rpmExpandMacros(spec->macros, lbuf, 0);
- if (spec->lbuf == NULL) {
+ if(rpmExpandMacros(spec->macros, spec->lbuf, &lbuf, 0) < 0) {
rpmlog(RPMLOG_ERR, _("line %d: %s\n"),
- spec->lineNum, lbuf);
- goto exit;
- } else {
- spec->lbufSize = strlen(spec->lbuf) + 1;
+ spec->lineNum, spec->lbuf);
+ return 1;
}
+ free(spec->lbuf);
+ spec->lbuf = lbuf;
+ spec->lbufSize = strlen(spec->lbuf) + 1;
+
if (strip & STRIP_COMMENTS && isComment) {
char *bufA = lbuf;
char *bufB = spec->lbuf;
@@ -212,10 +212,7 @@ static int expandMacrosInSpecBuf(rpmSpec spec, int strip)
spec->lineNum, lbuf);
}
-exit:
- free(lbuf);
-
- return rc;
+ return 0;
}
/* Return zero on success, 1 if we need to read more and -1 on errors. */
diff --git a/rpmio/macro.c b/rpmio/macro.c
index f9ca027..0c009ea 100644
--- a/rpmio/macro.c
+++ b/rpmio/macro.c
@@ -1471,7 +1471,7 @@ int expandMacros(void * spec, rpmMacroContext mc, char * sbuf, size_t slen)
return rc;
}
-char *rpmExpandMacros(rpmMacroContext mc, const char * sbuf, int flags)
+int rpmExpandMacros(rpmMacroContext mc, const char * sbuf, char ** obuf, int flags)
{
char *target = NULL;
int rc;
@@ -1482,10 +1482,11 @@ char *rpmExpandMacros(rpmMacroContext mc, const char * sbuf, int flags)
if (rc) {
free(target);
- target = NULL;
+ return -1;
+ } else {
+ *obuf = target;
+ return 1;
}
-
- return target;
}
void
diff --git a/rpmio/rpmmacro.h b/rpmio/rpmmacro.h
index f5ddcac..8027f98 100644
--- a/rpmio/rpmmacro.h
+++ b/rpmio/rpmmacro.h
@@ -69,11 +69,12 @@ int expandMacros (void * spec, rpmMacroContext mc,
* Expand macro into buffer.
* @param mc macro context (NULL uses global context).
* @param sbuf input macro to expand
+ * @param obuf macro expansion (malloc'ed)
* @param flags flags (currently unused)
- * @return macro expansion (malloc'ed) or NULL on failure
+ * @return negative on failure
*/
-char *rpmExpandMacros (rpmMacroContext mc, const char * sbuf,
- int flags);
+int rpmExpandMacros (rpmMacroContext mc, const char * sbuf,
+ char ** obuf, int flags);
/** \ingroup rpmmacro
* Add macro to context.
--
1.9.3

View File

@ -1,62 +0,0 @@
From 2dd06933726cf5191e05264901789f8e1da6e51d Mon Sep 17 00:00:00 2001
From: Lubos Kardos <lkardos@redhat.com>
Date: Fri, 6 Nov 2015 12:45:32 +0100
Subject: [PATCH] Fix SIGSEGV in case of old unsupported gpg keys
(rhbz:1277464)
Regression from: a173d781a631a92524ce5be364c679ba19b3e321
Adds also warning that gpg key is not supported.
---
rpmio/rpmkeyring.c | 5 ++---
rpmio/rpmpgp.c | 5 +++++
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/rpmio/rpmkeyring.c b/rpmio/rpmkeyring.c
index b6b5703..c3d2c19 100644
--- a/rpmio/rpmkeyring.c
+++ b/rpmio/rpmkeyring.c
@@ -159,9 +159,8 @@ rpmPubkey *rpmGetSubkeys(rpmPubkey mainkey, int *count)
int pgpsubkeysCount = 0;
int i;
- if (!pgpPrtParamsSubkeys(mainkey->pkt, mainkey->pktlen, mainkey->pgpkey,
- &pgpsubkeys, &pgpsubkeysCount)) {
-
+ if (mainkey && !pgpPrtParamsSubkeys(mainkey->pkt, mainkey->pktlen,
+ mainkey->pgpkey, &pgpsubkeys, &pgpsubkeysCount)) {
subkeys = xmalloc(pgpsubkeysCount * sizeof(*subkeys));
diff --git a/rpmio/rpmpgp.c b/rpmio/rpmpgp.c
index f020650..6f8d77b 100644
--- a/rpmio/rpmpgp.c
+++ b/rpmio/rpmpgp.c
@@ -624,6 +624,7 @@ static int pgpPrtSig(pgpTag tag, const uint8_t *h, size_t hlen,
rc = pgpPrtSigParams(tag, v->pubkey_algo, v->sigtype, p, h, hlen, _digp);
} break;
default:
+ rpmlog(RPMLOG_WARNING, _("Unsupported version of key: V%d\n"), h[0]);
rc = 1;
break;
}
@@ -710,6 +711,8 @@ static int pgpPrtKey(pgpTag tag, const uint8_t *h, size_t hlen,
rc = pgpPrtPubkeyParams(v->pubkey_algo, p, h, hlen, _digp);
}
} break;
+ default:
+ rpmlog(RPMLOG_WARNING, _("Unsupported version of key: V%d\n"), h[0]);
}
return rc;
}
@@ -775,6 +778,8 @@ static int getFingerprint(const uint8_t *h, size_t hlen, pgpKeyID_t keyid)
}
} break;
+ default:
+ rpmlog(RPMLOG_WARNING, _("Unsupported version of key: V%d\n"), h[0]);
}
return rc;
}
--
1.9.3

View File

@ -1,49 +0,0 @@
From 9c1e995043a999dcac05a74aa8bcf934122d40ba Mon Sep 17 00:00:00 2001
From: Lubos Kardos <lkardos@redhat.com>
Date: Thu, 14 Apr 2016 13:12:51 +0200
Subject: [PATCH] Make creating index records consistent for rich and rich-weak
deps
If a package contains a rich require dependency then this rich
dependency is parsed and also subdependencies are stored into the
require index. For example for rich dependency "(A and B)" the whole
string "(A and B)" is stored into the index Requirename but
subdependcies "A" and "B" are stored into index too. Previously this
parsing and storing subdependencies was done only for require rich
dependencies. Now it is done also for weak rich dependecies (suggests,
supplements and recommends).
(rhbz:1325982)
---
lib/rpmdb.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/lib/rpmdb.c b/lib/rpmdb.c
index 7992d9c..334c4d9 100644
--- a/lib/rpmdb.c
+++ b/lib/rpmdb.c
@@ -2342,9 +2342,19 @@ static rpmRC tag2index(dbiIndex dbi, rpmTagVal rpmtag,
rc += idxupdate(dbi, dbc, key, keylen, &rec);
- if ((rpmtag == RPMTAG_REQUIRENAME || rpmtag == RPMTAG_CONFLICTNAME) && *(char *)key == '(') {
- if (rpmtdType(&tagdata) == RPM_STRING_ARRAY_TYPE) {
- rc += updateRichDep(dbi, dbc, rpmtdGetString(&tagdata), &rec, idxupdate);
+ if (*(char *)key == '(') {
+ switch (rpmtag) {
+ case RPMTAG_REQUIRENAME:
+ case RPMTAG_CONFLICTNAME:
+ case RPMTAG_SUGGESTNAME:
+ case RPMTAG_SUPPLEMENTNAME:
+ case RPMTAG_RECOMMENDNAME:
+ if (rpmtdType(&tagdata) == RPM_STRING_ARRAY_TYPE) {
+ rc += updateRichDep(dbi, dbc, rpmtdGetString(&tagdata),
+ &rec, idxupdate);
+ }
+ default:
+ break;
}
}
}
--
1.9.3

View File

@ -1,67 +0,0 @@
From 5e94633660d0e2b970bf42f1dc24346ed46cae2e Mon Sep 17 00:00:00 2001
From: Lubos Kardos <lkardos@redhat.com>
Date: Fri, 23 Oct 2015 14:21:58 +0200
Subject: [PATCH] Make terminating build if version format is wrong
configurable
---
build/parseReqs.c | 14 +++++++++-----
macros.in | 3 +++
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/build/parseReqs.c b/build/parseReqs.c
index acdfeb9..a443505 100644
--- a/build/parseReqs.c
+++ b/build/parseReqs.c
@@ -21,6 +21,7 @@ static rpmRC checkSep(const char *s, char c, char **emsg)
const char *sep = strchr(s, c);
if (sep && strchr(sep + 1, c)) {
rasprintf(emsg, "Invalid version (double separator '%c'): %s", c, s);
+ return RPMRC_FAIL;
}
return RPMRC_OK;
}
@@ -35,7 +36,7 @@ static rpmRC checkEpoch(const char *s, char **emsg)
for (si = s; si != sep; si++) {
if (!risdigit(*si)) {
rasprintf(emsg, "Invalid version (epoch must be unsigned integer): %s", s);
- break;
+ return RPMRC_FAIL;
}
}
return RPMRC_OK;
@@ -58,10 +59,13 @@ static rpmRC checkDep(rpmSpec spec, char *N, char *EVR, char **emsg)
}
if (rpmCharCheck(spec, EVR, ".-_+:%{}~"))
return RPMRC_FAIL;
- if (checkSep(EVR, '-', emsg) != RPMRC_OK || checkSep(EVR, ':', emsg) != RPMRC_OK)
- return RPMRC_FAIL;
- if (checkEpoch(EVR, emsg) != RPMRC_OK)
- return RPMRC_FAIL;
+ if (checkSep(EVR, '-', emsg) != RPMRC_OK ||
+ checkSep(EVR, ':', emsg) != RPMRC_OK ||
+ checkEpoch(EVR, emsg) != RPMRC_OK) {
+
+ if (rpmExpandNumeric("%{?_wrong_version_format_terminate_build}"))
+ return RPMRC_FAIL;
+ }
}
return RPMRC_OK;
}
diff --git a/macros.in b/macros.in
index 9ffe4a8..6ea04c9 100644
--- a/macros.in
+++ b/macros.in
@@ -401,6 +401,9 @@ package or when debugging this package.\
# Should invalid utf8 encoding in package metadata terminate a build?
%_invalid_encoding_terminates_build 0
+# Should invalid version format in requires, provides, ... terminate a build?
+%_wrong_version_format_terminate_build 1
+
#
# Should rpm try to download missing sources at build-time?
# Enabling this is dangerous as long as rpm has no means to validate
--
1.9.3

View File

@ -1,95 +0,0 @@
From d9d47e01146a5d4411691a71916b1030ac7da193 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 9 Aug 2016 18:25:24 +0100
Subject: [PATCH 1/3] RISCV 64-bit (riscv64) support.
Based on Mark Salter's aarch64 support patch (commit 8e1ca16c58).
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
---
installplatform | 6 ++++++
rpmrc.in | 16 ++++++++++++++++
2 files changed, 22 insertions(+)
diff --git a/installplatform b/installplatform
index ebade42..12339fc 100755
--- a/installplatform
+++ b/installplatform
@@ -174,6 +174,12 @@ for ARCH in noarch `grep ^arch_canon $RPMRC | cut -d: -f2`; do
CANONARCH=m68k
CANONCOLOR=0
;;
+ riscv64)
+ ISANAME=riscv
+ ISABITS=64
+ CANONARCH=riscv64
+ CANONCOLOR=3
+ ;;
noarch)
CANONARCH=noarch
CANONCOLOR=0
diff --git a/rpmrc.in b/rpmrc.in
index e888b0f..abc08fc 100644
--- a/rpmrc.in
+++ b/rpmrc.in
@@ -99,6 +99,8 @@ optflags: sh4a -O2 -g -mieee
optflags: aarch64 -O2 -g
+optflags: riscv64 -O2 -g
+
#############################################################
# Architecture colors
@@ -147,6 +149,8 @@ archcolor: sh4 1
archcolor: aarch64 2
+archcolor: riscv64 2
+
#############################################################
# Canonical arch names and numbers
@@ -243,6 +247,9 @@ arch_canon: mipsr6el: mipsr6el 20
arch_canon: mips64r6: mips64r6 21
arch_canon: mips64r6el: mips64r6el 21
+arch_canon: riscv: riscv64 22
+arch_canon: riscv64: riscv64 22
+
#############################################################
# Canonical OS names and numbers
@@ -368,6 +375,9 @@ buildarchtranslate: sh4a: sh4
buildarchtranslate: aarch64: aarch64
+buildarchtranslate: riscv: riscv64
+buildarchtranslate: riscv64: riscv64
+
#############################################################
# Architecture compatibility
@@ -473,6 +483,9 @@ arch_compat: sh4a: sh4
arch_compat: aarch64: noarch
+arch_compat: riscv: noarch
+arch_compat: riscv64: noarch
+
os_compat: IRIX64: IRIX
os_compat: solaris2.7: solaris2.3 solaris2.4 solaris2.5 solaris2.6
os_compat: solaris2.6: solaris2.3 solaris2.4 solaris2.5
@@ -506,6 +519,9 @@ buildarch_compat: ia64: noarch
buildarch_compat: aarch64: noarch
+buildarch_compat: riscv: noarch
+buildarch_compat: riscv64: noarch
+
buildarch_compat: athlon: i686
buildarch_compat: geode: i586
buildarch_compat: pentium4: pentium3
--
2.7.4

View File

@ -1,52 +0,0 @@
From cf5679397f36710a942fcb83a63c690eb25d72af Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Thu, 11 Aug 2016 11:38:18 +0100
Subject: [PATCH 2/3] rpmrc: Convert uname.machine == "riscv" to
"riscv32"/"riscv64"/"riscv128".
On RISC-V, the kernel can return uname.machine == "riscv" (for all bit
sizes). I say "can" return, because that is the default, but it is
also possible to compile the kernel specially so it returns "riscv64"
etc.
GNU is using "riscv64".
This commit converts the kernel uname machine type "riscv" to a more
suitable value.
This conversion is supposed to be done by the arch_canon table.
However the arch_canon table is not populated until after the
defaultMachine function is called for the first time, making it a bit
useless. In any case, arch_canon cannot take into account the bit
size of the architecture, but the C code here can.
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
---
lib/rpmrc.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/lib/rpmrc.c b/lib/rpmrc.c
index f2e0f48..eb136d8 100644
--- a/lib/rpmrc.c
+++ b/lib/rpmrc.c
@@ -1216,6 +1216,17 @@ static void defaultMachine(rpmrcCtx ctx, const char ** arch, const char ** os)
}
# endif /* arm*-linux */
+# if defined(__linux__) && defined(__riscv__)
+ if (rstreq(un.machine, "riscv")) {
+ if (sizeof(long) == 4)
+ strcpy(un.machine, "riscv32");
+ else if (sizeof(long) == 8)
+ strcpy(un.machine, "riscv64");
+ else if (sizeof(long) == 16)
+ strcpy(un.machine, "riscv128");
+ }
+# endif /* riscv */
+
# if defined(__GNUC__) && defined(__alpha__)
{
unsigned long amask, implver;
--
2.7.4

View File

@ -18,7 +18,7 @@
%define rpmhome /usr/lib/rpm
%global rpmver 4.13.0
%global snapver rc1
%global snapver rc2
%global srcver %{version}%{?snapver:-%{snapver}}
%global srcdir %{?snapver:testing}%{!?snapver:%{name}-%(v=%{version}; echo ${v%.*}.x)}
@ -29,7 +29,7 @@
Summary: The RPM package management system
Name: rpm
Version: %{rpmver}
Release: %{?snapver:0.%{snapver}.}47%{?dist}
Release: %{?snapver:0.%{snapver}.}1%{?dist}
Group: System Environment/Base
Url: http://www.rpm.org/
Source0: http://rpm.org/releases/%{srcdir}/%{name}-%{srcver}.tar.bz2
@ -52,39 +52,6 @@ Patch4: rpm-4.8.1-use-gpg2.patch
Patch5: rpm-4.12.0-rpm2cpio-hack.patch
# Patches already upstream:
Patch100: rpm-4.13.0-rc1-Fix-new-richdep-syntax.patch
Patch101: rpm-4.13.0-selinux--permissive-scriptlets.patch
Patch102: rpm-4.13.0-non-numeric-epoch.patch
Patch103: rpm-4.13.0-wrong-version-macro.patch
Patch104: rpm-4.13.0-memory-error.patch
Patch105: rpm-4.13.0-rpmdeps-weakdep-support.patch
Patch106: rpm-4.13.0-autopatch-fix.patch
Patch107: rpm-4.13.0-ignore-sigpipe.patch
Patch108: rpm-4.13.0-unsupported-keys.patch
Patch109: rpm-4.13.0-fix-crash-on-corrupted.patch
Patch110: rpm-4.13.0-disabling-filetriggers.patch
Patch111: rpm-4.13.0-chroot-file-triggers.patch
Patch112: rpm-4.13.0-missingok.patch
Patch113: rpm-4.13.0-recursing-rpmdeps.patch
Patch114: rpm-4.13.0-autosetup-errors.patch
Patch115: rpm-4.13.0-unlimited-macro-expand.patch
Patch116: rpm-4.13.0-idle-and-sleep-in-systemd-inhibit.patch
Patch117: rpm-4.13.0-add-mipsr6-support.patch
Patch118: rpm-4.13.0-Use-pkg-dpaths-during-dependency-generation.patch
Patch119: rpm-4.13.0-Noarch-ExclusiveArch.patch
Patch120: rpm-4.13.0-redirect2null.patch
Patch121: rpm-4.13.0-lang-doc-directives.patch
Patch122: rpm-4.13.0-elem-progress-callback.patch
Patch123: rpm-4.13.0-weak-rich-consistency.patch
Patch124: rpm-4.13.0-fuzz-settings.patch
Patch125: rpm-4.13.0-patch-flags.patch
Patch126: rpm-4.13.0-no-backup-if-mismatch.patch
Patch127: rpm-4.13.0-rpmtd-out-of-bounds.patch
Patch128: rpm-4.13.0-stringFormat-sigsegv.patch
Patch129: rpm-4.13.0-filter-unversioned.patch
Patch130: rpm-4.13.0-armv7hl-isa.patch
Patch131: rpm-4.13.0-non-ASCII-keys.patch
Patch132: rpm-4.13.0-_buildhost-macro.diff
Patch133: rpm-4.13.x-pythondistdeps.patch
Patch134: rpm-4.13.x-pythondistdeps-Makefile.patch
Patch135: rpm-4.13.x-pythondistdeps-fileattr.patch
@ -92,23 +59,11 @@ Patch136: rpm-4.13.x-pythondistdeps.py-skip-distribution-metadata-if-ther.patch
Patch137: rpm-4.13.x-pythondistdeps.py-show-warning-if-version-is-not-fou.patch
Patch138: rpm-4.13.x-pythondistdeps.py-skip-.egg-link-files.patch
Patch139: rpm-4.13.x-pythondistdeps.py-add-forgotten-import.patch
Patch140: rpm-4.13.x-RISCV-64-bit-riscv64-support.patch
Patch141: rpm-4.13.x-rpmrc-Convert-uname.machine-riscv-to-riscv32-riscv64.patch
# These are not yet upstream
Patch302: rpm-4.7.1-geode-i686.patch
# Probably to be upstreamed in slightly different form
Patch304: rpm-4.9.1.1-ld-flags.patch
# Compressed debuginfo support (#833311)
Patch305: rpm-4.10.0-dwz-debuginfo.patch
# Minidebuginfo support (#834073)
Patch306: rpm-4.10.0-minidebuginfo.patch
# Fix CRC32 after dwz (#971119)
Patch307: rpm-4.11.1-sepdebugcrcfix.patch
# Fix race condidition where unchecked data is exposed in the file system
Patch308: rpm-4.12.0.x-CVE-2013-6435.patch
# Add check against malicious CPIO file name size
Patch309: rpm-4.12.0.x-CVE-2014-8118.patch
# Partially GPL/LGPL dual-licensed and some bits with BSD
# SourceLicense: (GPLv2+ and LGPLv2+ with exceptions) and BSD
@ -601,6 +556,9 @@ exit 0
%doc doc/librpm/html/*
%changelog
* Thu Oct 20 2016 Panu Matilainen <pmatilai@redhat.com> - 4.13.0-0.rc2.1
- Rebase to rpm 4.13.0-rc2
* Fri Sep 23 2016 Richard W.M. Jones <rjones@redhat.com> - 4.13.0-0.rc1.47
- Backport two upstream patches which add riscv64 architecture support.

View File

@ -1 +1 @@
f9be5490f187bc4d9710c9fdae529e7b rpm-4.13.0-rc1.tar.bz2
e5f31e745bfe3cbfccc5e869b0c84feb rpm-4.13.0-rc2.tar.bz2