diff --git a/.gitignore b/.gitignore
index e4fca6f..878f733 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1 @@
-SOURCES/rpm-4.11.1.tar.bz2
+SOURCES/rpm-4.11.3.tar.bz2
diff --git a/.rpm.metadata b/.rpm.metadata
index b9fbaf0..0894cbd 100644
--- a/.rpm.metadata
+++ b/.rpm.metadata
@@ -1 +1 @@
-31ddc4185137ce3f718c99e91dcb040614fe820c SOURCES/rpm-4.11.1.tar.bz2
+ae9ff06718e877d897ed47e3795b0e56727d752c SOURCES/rpm-4.11.3.tar.bz2
diff --git a/SOURCES/rpm b/SOURCES/rpm
new file mode 100644
index 0000000..a66534a
--- /dev/null
+++ b/SOURCES/rpm
@@ -0,0 +1,303 @@
+# bash completion for rpm                                  -*- shell-script -*-
+
+# helper functions
+
+_rpm_installed_packages()
+{
+    if [[ -r /var/log/rpmpkgs && \
+        /var/log/rpmpkgs -nt /var/lib/rpm/Packages ]]; then
+        # using RHL 7.2 or later - this is quicker than querying the DB
+        COMPREPLY=( $( compgen -W "$( sed -ne \
+            's|^\([^[:space:]]\{1,\}\)-[^[:space:]-]\{1,\}-[^[:space:]-]\{1,\}\.rpm$|\1|p' \
+            /var/log/rpmpkgs )" -- "$cur" ) )
+    elif type rpmqpack &>/dev/null ; then
+        # SUSE's rpmqpack is faster than rpm -qa
+        COMPREPLY=( $( compgen -W '$( rpmqpack )' -- "$cur" ) )
+    else
+        COMPREPLY=( $( ${1:-rpm} -qa --nodigest --nosignature \
+            --queryformat='%{NAME} ' "$cur*" 2>/dev/null ) )
+    fi
+}
+
+_rpm_groups()
+{
+    local IFS=$'\n'
+    COMPREPLY=( $( compgen -W "$( ${1:-rpm} -qa --nodigest --nosignature \
+        --queryformat='%{GROUP}\n' 2>/dev/null )" -- "$cur" ) )
+}
+
+_rpm_macros()
+{
+    # get a list of macros
+    COMPREPLY=( $( compgen -W "$( ${1:-rpm} --showrc | sed -ne \
+        's/^-\{0,1\}[0-9]\{1,\}[:=][[:space:]]\{1,\}\([^[:space:](]\{3,\}\).*/%\1/p' )" \
+        -- "$cur" ) )
+}
+
+_rpm_buildarchs()
+{
+    COMPREPLY=( $( compgen -W "$( ${1:-rpm} --showrc | sed -ne \
+        's/^\s*compatible\s\s*build\s\s*archs\s*:\s*\(.*\)/\1/ p' )" \
+        -- "$cur" ) )
+}
+
+# rpm(8) completion
+#
+_rpm()
+{
+    local cur prev words cword split
+    _init_completion -s || return
+
+    if [[ $cword -eq 1 ]]; then
+        # first parameter on line
+        case $cur in
+            --*)
+                COMPREPLY=( $( compgen -W '--help --version --initdb
+                    --checksig --addsign --delsign --rebuilddb --showrc
+                    --setperms --setugids --eval --install --upgrade --query
+                    --freshen --erase --verify --querytags --import' \
+                        -- "$cur" ) )
+                ;;
+            *)
+                COMPREPLY=( $( compgen -W '-e -E -F -i -q -t -U -V' \
+                    -- "$cur" ) )
+                ;;
+        esac
+        return 0
+    fi
+
+    case $prev in
+        --dbpath|--excludepath|--prefix|--relocate|--root|-r)
+            _filedir -d
+            return 0
+            ;;
+        --eval|-E)
+            _rpm_macros $1
+            return 0
+            ;;
+        --pipe)
+            compopt -o filenames
+            COMPREPLY=( $( compgen -c -- "$cur" ) )
+            return 0
+            ;;
+        --rcfile)
+            _filedir
+            return 0
+            ;;
+        --specfile)
+            # complete on .spec files
+            _filedir spec
+            return 0
+            ;;
+        --whatprovides)
+            if [[ "$cur" == */* ]]; then
+                _filedir
+            else
+                # complete on capabilities
+                local IFS=$'\n'
+                COMPREPLY=( $( compgen -W "$( $1 -qa --nodigest --nosignature \
+                    --queryformat='%{PROVIDENAME}\n' 2>/dev/null )" \
+                    -- "$cur" ) )
+            fi
+            return 0
+            ;;
+        --whatrequires)
+            if [[ "$cur" == */* ]]; then
+                _filedir
+            else
+                # complete on capabilities
+                local IFS=$'\n'
+                COMPREPLY=( $( compgen -W "$( $1 -qa --nodigest --nosignature \
+                    --queryformat='%{REQUIRENAME}\n' 2>/dev/null )" \
+                    -- "$cur" ) )
+            fi
+            return 0
+            ;;
+        --define|-D|--fileid|--hdrid|--pkgid)
+            # argument required but no completions available
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    # options common to all modes
+    local opts="--define= --eval= --macros= --nodigest --nosignature --rcfile=
+        --quiet --pipe --verbose"
+
+    case ${words[1]} in
+        -[iFU]*|--install|--freshen|--upgrade)
+            if [[ "$cur" == -* ]]; then
+                COMPREPLY=( $( compgen -W "$opts --percent --force --test
+                --replacepkgs --replacefiles --root --excludedocs --includedocs
+                --noscripts --ignorearch --dbpath --prefix= --ignoreos --nodeps
+                --allfiles --ftpproxy --ftpport --justdb --httpproxy --httpport
+                --noorder --relocate= --badreloc --notriggers --excludepath=
+                --ignoresize --oldpackage --queryformat --repackage
+                --nosuggests" -- "$cur" ) )
+            else
+                _filedir '[rs]pm'
+            fi
+            ;;
+        -e|--erase)
+            if [[ "$cur" == -* ]]; then
+                COMPREPLY=( $( compgen -W "$opts --allmatches --noscripts
+                    --notriggers --nodeps --test --repackage" -- "$cur" ) )
+            else
+                _rpm_installed_packages $1
+            fi
+            ;;
+        -q*|--query)
+            # options common to all query types
+            opts+=" --changelog --configfiles --conflicts --docfiles --dump
+                --enhances --filesbypkg --filecaps --fileclass --filecolor
+                --fileprovide --filerequire --filesbypkg --info --list
+                --obsoletes --pipe --provides --queryformat= --requires
+                --scripts --suggests --triggers --xml"
+
+            if [[ ${words[@]} == *\ -@(*([^ -])f|-file )* ]]; then
+                # -qf completion
+                if [[ "$cur" == -* ]]; then
+                    COMPREPLY=( $( compgen -W "$opts --dbpath --fscontext
+                        --last --root --state" -- "$cur" ) )
+                else
+                    _filedir
+                fi
+            elif [[ ${words[@]} == *\ -@(*([^ -])g|-group )* ]]; then
+                # -qg completion
+                _rpm_groups $1
+            elif [[ ${words[@]} == *\ -@(*([^ -])p|-package )* ]]; then
+                # -qp; uninstalled package completion
+                if [[ "$cur" == -* ]]; then
+                    COMPREPLY=( $( compgen -W "$opts --ftpport --ftpproxy
+                        --httpport --httpproxy --nomanifest" -- "$cur" ) )
+                else
+                    _filedir '[rs]pm'
+                fi
+            else
+                # -q; installed package completion
+                if [[ "$cur" == -* ]]; then
+                    COMPREPLY=( $( compgen -W "$opts --all --file --fileid
+                        --dbpath --fscontext --ftswalk --group --hdrid --last
+                        --package --pkgid --root= --specfile --state
+                        --triggeredby --whatprovides --whatrequires" \
+                            -- "$cur" ) )
+                elif [[ ${words[@]} != *\ -@(*([^ -])a|-all )* ]]; then
+                    _rpm_installed_packages $1
+                fi
+            fi
+            ;;
+        -K*|--checksig)
+            if [[ "$cur" == -* ]]; then
+                COMPREPLY=( $( compgen -W "$opts --nopgp --nogpg --nomd5" \
+                    -- "$cur" ) )
+            else
+                _filedir '[rs]pm'
+            fi
+            ;;
+        -[Vy]*|--verify)
+            if [[ "$cur" == -* ]]; then
+                COMPREPLY=( $( compgen -W "$opts --root= --dbpath --nodeps
+                    --nogroup --nolinkto --nomode --nomtime --nordev --nouser
+                    --nofiles --noscripts --nomd5 --querytags --specfile
+                    --whatrequires --whatprovides" -- "$cur" ) )
+            # check whether we're doing file completion
+            elif [[ ${words[@]} == *\ -@(*([^ -])f|-file )* ]]; then
+                _filedir
+            elif [[ ${words[@]} == *\ -@(*([^ -])g|-group )* ]]; then
+                _rpm_groups $1
+            elif [[ ${words[@]} == *\ -@(*([^ -])p|-package )* ]]; then
+                _filedir '[rs]pm'
+            else
+                _rpm_installed_packages $1
+            fi
+            ;;
+        --resign|--addsign|--delsign)
+            _filedir '[rs]pm'
+            ;;
+        --setperms|--setgids)
+            _rpm_installed_packages $1
+            ;;
+        --import|--dbpath|--root)
+            if [[ "$cur" == -* ]]; then
+                COMPREPLY=( $( compgen -W '--import --dbpath --root=' \
+                    -- "$cur" ) )
+            else
+                _filedir
+            fi
+            ;;
+    esac
+    [[ $COMPREPLY == *= ]] && compopt -o nospace
+
+    return 0
+} &&
+complete -F _rpm rpm
+
+_rpmbuild()
+{
+    local cur prev words cword split
+    _init_completion -s || return
+
+    local rpm="${1%build*}"
+    [[ $rpm == $1 ]] || ! type $rpm &>/dev/null && rpm=
+
+    case $prev in
+        --buildroot|--root|-r|--dbpath)
+            _filedir -d
+            return 0
+            ;;
+        --target)
+            _rpm_buildarchs
+            return 0
+            ;;
+        --eval|-E)
+            _rpm_macros $rpm
+            return 0
+            ;;
+        --macros|--rcfile)
+            _filedir
+            return 0
+            ;;
+        --buildpolicy)
+            local cfgdir=$( $rpm --eval '%{_rpmconfigdir}' 2>/dev/null )
+            if [[ $cfgdir ]]; then
+                COMPREPLY=( $( compgen -W "$( command ls $cfgdir 2>/dev/null \
+                    | sed -ne 's/^brp-//p' )" -- "$cur" ) )
+            fi
+            ;;
+        --define|-D|--with|--without)
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ $cur == -* ]]; then
+        COMPREPLY=( $( compgen -W "$( _parse_help "$1" )" -- "$cur" ) )
+        [[ $COMPREPLY == *= ]] && compopt -o nospace
+        return 0
+    fi
+
+    # Figure out file extensions to complete
+    local word ext
+    for word in ${words[@]}; do
+        case $word in
+            -b?)
+                ext=spec
+                break
+                ;;
+            -t?|--tarbuild)
+                ext='@(t?(ar.)@([gx]z|bz?(2))|tar?(.@(lzma|Z)))'
+                break
+                ;;
+            --rebuild|--recompile)
+                ext='@(?(no)src.r|s)pm'
+                break
+                ;;
+        esac
+    done
+    [[ -n $ext ]] && _filedir $ext
+} &&
+complete -F _rpmbuild rpmbuild rpmbuild-md5
+
+# ex: ts=4 sw=4 et filetype=sh
diff --git a/SOURCES/rpm-4.11.1-caps-doublefree.patch b/SOURCES/rpm-4.11.1-caps-doublefree.patch
deleted file mode 100644
index e5d9051..0000000
--- a/SOURCES/rpm-4.11.1-caps-doublefree.patch
+++ /dev/null
@@ -1,19 +0,0 @@
-commit 65eec62cb7796dad6fbf1d5436251e176449f522
-Author: Panu Matilainen <pmatilai@redhat.com>
-Date:   Thu Aug 29 16:32:32 2013 +0300
-
-    Fix double-free on %caps() wildcard %files entry (RhBug:956190)
-
-diff --git a/build/files.c b/build/files.c
-index 20f452f..eed5696 100644
---- a/build/files.c
-+++ b/build/files.c
-@@ -1448,7 +1448,7 @@ static rpmRC addFile(FileList fl, const char * diskPath,
- 	}
- 
- 	if (fl->cur.caps) {
--	    flp->caps = fl->cur.caps;
-+	    flp->caps = xstrdup(fl->cur.caps);
- 	} else {
- 	    flp->caps = xstrdup("");
- 	}
diff --git a/SOURCES/rpm-4.11.1-digests-max.patch b/SOURCES/rpm-4.11.1-digests-max.patch
deleted file mode 100644
index 53cbf91..0000000
--- a/SOURCES/rpm-4.11.1-digests-max.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-commit 85b62554d2632d06f975f90697c4c11c3f180931
-Author: Panu Matilainen <pmatilai@redhat.com>
-Date:   Tue Feb 18 18:13:54 2014 +0200
-
-    Make room for SHA224 in digest bundles. Doh.
-    
-    - Should've really been in commit 20cfa7d2b4c927798ad38126821d194fafd93ffe
-      but at the time NSS didn't even support SHA-224 so it was untestable.
-      Now that it does, and somebody actually bothered to test...
-      Fixes RhBug:1066494.
-
-diff --git a/rpmio/digest.c b/rpmio/digest.c
-index c1f73b3..4956a30 100644
---- a/rpmio/digest.c
-+++ b/rpmio/digest.c
-@@ -8,7 +8,7 @@
- 
- #include "debug.h"
- 
--#define DIGESTS_MAX 11
-+#define DIGESTS_MAX 12
- struct rpmDigestBundle_s {
-     int index_min;			/*!< Smallest index of active digest */
-     int index_max;			/*!< Largest index of active digest */
diff --git a/SOURCES/rpm-4.11.1-empty-lua-script.patch b/SOURCES/rpm-4.11.1-empty-lua-script.patch
deleted file mode 100644
index 2c4a590..0000000
--- a/SOURCES/rpm-4.11.1-empty-lua-script.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-commit 5f3598a700e8e028f9140682262869ca319597ee
-Author: Panu Matilainen <pmatilai@redhat.com>
-Date:   Fri Sep 6 16:31:25 2013 +0300
-
-    Fix segfault executing a -p <lua> scriptlet without a body (RhBug:1004062)
-    
-    - There are any number of places where this could be fixed, but
-      to keep the behavior similar to eg /bin/sh scriptlet without a body,
-      just turn a non-existent script into an empty string.
-
-diff --git a/rpmio/rpmlua.c b/rpmio/rpmlua.c
-index 0576318..921cc37 100644
---- a/rpmio/rpmlua.c
-+++ b/rpmio/rpmlua.c
-@@ -526,6 +526,8 @@ int rpmluaRunScript(rpmlua _lua, const char *script, const char *name)
-     int ret = 0;
-     if (name == NULL)
- 	name = "<lua>";
-+    if (script == NULL)
-+	script = "";
-     if (luaL_loadbuffer(L, script, strlen(script), name) != 0) {
- 	rpmlog(RPMLOG_ERR, _("invalid syntax in lua script: %s\n"),
- 		 lua_tostring(L, -1));
diff --git a/SOURCES/rpm-4.11.1-headersort.patch b/SOURCES/rpm-4.11.1-headersort.patch
deleted file mode 100644
index 3b2f27e..0000000
--- a/SOURCES/rpm-4.11.1-headersort.patch
+++ /dev/null
@@ -1,125 +0,0 @@
-commit da3a3a14e757ccd517e2eb2a3f0293ff48b3ff7f
-Author: Panu Matilainen <pmatilai@redhat.com>
-Date:   Wed Feb 5 13:36:31 2014 +0200
-
-    A boolean flag is not sufficient to cover three different states...
-    
-    - HEADERFLAG_SORTED flag bit has been used to track the header
-      sort state since beginning of times, but the header sort actually
-      has three different states: truly unsorted (such as after additions),
-      sorted by index achieved with headerSort(), or sorted by offset which
-      is creatively called headerUnsort() in the API.
-    
-      There's exactly one place that requires offset sorting, namely
-      headerExport(). It does call headerUnsort() explicitly, but
-      headerUnsort() would not do anything unless the header was in
-      index-sorted state. This is quite often the case, but data addition
-      would unset the sorted-flag, and causing headerUnsort() not to
-      do anything at all when it most certainly should have. That incorrect
-      sorting caused headerExport() calculations to be wildly off.
-    
-      This ancient bug was unearthed by the innocent looking
-      commit eae671556470136c37951f53ca966cd1bd09aac4: prior to that,
-      in half the cases headerSizeof() used to be called first, causing
-      index-sorting to take place, after which the headerUnsort() in
-      headerExport() did the right thing. In the other two cases
-      headerSizeof() was called afterwards, and the headerExport() would
-      be garbage in cases where new data had been just added, such as package
-      installation. With headerExport() eliminating the need to call
-      headerSizeof() all the cases became broken as the header would
-      seem much bigger than it is due to the bad sort order and cause
-      cases like RhBug:953719 where a largish header suddenly appears
-      to be oversized, causing mysterious install failure. Prior to the
-      commit (which in itself IS innocent) the issue would've mainly
-      manifested in cases where the header needs to be rewritten, which
-      only happens when files are replaced and the header is rewritten for that.
-
-diff --git a/lib/header.c b/lib/header.c
-index ceffb32..f78ba78 100644
---- a/lib/header.c
-+++ b/lib/header.c
-@@ -68,8 +68,13 @@ static const int typeSizes[16] =  {
-     0
- };
- 
-+enum headerSorted_e {
-+    HEADERSORT_NONE	= 0,	/* Not sorted */
-+    HEADERSORT_OFFSET	= 1,	/* Sorted by offset (on-disk format) */
-+    HEADERSORT_INDEX	= 2,	/* Sorted by index  */
-+};
-+
- enum headerFlags_e {
--    HEADERFLAG_SORTED    = (1 << 0), /*!< Are header entries sorted? */
-     HEADERFLAG_ALLOCATED = (1 << 1), /*!< Is 1st header region allocated? */
-     HEADERFLAG_LEGACY    = (1 << 2), /*!< Header came from legacy source? */
-     HEADERFLAG_DEBUG     = (1 << 3), /*!< Debug this header? */
-@@ -87,6 +92,7 @@ struct headerToken_s {
-     int indexAlloced;		/*!< Allocated size of tag array. */
-     unsigned int instance;	/*!< Rpmdb instance (offset) */
-     headerFlags flags;
-+    int sorted;			/*!< Current sort method */
-     int nrefs;			/*!< Reference count. */
- };
- 
-@@ -169,7 +175,7 @@ static Header headerCreate(void *blob, unsigned int pvlen, int32_t indexLen)
- 	h->indexUsed = 0;
-     }
-     h->instance = 0;
--    h->flags |= HEADERFLAG_SORTED;
-+    h->sorted = HEADERSORT_NONE;
- 
-     h->index = (h->indexAlloced
- 	? xcalloc(h->indexAlloced, sizeof(*h->index))
-@@ -219,9 +225,9 @@ static int indexCmp(const void * avp, const void * bvp)
- 
- void headerSort(Header h)
- {
--    if (!(h->flags & HEADERFLAG_SORTED)) {
-+    if (h->sorted != HEADERSORT_INDEX) {
- 	qsort(h->index, h->indexUsed, sizeof(*h->index), indexCmp);
--	h->flags |= HEADERFLAG_SORTED;
-+	h->sorted = HEADERSORT_INDEX;
-     }
- }
- 
-@@ -242,9 +248,9 @@ static int offsetCmp(const void * avp, const void * bvp)
- 
- void headerUnsort(Header h)
- {
--    if (h->flags & HEADERFLAG_SORTED) {
-+    if (h->sorted != HEADERSORT_OFFSET) {
- 	qsort(h->index, h->indexUsed, sizeof(*h->index), offsetCmp);
--	h->flags &= ~HEADERFLAG_SORTED;
-+	h->sorted = HEADERSORT_OFFSET;
-     }
- }
- 
-@@ -721,7 +727,8 @@ indexEntry findEntry(Header h, rpmTagVal tag, rpm_tagtype_t type)
-     struct indexEntry_s key;
- 
-     if (h == NULL) return NULL;
--    if (!(h->flags & HEADERFLAG_SORTED)) headerSort(h);
-+    if (h->sorted != HEADERSORT_INDEX)
-+	headerSort(h);
- 
-     key.info.tag = tag;
- 
-@@ -907,7 +914,8 @@ Header headerImport(void * blob, unsigned int bsize, headerImportFlags flags)
- 	    goto errxit;
-     }
- 
--    h->flags &= ~HEADERFLAG_SORTED;
-+    /* Force sorting, dribble lookups can cause early sort on partial header */
-+    h->sorted = HEADERSORT_NONE;
-     headerSort(h);
-     h->flags |= HEADERFLAG_ALLOCATED;
- 
-@@ -1439,7 +1447,7 @@ static int intAddEntry(Header h, rpmtd td)
-     entry->length = length;
- 
-     if (h->indexUsed > 0 && td->tag < h->index[h->indexUsed-1].info.tag)
--	h->flags &= ~HEADERFLAG_SORTED;
-+	h->sorted = HEADERSORT_NONE;
-     h->indexUsed++;
- 
-     return 1;
diff --git a/SOURCES/rpm-4.11.1-instprefix.patch b/SOURCES/rpm-4.11.1-instprefix.patch
deleted file mode 100644
index 54c6ae7..0000000
--- a/SOURCES/rpm-4.11.1-instprefix.patch
+++ /dev/null
@@ -1,55 +0,0 @@
-commit 1ac9e84d9a4a04df7c8f659a8df676fc4f8544f0
-Author: Panu Matilainen <pmatilai@redhat.com>
-Date:   Fri Jul 5 10:27:18 2013 +0300
-
-    Ensure relocatable packages always get install-prefix(es) set (RhBug:979443)
-    
-    - Scriptlets from relocatable packages should always run with
-      $RPM_INSTALL_PREFIX* defined, whether actually being relocated or not.
-    - Fixes regression introduced by the optimization in commit
-      5d3018c4ed476b1b7ac18e2573af517f872cb303. We always need to call
-      addPrefixes() but return early from rpmRelocateFileList() when
-      no relocations are taking place, fixing the performance regression
-      introduced all the way back in cb8241dda783f7e8c143b08fecf57fe89a39c3a6
-      which is what 5d3018c4ed476b1b7ac18e2573af517f872cb303 was trying
-      to fix. Pooh :)
-    
-    (cherry picked from commit 88d24b14a8e0e33e768cb74a3487acf0925b012a)
-
-diff --git a/lib/rpmfi.c b/lib/rpmfi.c
-index 0bfb5dd..185deae 100644
---- a/lib/rpmfi.c
-+++ b/lib/rpmfi.c
-@@ -793,7 +793,8 @@ static int addPrefixes(Header h, rpmRelocation *relocations, int numRelocations)
- 	headerPutStringArray(h, RPMTAG_INSTPREFIXES, actualRelocations, numActual);
-     }
-     free(actualRelocations);
--    return numActual;
-+    /* When any relocations are present there'll be more work to do */
-+    return 1;
- }
- 
- static void saveRelocs(Header h, rpmtd bnames, rpmtd dnames, rpmtd dindexes)
-@@ -835,7 +836,8 @@ void rpmRelocateFileList(rpmRelocation *relocations, int numRelocations,
-     int i, j;
-     struct rpmtd_s bnames, dnames, dindexes, fmodes;
- 
--    addPrefixes(h, relocations, numRelocations);
-+    if (!addPrefixes(h, relocations, numRelocations))
-+	return;
- 
-     if (!_printed) {
- 	_printed = 1;
-diff --git a/lib/rpmte.c b/lib/rpmte.c
-index 6afd69e..87fb391 100644
---- a/lib/rpmte.c
-+++ b/lib/rpmte.c
-@@ -98,7 +98,7 @@ static rpmfi getFI(rpmte p, Header h)
- 				      (RPMFI_NOHEADER | RPMFI_FLAGS_ERASE);
- 
-     /* relocate stuff in header if necessary */
--    if (rpmteType(p) == TR_ADDED && rpmfsFC(p->fs) > 0 && p->nrelocs) {
-+    if (rpmteType(p) == TR_ADDED && rpmfsFC(p->fs) > 0) {
- 	if (!headerIsSource(h) && !headerIsEntry(h, RPMTAG_ORIGBASENAMES)) {
- 	    rpmRelocateFileList(p->relocs, p->nrelocs, p->fs, h);
- 	}
diff --git a/SOURCES/rpm-4.11.1-ppc64le.patch b/SOURCES/rpm-4.11.1-ppc64le.patch
deleted file mode 100644
index d067ffe..0000000
--- a/SOURCES/rpm-4.11.1-ppc64le.patch
+++ /dev/null
@@ -1,109 +0,0 @@
-diff --git a/installplatform b/installplatform
-index 9a11bc3..6908f02 100755
---- a/installplatform
-+++ b/installplatform
-@@ -54,12 +54,18 @@ for ARCH in noarch `grep ^arch_canon $RPMRC | cut -d: -f2`; do
- 	CANONARCH=s390x
- 	CANONCOLOR=3
- 	;;
--    ppc64*)
-+    ppc64|ppc64p7)
- 	ISANAME=ppc
- 	ISABITS=64
- 	CANONARCH=ppc64
- 	CANONCOLOR=3
- 	;;
-+    ppc64le)
-+	ISANAME=ppc
-+        ISABITS=64
-+        CANONARCH=ppc64le
-+        CANONCOLOR=3
-+	;;
-     ppc*)
- 	ISANAME=ppc
- 	ISABITS=32
-diff --git a/lib/rpmrc.c b/lib/rpmrc.c
-index 794d028..f209851 100644
---- a/lib/rpmrc.c
-+++ b/lib/rpmrc.c
-@@ -1125,6 +1125,7 @@ static void defaultMachine(rpmrcCtx ctx, const char ** arch, const char ** os)
- #	endif	/* sparc*-linux */
- 
- #	if defined(__linux__) && defined(__powerpc__)
-+#	if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
- 	{
-             int powerlvl;
-             if (!rstreq(un.machine, "ppc") &&
-@@ -1133,6 +1134,7 @@ static void defaultMachine(rpmrcCtx ctx, const char ** arch, const char ** os)
-                 strcpy(un.machine, "ppc64p7");
- 	    }
-         }
-+#	endif	/* __ORDER_BIG_ENDIAN__ */
- #	endif	/* ppc64*-linux */
- 
- #	if defined(__GNUC__) && defined(__alpha__)
-diff --git a/rpmrc.in b/rpmrc.in
-index 55ff25f..affb736 100644
---- a/rpmrc.in
-+++ b/rpmrc.in
-@@ -48,6 +48,7 @@ optflags: ppc32dy4 -O2 -g -fsigned-char
- optflags: ppciseries -O2 -g -fsigned-char
- optflags: ppcpseries -O2 -g -fsigned-char
- optflags: ppc64 -O2 -g -fsigned-char
-+optflags: ppc64le -O2 -g -fsigned-char
- optflags: ppc64p7 -O3 -mtune=power7 -mcpu=power7 -g -fsigned-char
- 
- optflags: parisc -O2 -g -mpa-risc-1-0
-@@ -96,6 +97,7 @@ archcolor: sparc64 2
- archcolor: sparcv9 2
- archcolor: ppc 1
- archcolor: ppc64 2
-+archcolor: ppc64le 2
- 
- archcolor: armv3l 1
- archcolor: armv4b 1
-@@ -194,6 +196,7 @@ arch_canon:	i370: i370	14
- arch_canon:	s390x: s390x	15
- 
- arch_canon:	ppc64:	ppc64	16
-+arch_canon:	ppc64le:	ppc64le	16
- arch_canon:    ppc64pseries: ppc64pseries  16
- arch_canon:    ppc64iseries: ppc64iseries  16
- arch_canon:    ppc64p7: ppc64p7  16
-@@ -281,6 +284,7 @@ buildarchtranslate: ppcpseries: ppc
- buildarchtranslate: ppc64iseries: ppc64
- buildarchtranslate: ppc64pseries: ppc64
- buildarchtranslate: ppc64p7: ppc64
-+buildarchtranslate: ppc64le: ppc64le
- 
- buildarchtranslate: armv3l: armv3l
- buildarchtranslate: armv4b: armv4b
-@@ -352,6 +356,7 @@ arch_compat: rs6000: noarch fat
- arch_compat: ppc64pseries: ppc64
- arch_compat: ppc64iseries: ppc64
- arch_compat: ppc64p7: ppc64
-+arch_compat: ppc64le: noarch fat
- 
- arch_compat: sun4c: sparc
- arch_compat: sun4d: sparc
-@@ -475,6 +480,7 @@ buildarch_compat: ppciseries: noarch
- buildarch_compat: ppcpseries: noarch
- buildarch_compat: ppc: noarch fat
- buildarch_compat: ppc64: noarch fat
-+buildarch_compat: ppc64le: noarch fat
- buildarch_compat: ppc64pseries: ppc64
- buildarch_compat: ppc64iseries: ppc64
- buildarch_compat: ppc64p7: ppc64
-diff --git a/macros.in b/macros.in
-index 2e693e1..5a075a3 100644
---- a/macros.in
-+++ b/macros.in
-@@ -1002,7 +1002,7 @@ done \
- 
- #------------------------------------------------------------------------------
- # arch macro for all supported PowerPC 64 processors
--%power64	ppc64 ppc64p7
-+%power64	ppc64 ppc64p7 ppc64le
- 
- #------------------------------------------------------------------------
- # Use in %install to generate locale specific file lists. For example,
diff --git a/SOURCES/rpm-4.11.1-python-bytecompile-path.patch b/SOURCES/rpm-4.11.1-python-bytecompile-path.patch
deleted file mode 100644
index 7c7b9c9..0000000
--- a/SOURCES/rpm-4.11.1-python-bytecompile-path.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-commit 198363e1b703107eba929d70dce2e1d762388bef
-Author: Panu Matilainen <pmatilai@redhat.com>
-Date:   Fri Sep 6 10:41:45 2013 +0300
-
-    Byte-compile versioned python libdirs in non-root prefix too (RhBug:868332)
-    
-    - Previously brp-python-bytecompile assumed versioned python stdlib
-      always starts at / but if a software stack relies on "non-system"
-      python installed to a different prefix, those directories did
-      not get bytecompiled at all. Look for versioned python libdirs
-      all over the buildroot in the first loop to allow multiple
-      parallel versions to be handled (notably python 2 vs 3), everything
-      else still falls back to "default" python.
-    
-    (cherry picked from commit e83d5c0bdd0e5d400a7bf76e08ce45f5305cf18d)
-
-diff --git a/scripts/brp-python-bytecompile b/scripts/brp-python-bytecompile
-index af6378e..f227305 100644
---- a/scripts/brp-python-bytecompile
-+++ b/scripts/brp-python-bytecompile
-@@ -34,7 +34,7 @@ fi
- # and below /usr/lib/python3.1/, we're targeting /usr/bin/python3.1
- 
- shopt -s nullglob
--for python_libdir in "$RPM_BUILD_ROOT"/usr/lib{,64}/python[0-9].[0-9]/ ;
-+for python_libdir in `find "$RPM_BUILD_ROOT" -type d|grep -E "/usr/lib(64)?/python[0-9]\.[0-9]$"`;
- do
- 	python_binary=/usr/bin/$(basename $python_libdir)
- 	real_libdir=${python_libdir/$RPM_BUILD_ROOT/}
diff --git a/SOURCES/rpm-4.11.1-reloc-sanity-check.patch b/SOURCES/rpm-4.11.1-reloc-sanity-check.patch
deleted file mode 100644
index 10c5dcc..0000000
--- a/SOURCES/rpm-4.11.1-reloc-sanity-check.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-commit 65c7cc17664358051f0358de272e616dd88ab624
-Author: Panu Matilainen <pmatilai@redhat.com>
-Date:   Tue Aug 27 15:15:40 2013 +0300
-
-    Relax the filename triplet sanity check a bit (RhBug:1001553)
-    
-    - At least unowned directories can cause orphans to be left around
-      in RPMTAG_DIRNAMES, in which case its possible for number of
-      dirnames to be larger than the number of basenames. This is
-      arguably a bug in the relocation code but doesn't seem worth
-      the trouble... so just relax the check to simply permit non-empty
-      dirnames array, the index bound checking is far more important.
-
-diff --git a/lib/rpmfi.c b/lib/rpmfi.c
-index 30663d0..00506ce 100644
---- a/lib/rpmfi.c
-+++ b/lib/rpmfi.c
-@@ -1128,7 +1128,8 @@ static int indexSane(rpmtd xd, rpmtd yd, rpmtd zd)
-     uint32_t zc = rpmtdCount(zd);
- 
-     /* check that the amount of data in each is sane */
--    if (xc > 0 && yc > 0 && yc <= xc && zc == xc) {
-+    /* normally yc <= xc but larger values are not fatal (RhBug:1001553) */
-+    if (xc > 0 && yc > 0 && zc == xc) {
- 	uint32_t * i;
- 	/* ...and that the indexes are within bounds */
- 	while ((i = rpmtdNextUint32(zd))) {
diff --git a/SOURCES/rpm-4.11.1-sepdebugcrcfix.patch b/SOURCES/rpm-4.11.1-sepdebugcrcfix.patch
index 74e8445..d92ba6b 100644
--- a/SOURCES/rpm-4.11.1-sepdebugcrcfix.patch
+++ b/SOURCES/rpm-4.11.1-sepdebugcrcfix.patch
@@ -57,9 +57,9 @@
  	$(rpmgraph_SOURCES) $(rpmkeys_SOURCES) $(rpmsign_SOURCES) \
 -	$(rpmspec_SOURCES)
 +	$(rpmspec_SOURCES) $(am__sepdebugcrcfix_SOURCES_DIST)
- RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
- 	html-recursive info-recursive install-data-recursive \
- 	install-dvi-recursive install-exec-recursive \
+ RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
+ 	ctags-recursive dvi-recursive html-recursive info-recursive \
+ 	install-data-recursive install-dvi-recursive \
 @@ -636,6 +643,8 @@ rpm2cpio_LDADD = lib/librpm.la rpmio/lib
  @LIBDWARF_TRUE@@LIBELF_TRUE@elfdeps_LDADD = rpmio/librpmio.la \
  @LIBDWARF_TRUE@@LIBELF_TRUE@	@WITH_LIBELF_LIB@ @WITH_POPT_LIB@ \
diff --git a/SOURCES/rpm-4.11.3-EVR-validity-check.patch b/SOURCES/rpm-4.11.3-EVR-validity-check.patch
new file mode 100644
index 0000000..da09e08
--- /dev/null
+++ b/SOURCES/rpm-4.11.3-EVR-validity-check.patch
@@ -0,0 +1,30 @@
+--- rpm-4.11.3/build/parseReqs.c.orig	2015-08-19 16:24:55.343033682 +0200
++++ rpm-4.11.3/build/parseReqs.c	2015-08-19 16:25:26.166111719 +0200
+@@ -35,16 +35,6 @@
+ #define	SKIPWHITE(_x)	{while(*(_x) && (risspace(*_x) || *(_x) == ',')) (_x)++;}
+ #define	SKIPNONWHITE(_x){while(*(_x) &&!(risspace(*_x) || *(_x) == ',')) (_x)++;}
+ 
+-static int 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 1;
+-    }
+-    return 0;
+-}
+-
+ rpmRC parseRCPOT(rpmSpec spec, Package pkg, const char *field, rpmTagVal tagN,
+ 	       int index, rpmsenseFlags tagflags)
+ {
+@@ -165,10 +155,6 @@
+ 	    rstrlcpy(EVR, v, (ve-v) + 1);
+ 	    if (rpmCharCheck(spec, EVR, ve-v, ".-_+:%{}~")) goto exit;
+ 
+-            /* While ':' and '-' are valid, only one of each is valid. */
+-	    if (checkSep(EVR, '-', &emsg) || checkSep(EVR, ':', &emsg))
+-		goto exit;
+-
+ 	    re = ve;	/* ==> next token after EVR string starts here */
+ 	} else
+ 	    EVR = NULL;
diff --git a/SOURCES/rpm-4.11.3-Initialize-plugins-based-on-DSO-discovery.patch b/SOURCES/rpm-4.11.3-Initialize-plugins-based-on-DSO-discovery.patch
new file mode 100644
index 0000000..b941cdc
--- /dev/null
+++ b/SOURCES/rpm-4.11.3-Initialize-plugins-based-on-DSO-discovery.patch
@@ -0,0 +1,91 @@
+From b62a75b137bde84ec8bac92c0238502b422c56ce Mon Sep 17 00:00:00 2001
+From: Panu Matilainen <pmatilai@redhat.com>
+Date: Tue, 24 Jun 2014 14:37:38 +0300
+Subject: [PATCH] Initialize plugins based on DSO discovery
+
+- %__transaction_plugins style configuration is problematic for plugins
+  because we want plugins to be, well, pluggable. As in drop-in to
+  enable, which is not achievable with a single macro entry. Look up
+  all DSO's from the plugin dir and enable if a matching
+  %__transaction_foo macro is defined.
+- This isn't optimal but it'll buy us the drop-in capability, which
+  is what matters most right now. We'll want to have forcability as
+  well later on (ie it should be possible to require given plugins
+  to be present)
+
+Conflicts:
+	lib/transaction.c
+---
+ lib/rpmplugins.c  |  3 ++-
+ lib/transaction.c | 34 +++++++++++++++++-----------------
+ 2 files changed, 19 insertions(+), 18 deletions(-)
+
+diff --git a/lib/rpmplugins.c b/lib/rpmplugins.c
+index 7285f54..4e600db 100644
+--- a/lib/rpmplugins.c
++++ b/lib/rpmplugins.c
+@@ -84,8 +84,9 @@ rpmRC rpmpluginsAddPlugin(rpmPlugins plugins, const char *type, const char *name
+ 
+     path = rpmExpand("%{?__", type, "_", name, "}", NULL);
+     if (!path || rstreq(path, "")) {
+-	rpmlog(RPMLOG_ERR, _("Failed to expand %%__%s_%s macro\n"),
++	rpmlog(RPMLOG_DEBUG, _("Plugin %%__%s_%s not configured\n"),
+ 	       type, name);
++	rc = RPMRC_NOTFOUND;
+ 	goto exit;
+     }
+ 
+diff --git a/lib/transaction.c b/lib/transaction.c
+index 08a5643..386f107 100644
+--- a/lib/transaction.c
++++ b/lib/transaction.c
+@@ -1440,29 +1440,29 @@ static int rpmtsProcess(rpmts ts)
+ static rpmRC rpmtsSetupTransactionPlugins(rpmts ts)
+ {
+     rpmRC rc = RPMRC_OK;
+-    char *plugins = NULL, *plugin = NULL;
+-    const char *delims = ",";
++    ARGV_t files = NULL;
++    int nfiles = 0;
++    char *dsoPath = NULL;
+ 
+-    plugins = rpmExpand("%{?__transaction_plugins}", NULL);
+-    if (!plugins || rstreq(plugins, "")) {
+-	goto exit;
+-    }
++    /*
++     * Assume allocated equals initialized. There are some oddball cases
++     * (verification of non-installed package) where this is not true
++     * currently but that's not a new issue.
++     */
+ 
+-    plugin = strtok(plugins, delims);
+-    while(plugin != NULL) {
+-	rpmlog(RPMLOG_DEBUG, "plugin is %s\n", plugin);
+-	if (!rpmpluginsPluginAdded(ts->plugins, (const char*)plugin)) {
+-	    if (rpmpluginsAddPlugin(ts->plugins, "transaction",
+-				    (const char*)plugin) == RPMRC_FAIL) {
+-		/* any configured plugin failing to load is a failure */
++    dsoPath = rpmExpand("%{__plugindir}/*.so", NULL);
++    if (rpmGlob(dsoPath, &nfiles, &files) == 0) {
++	rpmPlugins tsplugins = rpmtsPlugins(ts);
++	for (int i = 0; i < nfiles; i++) {
++	    char *bn = basename(files[i]);
++	    bn[strlen(bn)-strlen(".so")] = '\0';
++	    if (rpmpluginsAddPlugin(tsplugins, "transaction", bn) == RPMRC_FAIL)
+ 		rc = RPMRC_FAIL;
+-	    }
+ 	}
+-	plugin = strtok(NULL, delims);
++	files = argvFree(files);
+     }
++    free(dsoPath);
+ 
+-exit:
+-    free(plugins);
+     return rc;
+ }
+ 
+-- 
+2.1.0
+
diff --git a/SOURCES/rpm-4.11.3-disable-collection-plugins.patch b/SOURCES/rpm-4.11.3-disable-collection-plugins.patch
new file mode 100644
index 0000000..f80e525
--- /dev/null
+++ b/SOURCES/rpm-4.11.3-disable-collection-plugins.patch
@@ -0,0 +1,17 @@
+--- rpm-4.11.3/macros.in.orig	2015-08-19 11:09:48.785440045 +0200
++++ rpm-4.11.3/macros.in	2015-08-19 11:10:15.322505916 +0200
+@@ -1038,10 +1038,10 @@
+ #------------------------------------------------------------------------------
+ # Collection specific macros
+ %__plugindir		%{_libdir}/rpm-plugins
+-%__collection_font	%{__plugindir}/exec.so /usr/bin/fc-cache
+-%__collection_java	%{__plugindir}/exec.so /usr/bin/rebuild-gcj-db
+-%__collection_sepolicy		%{__plugindir}/sepolicy.so
+-%__collection_sepolicy_flags	1
++# %__collection_font	%{__plugindir}/exec.so /usr/bin/fc-cache
++# %__collection_java	%{__plugindir}/exec.so /usr/bin/rebuild-gcj-db
++# %__collection_sepolicy		%{__plugindir}/sepolicy.so
++# %__collection_sepolicy_flags	1
+ 
+ # Transaction plugin macros
+ %__transaction_systemd_inhibit	%{__plugindir}/systemd_inhibit.so
diff --git a/SOURCES/rpm-4.11.x-64-bit-big-endian.patch b/SOURCES/rpm-4.11.x-64-bit-big-endian.patch
deleted file mode 100644
index dca3c82..0000000
--- a/SOURCES/rpm-4.11.x-64-bit-big-endian.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From 09fb3830b66fa88162d2e16eeb6c4a63eec9fdfe Mon Sep 17 00:00:00 2001
-From: Florian Festi <ffesti@redhat.com>
-Date: Mon, 30 Sep 2013 14:17:33 +0200
-Subject: [PATCH 1/2] Fix byteorder for 64 bit tags on big endian machines
- (rh#1012946)
-
----
- lib/header.c | 2 ++
- 1 file changed, 2 insertions(+)
-
-diff --git a/lib/header.c b/lib/header.c
-index b24d16e..ceffb32 100644
---- a/lib/header.c
-+++ b/lib/header.c
-@@ -105,10 +105,12 @@ static const size_t headerMaxbytes = (32*1024*1024);
- RPM_GNUC_CONST
- static uint64_t htonll(uint64_t n)
- {
-+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
-     uint32_t *i = (uint32_t*)&n;
-     uint32_t b = i[0];
-     i[0] = htonl(i[1]);
-     i[1] = htonl(b);
-+#endif
-     return n;
- }
- 
--- 
-1.8.3.1
-
diff --git a/SOURCES/rpm-4.11.x-Add-make_build-macro.patch b/SOURCES/rpm-4.11.x-Add-make_build-macro.patch
new file mode 100644
index 0000000..5871107
--- /dev/null
+++ b/SOURCES/rpm-4.11.x-Add-make_build-macro.patch
@@ -0,0 +1,37 @@
+From 89df36524bace71decee4ab4f979d4ffb449c9a7 Mon Sep 17 00:00:00 2001
+From: Panu Matilainen <pmatilai@redhat.com>
+Date: Wed, 22 Jan 2014 10:56:00 +0200
+Subject: [PATCH] Add %make_build macro for hiding parallel-build magic from
+ specs (ticket #115)
+
+- This allows simplifying the make invokations from specs. In particular
+  the parallel build options no longer need to be messed with from specs,
+  and %__make can be overridden to force a different make implementation
+  to be used throughout the spec.
+- While a lot of software builds correctly in parallel, there are always
+  exceptions... together with _smp_ncpus_max macro this can now be
+  expressed with a separate "%global _smp_ncpus_max 1" (or any other
+  arbitrary value beyond which parallel build is buggy) line which
+  is easy to grep for and experiment with.
+---
+ macros.in | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/macros.in b/macros.in
+index 5a075a3..9c7a111 100644
+--- a/macros.in
++++ b/macros.in
+@@ -861,6 +861,10 @@ package or when debugging this package.\
+ 	--infodir=%{_infodir}
+ 
+ #------------------------------------------------------------------------------
++# The "make" analogue, hiding the _smp_mflags magic from specs
++%make_build %{__make} %{?_smp_mflags}
++
++#------------------------------------------------------------------------------
+ # The make install analogue of %configure for modern autotools:
+ %make_install %{__make} install DESTDIR=%{?buildroot}
+ 
+-- 
+2.1.0
+
diff --git a/SOURCES/rpm-4.11.x-Handle-line-continuation.patch b/SOURCES/rpm-4.11.x-Handle-line-continuation.patch
new file mode 100644
index 0000000..e96ec3b
--- /dev/null
+++ b/SOURCES/rpm-4.11.x-Handle-line-continuation.patch
@@ -0,0 +1,31 @@
+From 817959609b95afe34ce0f7f6c3dc5d7d0d9a8470 Mon Sep 17 00:00:00 2001
+From: Panu Matilainen <pmatilai@redhat.com>
+Date: Wed, 25 Jun 2014 11:28:02 +0300
+Subject: [PATCH] Handle line continuation in grabArgs() (related to
+ RhBug:1045723)
+
+- Commit 1bdcd0500865efd3566efd7f951228f69b58e755 to fix RhBug:1045723
+  broke some funky java macros in Fedora which include line continuation
+  in the argument (comments 6-7 in the bug). That it ever worked seems
+  far more like luck than by design but since this seems to fix it...
+---
+ rpmio/macro.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/rpmio/macro.c b/rpmio/macro.c
+index 12a65a4..b00155c 100644
+--- a/rpmio/macro.c
++++ b/rpmio/macro.c
+@@ -771,7 +771,8 @@ grabArgs(MacroBuf mb, const rpmMacroEntry me, const char * se,
+ 
+ exit:
+     argvFree(argv);
+-    return (*lastc == '\0' || *lastc == '\n') ? lastc : lastc + 1;
++    return ((*lastc == '\0' || *lastc == '\n') && *(lastc-1) != '\\') ?
++	   lastc : lastc + 1;
+ }
+ 
+ /**
+-- 
+2.1.0
+
diff --git a/SOURCES/rpm-4.11.x-RPMSIGTAG_LONGSIZE-detection.patch b/SOURCES/rpm-4.11.x-RPMSIGTAG_LONGSIZE-detection.patch
deleted file mode 100644
index a696d02..0000000
--- a/SOURCES/rpm-4.11.x-RPMSIGTAG_LONGSIZE-detection.patch
+++ /dev/null
@@ -1,88 +0,0 @@
-From 116a6f7105414819944c3347b12a21d2af4a26de Mon Sep 17 00:00:00 2001
-From: Florian Festi <ffesti@redhat.com>
-Date: Mon, 30 Sep 2013 16:08:57 +0200
-Subject: [PATCH 2/2] Move RPMSIGTAG_SIZE vs PMSIGTAG_LONGSIZE detection to
- rpmGenDigest()
-
-Fixes problem with rpmSign() only using RPMSIGTAG_SIZE
-Fixes rh#1012595 for now as we are only moving to PMSIGTAG_LONGSIZE when needed
----
- build/pack.c    |  5 +----
- lib/signature.c | 32 ++++++++++++++++----------------
- 2 files changed, 17 insertions(+), 20 deletions(-)
-
-diff --git a/build/pack.c b/build/pack.c
-index 40bf9dc..81eee37 100644
---- a/build/pack.c
-+++ b/build/pack.c
-@@ -257,7 +257,6 @@ static rpmRC writeRPM(Package pkg, unsigned char ** pkgidp,
-     int xx;
-     rpmRC rc = RPMRC_OK;
-     struct rpmtd_s td;
--    rpmTagVal sizetag;
-     rpmTagVal payloadtag;
- 
-     if (pkgidp)
-@@ -377,13 +376,11 @@ static rpmRC writeRPM(Package pkg, unsigned char ** pkgidp,
-      * such a package.
-      */
-     if (pkg->cpioArchiveSize < UINT32_MAX) {
--	sizetag = RPMSIGTAG_SIZE;
- 	payloadtag = RPMSIGTAG_PAYLOADSIZE;
-     } else {
--	sizetag = RPMSIGTAG_LONGSIZE;
- 	payloadtag = RPMSIGTAG_LONGARCHIVESIZE;
-     }
--    (void) rpmGenDigest(sig, sigtarget, sizetag);
-+    (void) rpmGenDigest(sig, sigtarget, RPMSIGTAG_SIZE);
-     (void) rpmGenDigest(sig, sigtarget, RPMSIGTAG_MD5);
- 
-     if (SHA1) {
-diff --git a/lib/signature.c b/lib/signature.c
-index 4acce7a..f17e47f 100644
---- a/lib/signature.c
-+++ b/lib/signature.c
-@@ -347,24 +347,24 @@ int rpmGenDigest(Header sigh, const char * file, rpmTagVal sigTag)
-     int ret = -1;	/* assume failure. */
- 
-     switch (sigTag) {
--    case RPMSIGTAG_SIZE: {
--	rpm_off_t size;
-+    case RPMSIGTAG_SIZE:
-+    case RPMSIGTAG_LONGSIZE:
- 	if (stat(file, &st) != 0)
- 	    break;
--	size = st.st_size;
--	if (!sighdrPut(sigh, sigTag, RPM_INT32_TYPE, &size, 1))
--	    break;
--	ret = 0;
--	} break;
--    case RPMSIGTAG_LONGSIZE: {
--	rpm_loff_t size;
--	if (stat(file, &st) != 0)
--	    break;
--	size = st.st_size;
--	if (!sighdrPut(sigh, sigTag, RPM_INT64_TYPE, &size, 1))
--	    break;
--	ret = 0;
--	} break;
-+	if (st.st_size>UINT32_MAX || sigTag==RPMSIGTAG_LONGSIZE) {
-+	    rpm_loff_t size;
-+	    size = st.st_size;
-+	    if (!sighdrPut(sigh, RPMSIGTAG_LONGSIZE, RPM_INT64_TYPE, &size, 1))
-+		break;
-+	    ret = 0;
-+	} else {
-+	    rpm_off_t size;
-+	    size = st.st_size;
-+	    if (!sighdrPut(sigh, RPMSIGTAG_SIZE, RPM_INT32_TYPE, &size, 1))
-+		break;
-+	    ret = 0;
-+	}
-+	break;
-     case RPMSIGTAG_MD5:
- 	pktlen = 16;
- 	pkt = xcalloc(pktlen, sizeof(*pkt));
--- 
-1.8.3.1
-
diff --git a/SOURCES/rpm-4.11.x-broken-pipe.patch b/SOURCES/rpm-4.11.x-broken-pipe.patch
new file mode 100644
index 0000000..d9aa9b6
--- /dev/null
+++ b/SOURCES/rpm-4.11.x-broken-pipe.patch
@@ -0,0 +1,45 @@
+From f515907c71c03019a52f89921c41303fa5926b2a Mon Sep 17 00:00:00 2001
+From: Lubos Kardos <lkardos@redhat.com>
+Date: Fri, 12 Jun 2015 13:38:23 +0200
+Subject: [PATCH] Don't show error message if log function fails because of
+ broken pipe.
+
+- regression from commit 11b005c957fb0e52d42078480104d3e27e95e609
+- rhbz: #1231138
+---
+ rpmio/rpmlog.c | 7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+diff --git a/rpmio/rpmlog.c b/rpmio/rpmlog.c
+index f43e622..43ae36f 100644
+--- a/rpmio/rpmlog.c
++++ b/rpmio/rpmlog.c
+@@ -4,7 +4,8 @@
+ 
+ #include "system.h"
+ #include <stdarg.h>
++#include <errno.h>
+ #include <stdlib.h>
+ #include <rpm/rpmlog.h>
+ #include "debug.h"
+ 
+@@ -127,13 +128,13 @@ static int rpmlogDefault(FILE *stdlog, rpmlogRec rec)
+         break;
+     }
+ 
+-    if (fputs(rpmlogLevelPrefix(rec->pri), msgout) == EOF)
++    if (fputs(rpmlogLevelPrefix(rec->pri), msgout) == EOF && errno != EPIPE)
+ 	perror("Error occurred during writing of a log message");
+ 
+-    if (fputs(rec->message, msgout) == EOF)
++    if (fputs(rec->message, msgout) == EOF && errno != EPIPE)
+ 	perror("Error occurred during writing of a log message");
+ 
+-    if (fflush(msgout) == EOF)
++    if (fflush(msgout) == EOF && errno != EPIPE)
+ 	perror("Error occurred during writing of a log message");
+ 
+     return (rec->pri <= RPMLOG_CRIT ? RPMLOG_EXIT : 0);
+-- 
+1.9.3
+
diff --git a/SOURCES/rpm-4.11.x-color-skipping.patch b/SOURCES/rpm-4.11.x-color-skipping.patch
new file mode 100644
index 0000000..46b77cf
--- /dev/null
+++ b/SOURCES/rpm-4.11.x-color-skipping.patch
@@ -0,0 +1,30 @@
+From 2f31395dcd49459c775caaadefa0513181cd12ff Mon Sep 17 00:00:00 2001
+From: Lubos Kardos <lkardos@localhost.localdomain>
+Date: Wed, 17 Dec 2014 12:53:30 +0100
+Subject: [PATCH] Fix color skipping of multiple files with the same content.
+
+- If we process some file and we find another file with the same path
+  and the same content and this other file is skipped for color then
+  the currently being processed file has to be skipped for color too.
+  (RhBug:1170124)
+---
+ lib/transaction.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/lib/transaction.c b/lib/transaction.c
+index 736f64d..2d1432e 100644
+--- a/lib/transaction.c
++++ b/lib/transaction.c
+@@ -587,6 +587,9 @@ assert(otherFi != NULL);
+ 		    if (!(oflags & RPMFILE_GHOST)) {
+ 			rpmfsSetAction(fs, i, FA_SKIP);
+ 		    }
++		/* if the other file is color skipped then skip this file too */
++		} else if (oaction == FA_SKIPCOLOR) {
++		    rpmfsSetAction(fs, i, FA_SKIPCOLOR);
+ 		}
+ 	    }
+ 
+-- 
+2.1.0
+
diff --git a/SOURCES/rpm-4.11.x-defattr-permissions.patch b/SOURCES/rpm-4.11.x-defattr-permissions.patch
new file mode 100644
index 0000000..f8e1b50
--- /dev/null
+++ b/SOURCES/rpm-4.11.x-defattr-permissions.patch
@@ -0,0 +1,16 @@
+--- rpm-4.8.0/build/files.c.defattr-permissions	2015-02-23 10:45:47.043339687 +0100
++++ rpm-4.8.0/build/files.c	2015-02-23 10:53:55.673480702 +0100
+@@ -1446,6 +1446,12 @@
+ 	    if (fl->def.ar.ar_dmodestr) {
+ 		fileMode &= S_IFMT;
+ 		fileMode |= fl->def.ar.ar_dmode;
++	    } else if (fl->def.ar.ar_fmodestr){
++		rpmlog(RPMLOG_WARNING, _("%%defattr doesn't define directory "
++		    "mode so file mode defined in %%defattr is used for "
++		    "directory: %s\n"), diskPath);
++		fileMode &= S_IFMT;
++		fileMode |= fl->def.ar.ar_fmode;
+ 	    }
+ 	} else if (!S_ISLNK(fileMode) && fl->def.ar.ar_fmodestr) {
+ 	    fileMode &= S_IFMT;
+
diff --git a/SOURCES/rpm-4.11.x-deprecate-addsign.patch b/SOURCES/rpm-4.11.x-deprecate-addsign.patch
new file mode 100644
index 0000000..eb7a1a6
--- /dev/null
+++ b/SOURCES/rpm-4.11.x-deprecate-addsign.patch
@@ -0,0 +1,25 @@
+From 5dd555adbed5dae6a9255bb17074d2b043d0244e Mon Sep 17 00:00:00 2001
+From: Lubos Kardos <lkardos@redhat.com>
+Date: Fri, 27 Mar 2015 09:57:29 +0100
+Subject: [PATCH] Add deprecation warning to description of "--addsign"
+
+---
+ rpmpopt.in | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/rpmpopt.in b/rpmpopt.in
+index fe4f40f..ca95702 100644
+--- a/rpmpopt.in
++++ b/rpmpopt.in
+@@ -188,7 +188,7 @@ rpmbuild alias --buildpolicy --define '__os_install_post %{_rpmconfigdir}/brp-!#
+ # Minimally preserve rpmbuild's --sign functionality
+ rpmbuild alias --sign \
+ 	--pipe "grep '.*: .*\.rpm$'|cut -d: -f2|xargs -r rpm --addsign" \
+-	--POPTdesc=$"generate GPG signature"
++	--POPTdesc=$"generate GPG signature (deprecated, use command rpmsign instead)"
+ 
+ rpmsign alias --key-id  --define '_gpg_name !#:+' \
+ 	--POPTdesc=$"key id/name to sign with" \
+-- 
+2.1.0
+
diff --git a/SOURCES/rpm-4.11.x-fix-debuginfo-creation.patch b/SOURCES/rpm-4.11.x-fix-debuginfo-creation.patch
new file mode 100644
index 0000000..02a80e3
--- /dev/null
+++ b/SOURCES/rpm-4.11.x-fix-debuginfo-creation.patch
@@ -0,0 +1,27 @@
+From 659614aeb6fffe3b249c12b442bd85129100f73b Mon Sep 17 00:00:00 2001
+From: Pascal Terjan <pterjan@gmail.com>
+Date: Mon, 16 Feb 2015 13:08:50 +0100
+Subject: [PATCH] Fix debuginfo creation for changed file output.
+
+file will print a "warning" that it only processed up to 256 notes.
+Fixes: http://rpm.org/ticket/887
+---
+ scripts/find-debuginfo.sh | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/scripts/find-debuginfo.sh b/scripts/find-debuginfo.sh
+index 57449f7..264fad5 100644
+--- a/scripts/find-debuginfo.sh
++++ b/scripts/find-debuginfo.sh
+@@ -205,7 +205,7 @@ $strict || strict_error=WARNING
+ find "$RPM_BUILD_ROOT" ! -path "${debugdir}/*.debug" -type f \
+      		     \( -perm -0100 -or -perm -0010 -or -perm -0001 \) \
+ 		     -print |
+-file -N -f - | sed -n -e 's/^\(.*\):[ 	]*.*ELF.*, not stripped/\1/p' |
++file -N -f - | sed -n -e 's/^\(.*\):[ 	]*.*ELF.*, not stripped.*/\1/p' |
+ xargs --no-run-if-empty stat -c '%h %D_%i %n' |
+ while read nlinks inum f; do
+   get_debugfn "$f"
+-- 
+2.1.0
+
diff --git a/SOURCES/rpm-4.11.x-fix-stripping-of-binaries.patch b/SOURCES/rpm-4.11.x-fix-stripping-of-binaries.patch
new file mode 100644
index 0000000..79fd6b7
--- /dev/null
+++ b/SOURCES/rpm-4.11.x-fix-stripping-of-binaries.patch
@@ -0,0 +1,56 @@
+From 5b4805df2085b0e7c4f09caad62638c3238b3bc1 Mon Sep 17 00:00:00 2001
+From: Florian Festi <ffesti@redhat.com>
+Date: Tue, 30 Jun 2015 11:39:21 +0200
+Subject: [PATCH] Fix stripping of binaries for changed file output.
+
+file will print a "warning" that it only processed up to 256 notes.
+
+ - Related: 659614aeb6fffe3b249c12b442bd85129100f73b
+ - Related: http://rpm.org/ticket/887
+ - Related: rhbz#1206312
+---
+ scripts/brp-strip              | 2 +-
+ scripts/brp-strip-comment-note | 2 +-
+ scripts/brp-strip-shared       | 2 +-
+ 3 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/scripts/brp-strip b/scripts/brp-strip
+index 2e99d1e..5e64566 100755
+--- a/scripts/brp-strip
++++ b/scripts/brp-strip
+@@ -15,6 +15,6 @@ esac
+ for f in `find "$RPM_BUILD_ROOT" -type f \( -perm -0100 -or -perm -0010 -or -perm -0001 \) -exec file {} \; | \
+         grep -v "^${RPM_BUILD_ROOT}/\?usr/lib/debug"  | \
+ 	grep -v ' shared object,' | \
+-	sed -n -e 's/^\(.*\):[ 	]*ELF.*, not stripped/\1/p'`; do
++	sed -n -e 's/^\(.*\):[ 	]*ELF.*, not stripped.*/\1/p'`; do
+ 	$STRIP -g "$f" || :
+ done
+diff --git a/scripts/brp-strip-comment-note b/scripts/brp-strip-comment-note
+index 323c041..833ac78 100755
+--- a/scripts/brp-strip-comment-note
++++ b/scripts/brp-strip-comment-note
+@@ -16,7 +16,7 @@ esac
+ # for already stripped elf files in the build root
+ for f in `find "$RPM_BUILD_ROOT" -type f \( -perm -0100 -or -perm -0010 -or -perm -0001 \) -exec file {} \; | \
+         grep -v "^${RPM_BUILD_ROOT}/\?usr/lib/debug"  | \
+-	sed -n -e 's/^\(.*\):[ 	]*ELF.*, stripped/\1/p'`; do
++	sed -n -e 's/^\(.*\):[ 	]*ELF.*, stripped.*/\1/p'`; do
+ 	note="-R .note"
+ 	if $OBJDUMP -h $f | grep '^[ 	]*[0-9]*[ 	]*.note[ 	]' -A 1 | \
+ 		grep ALLOC >/dev/null; then
+diff --git a/scripts/brp-strip-shared b/scripts/brp-strip-shared
+index e06ee4b..51d10d5 100644
+--- a/scripts/brp-strip-shared
++++ b/scripts/brp-strip-shared
+@@ -20,6 +20,6 @@ esac
+ for f in `find "$RPM_BUILD_ROOT" -type f -a -exec file {} \; | \
+         grep -v "^${RPM_BUILD_ROOT}/\?usr/lib/debug"  | \
+ 	grep ' shared object,' | \
+-	sed -n -e 's/^\(.*\):[ 	]*ELF.*, not stripped/\1/p'`; do
++	sed -n -e 's/^\(.*\):[ 	]*ELF.*, not stripped.*/\1/p'`; do
+ 	$STRIP --strip-unneeded "$f"
+ done
+-- 
+2.1.0
+
diff --git a/SOURCES/rpm-4.11.x-parametrized-macro-invocations.patch b/SOURCES/rpm-4.11.x-parametrized-macro-invocations.patch
new file mode 100644
index 0000000..2769f1c
--- /dev/null
+++ b/SOURCES/rpm-4.11.x-parametrized-macro-invocations.patch
@@ -0,0 +1,32 @@
+From 1bdcd0500865efd3566efd7f951228f69b58e755 Mon Sep 17 00:00:00 2001
+From: Panu Matilainen <pmatilai@redhat.com>
+Date: Wed, 19 Feb 2014 14:16:38 +0200
+Subject: [PATCH] Dont eat newlines on parametrized macro invocations
+ (RhBug:1045723)
+
+- Makes the testcase from commit f082b5baa4dcf9601eeb1e0e520ff06e77dc61c0
+  succeed. While the old behavior is non-sensical and most likely entirely
+  unintentional, we're changing a very long-standing behavior here (tested
+  back to rpm 4.4.x and almost certainly much much older than that) so
+  its entirely possible people are actually relying on the old
+  behavior. Lets see what breaks...
+---
+ rpmio/macro.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/rpmio/macro.c b/rpmio/macro.c
+index e1c2a91..72471a2 100644
+--- a/rpmio/macro.c
++++ b/rpmio/macro.c
+@@ -764,7 +764,7 @@ grabArgs(MacroBuf mb, const rpmMacroEntry me, const char * se,
+ 
+ exit:
+     argvFree(argv);
+-    return *lastc ? lastc + 1 : lastc; 
++    return (*lastc == '\0' || *lastc == '\n') ? lastc : lastc + 1;
+ }
+ 
+ /**
+-- 
+2.1.0
+
diff --git a/SOURCES/rpm-4.11.x-reset-fileactions.patch b/SOURCES/rpm-4.11.x-reset-fileactions.patch
deleted file mode 100644
index cf67f6b..0000000
--- a/SOURCES/rpm-4.11.x-reset-fileactions.patch
+++ /dev/null
@@ -1,58 +0,0 @@
-diff --git a/lib/rpmfs.c b/lib/rpmfs.c
-index 764618d..916f6eb 100644
---- a/lib/rpmfs.c
-+++ b/lib/rpmfs.c
-@@ -18,7 +18,7 @@ rpmfs rpmfsNew(rpm_count_t fc, int initState)
-     rpmfs fs = xcalloc(1, sizeof(*fs));
-     fs->fc = fc;
-     fs->actions = xmalloc(fs->fc * sizeof(*fs->actions));
--    memset(fs->actions, FA_UNKNOWN, fs->fc * sizeof(*fs->actions));
-+    rpmfsResetActions(fs);
-     if (initState) {
- 	fs->states = xmalloc(sizeof(*fs->states) * fs->fc);
- 	memset(fs->states, RPMFILE_STATE_NORMAL, fs->fc);
-@@ -115,3 +115,10 @@ void rpmfsSetAction(rpmfs fs, unsigned int ix, rpmFileAction action)
- 	fs->actions[ix] = action;
-     }
- }
-+
-+void rpmfsResetActions(rpmfs fs)
-+{
-+    if (fs && fs->actions) {
-+	memset(fs->actions, FA_UNKNOWN, fs->fc * sizeof(*fs->actions));
-+    }
-+}
-diff --git a/lib/rpmfs.h b/lib/rpmfs.h
-index 5f74753..83f99d1 100644
---- a/lib/rpmfs.h
-+++ b/lib/rpmfs.h
-@@ -57,6 +57,9 @@ rpmFileAction rpmfsGetAction(rpmfs fs, unsigned int ix);
- RPM_GNUC_INTERNAL
- void rpmfsSetAction(rpmfs fs, unsigned int ix, rpmFileAction action);
- 
-+RPM_GNUC_INTERNAL
-+void rpmfsResetActions(rpmfs fs);
-+
- #ifdef __cplusplus
- }
- #endif
-diff --git a/lib/transaction.c b/lib/transaction.c
-index 02badc6..09c199a 100644
---- a/lib/transaction.c
-+++ b/lib/transaction.c
-@@ -1323,11 +1323,14 @@ static int rpmtsPrepare(rpmts ts)
- 
-     rpmlog(RPMLOG_DEBUG, "computing %" PRIu64 " file fingerprints\n", fileCount);
- 
--    /* Skip netshared paths, not our i18n files, and excluded docs */
-+    /* Reset actions, set skip for netshared paths and excluded files */
-     pi = rpmtsiInit(ts);
-     while ((p = rpmtsiNext(pi, 0)) != NULL) {
- 	if (rpmfiFC(rpmteFI(p)) == 0)
- 	    continue;
-+	/* Ensure clean state, this could get called more than once. */
-+	rpmfs fs = rpmteGetFileStates(p);
-+	rpmfsResetActions(fs);
- 	if (rpmteType(p) == TR_ADDED) {
- 	    skipInstallFiles(ts, p);
- 	} else {
diff --git a/SOURCES/rpm-4.11.x-setperms-setugids-mutual-exclusion.patch b/SOURCES/rpm-4.11.x-setperms-setugids-mutual-exclusion.patch
new file mode 100644
index 0000000..b422346
--- /dev/null
+++ b/SOURCES/rpm-4.11.x-setperms-setugids-mutual-exclusion.patch
@@ -0,0 +1,25 @@
+From 6013799f80d4dc4fbf5d23cfa0c54ffdee4f95c7 Mon Sep 17 00:00:00 2001
+From: jchaloup <jchaloup@redhat.com>
+Date: Fri, 13 Jun 2014 12:53:02 +0200
+Subject: [PATCH] rpm.8 setperms setugids mutual exclusion
+
+---
+ doc/rpm.8 | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/doc/rpm.8 b/doc/rpm.8
+index 31ccceb..c3b79bd 100644
+--- a/doc/rpm.8
++++ b/doc/rpm.8
+@@ -851,6 +851,8 @@ sets permissions of files in the given package.
+ .TP
+ \fBrpm\fR \fB--setugids\fR \fIPACKAGE_NAME\fR
+ sets user/group ownership of files in the given package.
++.TP
++Options \fB--setperms\fR and \fB--setugids\fR are mutually exclusive.
+ 
+ .SS "FTP/HTTP OPTIONS"
+ .PP
+-- 
+1.9.3
+
diff --git a/SOURCES/rpm-4.11.x-systemd-inhibit.patch b/SOURCES/rpm-4.11.x-systemd-inhibit.patch
new file mode 100644
index 0000000..6757b1a
--- /dev/null
+++ b/SOURCES/rpm-4.11.x-systemd-inhibit.patch
@@ -0,0 +1,657 @@
+diff --git a/configure.ac b/configure.ac
+index 167491e..3bacc1d 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -745,6 +745,16 @@ AS_IF([test "$enable_plugins" = yes],[
+ ])
+ AM_CONDITIONAL(ENABLE_PLUGINS,[test "$enable_plugins" = yes])
+ 
++with_dbus=no
++AS_IF([test "$enable_plugins" != no],[
++  PKG_CHECK_MODULES([DBUS],
++    [dbus-1 >= 1.0],
++    [AC_DEFINE(DBUS, 1, [Build with dbus support?]) with_dbus=yes],
++    [with_dbus=no])
++  AC_SUBST(DBUS_CFLAGS)
++  AC_SUBST(DBUS_LIBS)
++])
++AM_CONDITIONAL(DBUS, [test "$with_dbus" = yes])
+ 
+ with_dmalloc=no
+ AC_ARG_WITH(dmalloc, [AS_HELP_STRING([--with-dmalloc],[build with dmalloc debugging support])])
+diff --git a/lib/psm.c b/lib/psm.c
+index 8f5376d..e80a90e 100644
+--- a/lib/psm.c
++++ b/lib/psm.c
+@@ -23,8 +23,11 @@
+ #include "lib/rpmfi_internal.h" /* XXX replaced/states... */
+ #include "lib/rpmte_internal.h"	/* XXX internal apis */
+ #include "lib/rpmdb_internal.h" /* rpmdbAdd/Remove */
++#include "lib/rpmts_internal.h" /* ts->plugins */
+ #include "lib/rpmscript.h"
+ 
++#include "lib/rpmplugins.h"
++
+ #include "debug.h"
+ 
+ typedef enum pkgStage_e {
+@@ -421,7 +424,7 @@ static rpmRC runScript(rpmpsm psm, ARGV_const_t prefixes,
+ 
+     rpmswEnter(rpmtsOp(psm->ts, RPMTS_OP_SCRIPTLETS), 0);
+     rc = rpmScriptRun(script, arg1, arg2, sfd,
+-		      prefixes, warn_only, selinux);
++		      prefixes, warn_only, selinux, psm->ts->plugins);
+     rpmswExit(rpmtsOp(psm->ts, RPMTS_OP_SCRIPTLETS), 0);
+ 
+     /* Map warn-only errors to "notfound" for script stop callback */
+@@ -1033,16 +1036,23 @@ rpmRC rpmpsmRun(rpmts ts, rpmte te, pkgGoal goal)
+ 	switch (goal) {
+ 	case PKG_INSTALL:
+ 	case PKG_ERASE:
+-	    op = (goal == PKG_INSTALL) ? RPMTS_OP_INSTALL : RPMTS_OP_ERASE;
+-	    rpmswEnter(rpmtsOp(psm->ts, op), 0);
++	    /* Run pre transaction element hook for all plugins */
++	    if (rpmpluginsCallPsmPre(ts->plugins, te) != RPMRC_FAIL) {
++
++		op = (goal == PKG_INSTALL) ? RPMTS_OP_INSTALL : RPMTS_OP_ERASE;
++		rpmswEnter(rpmtsOp(psm->ts, op), 0);
+ 
+-	    rc = rpmpsmNext(psm, PSM_INIT);
+-	    if (!rc) rc = rpmpsmNext(psm, PSM_PRE);
+-	    if (!rc) rc = rpmpsmNext(psm, PSM_PROCESS);
+-	    if (!rc) rc = rpmpsmNext(psm, PSM_POST);
+-	    (void) rpmpsmNext(psm, PSM_FINI);
++		rc = rpmpsmNext(psm, PSM_INIT);
++		if (!rc) rc = rpmpsmNext(psm, PSM_PRE);
++		if (!rc) rc = rpmpsmNext(psm, PSM_PROCESS);
++		if (!rc) rc = rpmpsmNext(psm, PSM_POST);
++		(void) rpmpsmNext(psm, PSM_FINI);
++
++		rpmswExit(rpmtsOp(psm->ts, op), 0);
++	    }
+ 
+-	    rpmswExit(rpmtsOp(psm->ts, op), 0);
++	    /* Run post transaction element hook for all plugins */
++	    rpmpluginsCallPsmPost(ts->plugins, te, rc);
+ 	    break;
+ 	case PKG_PRETRANS:
+ 	case PKG_POSTTRANS:
+diff --git a/lib/rpmplugins.c b/lib/rpmplugins.c
+index 9098aa5..7285f54 100644
+--- a/lib/rpmplugins.c
++++ b/lib/rpmplugins.c
+@@ -76,16 +76,16 @@ rpmRC rpmpluginsAdd(rpmPlugins plugins, const char *name, const char *path,
+     return rpmpluginsCallInit(plugins, name, opts);
+ }
+ 
+-rpmRC rpmpluginsAddCollectionPlugin(rpmPlugins plugins, const char *name)
++rpmRC rpmpluginsAddPlugin(rpmPlugins plugins, const char *type, const char *name)
+ {
+     char *path;
+     char *options;
+     rpmRC rc = RPMRC_FAIL;
+ 
+-    path = rpmExpand("%{?__collection_", name, "}", NULL);
++    path = rpmExpand("%{?__", type, "_", name, "}", NULL);
+     if (!path || rstreq(path, "")) {
+-	rpmlog(RPMLOG_ERR, _("Failed to expand %%__collection_%s macro\n"),
+-	       name);
++	rpmlog(RPMLOG_ERR, _("Failed to expand %%__%s_%s macro\n"),
++	       type, name);
+ 	goto exit;
+     }
+ 
+@@ -195,3 +195,88 @@ rpmRC rpmpluginsCallCollectionPreRemove(rpmPlugins plugins, const char *name)
+     RPMPLUGINS_SET_HOOK_FUNC(PLUGINHOOK_COLL_PRE_REMOVE);
+     return hookFunc();
+ }
++
++rpmRC rpmpluginsCallTsmPre(rpmPlugins plugins, rpmts ts)
++{
++    rpmRC (*hookFunc)(rpmts);
++    int i;
++    rpmRC rc = RPMRC_OK;
++    const char *name = NULL;
++
++    for (i = 0; i < plugins->count; i++) {
++	name = plugins->names[i];
++	RPMPLUGINS_SET_HOOK_FUNC(PLUGINHOOK_TSM_PRE);
++	if (hookFunc(ts) == RPMRC_FAIL)
++	    rc = RPMRC_FAIL;
++    }
++
++    return rc;
++}
++
++rpmRC rpmpluginsCallTsmPost(rpmPlugins plugins, rpmts ts, int res)
++{
++    rpmRC (*hookFunc)(rpmts, int);
++    int i;
++    rpmRC rc = RPMRC_OK;
++    const char *name = NULL;
++
++    for (i = 0; i < plugins->count; i++) {
++	name = plugins->names[i];
++	RPMPLUGINS_SET_HOOK_FUNC(PLUGINHOOK_TSM_POST);
++	if (hookFunc(ts, res) == RPMRC_FAIL)
++	    rc = RPMRC_FAIL;
++    }
++
++    return rc;
++}
++
++rpmRC rpmpluginsCallPsmPre(rpmPlugins plugins, rpmte te)
++{
++    rpmRC (*hookFunc)(rpmte);
++    int i;
++    rpmRC rc = RPMRC_OK;
++    const char *name = NULL;
++
++    for (i = 0; i < plugins->count; i++) {
++	name = plugins->names[i];
++	RPMPLUGINS_SET_HOOK_FUNC(PLUGINHOOK_PSM_PRE);
++	if (hookFunc(te) == RPMRC_FAIL)
++	    rc = RPMRC_FAIL;
++    }
++
++    return rc;
++}
++
++rpmRC rpmpluginsCallPsmPost(rpmPlugins plugins, rpmte te, int res)
++{
++    rpmRC (*hookFunc)(rpmte, int);
++    int i;
++    rpmRC rc = RPMRC_OK;
++    const char *name = NULL;
++
++    for (i = 0; i < plugins->count; i++) {
++	name = plugins->names[i];
++	RPMPLUGINS_SET_HOOK_FUNC(PLUGINHOOK_PSM_POST);
++	if (hookFunc(te, res) == RPMRC_FAIL)
++	    rc = RPMRC_FAIL;
++    }
++
++    return rc;
++}
++
++rpmRC rpmpluginsCallScriptSetup(rpmPlugins plugins, char* path)
++{
++    rpmRC (*hookFunc)(char*);
++    int i;
++    rpmRC rc = RPMRC_OK;
++    const char *name = NULL;
++
++    for (i = 0; i < plugins->count; i++) {
++	name = plugins->names[i];
++	RPMPLUGINS_SET_HOOK_FUNC(PLUGINHOOK_SCRIPT_SETUP);
++	if (hookFunc(path) == RPMRC_FAIL)
++	    rc = RPMRC_FAIL;
++    }
++
++    return rc;
++}
+diff --git a/lib/rpmplugins.h b/lib/rpmplugins.h
+index 7985559..c462eae 100644
+--- a/lib/rpmplugins.h
++++ b/lib/rpmplugins.h
+@@ -11,11 +11,20 @@ extern "C" {
+ 
+ #define PLUGINHOOK_INIT_FUNC			pluginhook_init
+ #define PLUGINHOOK_CLEANUP_FUNC			pluginhook_cleanup
++
+ #define PLUGINHOOK_OPENTE_FUNC			pluginhook_opente
+ #define PLUGINHOOK_COLL_POST_ADD_FUNC		pluginhook_coll_post_add
+ #define PLUGINHOOK_COLL_POST_ANY_FUNC		pluginhook_coll_post_any
+ #define PLUGINHOOK_COLL_PRE_REMOVE_FUNC		pluginhook_coll_pre_remove
+ 
++#define PLUGINHOOK_TSM_PRE_FUNC        pluginhook_tsm_pre
++#define PLUGINHOOK_TSM_POST_FUNC        pluginhook_tsm_post
++
++#define PLUGINHOOK_PSM_PRE_FUNC        pluginhook_psm_pre
++#define PLUGINHOOK_PSM_POST_FUNC        pluginhook_psm_post
++ 
++#define PLUGINHOOK_SCRIPT_SETUP_FUNC    pluginhook_script_setup
++
+ enum rpmPluginHook_e {
+     PLUGINHOOK_NONE		= 0,
+     PLUGINHOOK_INIT		= 1 << 0,
+@@ -23,7 +32,12 @@ enum rpmPluginHook_e {
+     PLUGINHOOK_OPENTE		= 1 << 2,
+     PLUGINHOOK_COLL_POST_ADD	= 1 << 3,
+     PLUGINHOOK_COLL_POST_ANY	= 1 << 4,
+-    PLUGINHOOK_COLL_PRE_REMOVE	= 1 << 5
++    PLUGINHOOK_COLL_PRE_REMOVE	= 1 << 5,
++    PLUGINHOOK_TSM_PRE         = 1 << 6,
++    PLUGINHOOK_TSM_POST        = 1 << 7,
++    PLUGINHOOK_PSM_PRE         = 1 << 8,
++    PLUGINHOOK_PSM_POST        = 1 << 9,
++    PLUGINHOOK_SCRIPT_SETUP    = 1 << 10
+ };
+ 
+ typedef rpmFlags rpmPluginHook;
+@@ -53,12 +67,13 @@ rpmPlugins rpmpluginsFree(rpmPlugins plugins);
+ rpmRC rpmpluginsAdd(rpmPlugins plugins, const char *name, const char *path, const char *opts);
+ 
+ /** \ingroup rpmplugins
+- * Add and open a collection plugin
++ * Add and open a rpm plugin
+  * @param plugins	plugins structure to add a collection plugin to
+- * @param name		name of collection to open
++ * @param type     type of plugin
++ * @param name		name of plugin
+  * @return		RPMRC_OK on success, RPMRC_FAIL otherwise
+  */
+-rpmRC rpmpluginsAddCollectionPlugin(rpmPlugins plugins, const char *name);
++rpmRC rpmpluginsAddPlugin(rpmPlugins plugins, const char *type, const char *name);
+ 
+ /** \ingroup rpmplugins
+  * Determine if a plugin has been added already
+@@ -119,6 +134,48 @@ rpmRC rpmpluginsCallCollectionPostAny(rpmPlugins plugins, const char *name);
+  */
+ rpmRC rpmpluginsCallCollectionPreRemove(rpmPlugins plugins, const char *name);
+ 
++/** \ingroup rpmplugins
++ * Call the pre transaction plugin hook
++ * @param plugins	plugins structure
++ * @param ts		processed transaction
++ * @return		RPMRC_OK on success, RPMRC_FAIL otherwise
++ */
++rpmRC rpmpluginsCallTsmPre(rpmPlugins plugins, rpmts ts);
++
++/** \ingroup rpmplugins
++ * Call the post transaction plugin hook
++ * @param plugins	plugins structure
++ * @param ts		processed transaction
++ * @param res		transaction result code
++ * @return		RPMRC_OK on success, RPMRC_FAIL otherwise
++ */
++rpmRC rpmpluginsCallTsmPost(rpmPlugins plugins, rpmts ts, int res);
++
++/** \ingroup rpmplugins
++ * Call the pre transaction element plugin hook
++ * @param plugins	plugins structure
++ * @param te		processed transaction element
++ * @return		RPMRC_OK on success, RPMRC_FAIL otherwise
++ */
++rpmRC rpmpluginsCallPsmPre(rpmPlugins plugins, rpmte te);
++
++/** \ingroup rpmplugins
++ * Call the post transaction element plugin hook
++ * @param plugins	plugins structure
++ * @param te		processed transaction element
++ * @param res		transaction element result code
++ * @return		RPMRC_OK on success, RPMRC_FAIL otherwise
++ */
++rpmRC rpmpluginsCallPsmPost(rpmPlugins plugins, rpmte te, int res);
++
++/** \ingroup rpmplugins
++ * Call the script setup plugin hook
++ * @param plugins	plugins structure
++ * @param path		script path
++ * @return		RPMRC_OK on success, RPMRC_FAIL otherwise
++ */
++rpmRC rpmpluginsCallScriptSetup(rpmPlugins plugins, char* path);
++
+ #ifdef __cplusplus
+ }
+ #endif
+diff --git a/lib/rpmscript.c b/lib/rpmscript.c
+index 57c24c6..f8c5fc7 100644
+--- a/lib/rpmscript.c
++++ b/lib/rpmscript.c
+@@ -14,6 +14,8 @@
+ #include "rpmio/rpmlua.h"
+ #include "lib/rpmscript.h"
+ 
++#include "lib/rpmplugins.h"     /* rpm plugins hooks */
++
+ #include "debug.h"
+ 
+ struct rpmScript_s {
+@@ -91,7 +93,7 @@ static rpmRC runLuaScript(int selinux, ARGV_const_t prefixes,
+ 
+ static const char * const SCRIPT_PATH = "PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin";
+ 
+-static void doScriptExec(int selinux, ARGV_const_t argv, ARGV_const_t prefixes,
++static void doScriptExec(rpmPlugins plugins, int selinux, ARGV_const_t argv, ARGV_const_t prefixes,
+ 			FD_t scriptFd, FD_t out)
+ {
+     int pipes[2];
+@@ -169,7 +171,10 @@ static void doScriptExec(int selinux, ARGV_const_t argv, ARGV_const_t prefixes,
+ 	}
+ 
+ 	if (xx == 0) {
+-	    xx = execv(argv[0], argv);
++	    /* Run script setup hook for all plugins */
++	    if (rpmpluginsCallScriptSetup(plugins, argv[0]) != RPMRC_FAIL) {
++		xx = execv(argv[0], argv);
++	    }
+ 	}
+     }
+     _exit(127); /* exit 127 for compatibility with bash(1) */
+@@ -202,7 +207,7 @@ exit:
+ /**
+  * Run an external script.
+  */
+-static rpmRC runExtScript(int selinux, ARGV_const_t prefixes,
++static rpmRC runExtScript(rpmPlugins plugins, int selinux, ARGV_const_t prefixes,
+ 		   const char *sname, rpmlogLvl lvl, FD_t scriptFd,
+ 		   ARGV_t * argvp, const char *script, int arg1, int arg2)
+ {
+@@ -258,7 +263,7 @@ static rpmRC runExtScript(int selinux, ARGV_const_t prefixes,
+     } else if (pid == 0) {/* Child */
+ 	rpmlog(RPMLOG_DEBUG, "%s: execv(%s) pid %d\n",
+ 	       sname, *argvp[0], (unsigned)getpid());
+-	doScriptExec(selinux, *argvp, prefixes, scriptFd, out);
++	doScriptExec(plugins, selinux, *argvp, prefixes, scriptFd, out);
+     }
+ 
+     do {
+@@ -297,7 +302,7 @@ exit:
+ }
+ 
+ rpmRC rpmScriptRun(rpmScript script, int arg1, int arg2, FD_t scriptFd,
+-		   ARGV_const_t prefixes, int warn_only, int selinux)
++		   ARGV_const_t prefixes, int warn_only, int selinux, rpmPlugins plugins)
+ {
+     ARGV_t args = NULL;
+     rpmlogLvl lvl = warn_only ? RPMLOG_WARNING : RPMLOG_ERR;
+@@ -315,7 +320,7 @@ rpmRC rpmScriptRun(rpmScript script, int arg1, int arg2, FD_t scriptFd,
+     if (rstreq(args[0], "<lua>")) {
+ 	rc = runLuaScript(selinux, prefixes, script->descr, lvl, scriptFd, &args, script->body, arg1, arg2);
+     } else {
+-	rc = runExtScript(selinux, prefixes, script->descr, lvl, scriptFd, &args, script->body, arg1, arg2);
++	rc = runExtScript(plugins, selinux, prefixes, script->descr, lvl, scriptFd, &args, script->body, arg1, arg2);
+     }
+     argvFree(args);
+ 
+diff --git a/lib/rpmscript.h b/lib/rpmscript.h
+index 7d584bc..852735b 100644
+--- a/lib/rpmscript.h
++++ b/lib/rpmscript.h
+@@ -29,7 +29,7 @@ rpmScript rpmScriptFree(rpmScript script);
+ 
+ RPM_GNUC_INTERNAL
+ rpmRC rpmScriptRun(rpmScript script, int arg1, int arg2, FD_t scriptFd,
+-                   ARGV_const_t prefixes, int warn_only, int selinux);
++                   ARGV_const_t prefixes, int warn_only, int selinux, rpmPlugins plugins);
+ 
+ RPM_GNUC_INTERNAL
+ rpmTagVal rpmScriptTag(rpmScript script);
+diff --git a/lib/rpmte.c b/lib/rpmte.c
+index 87fb391..9fc5522 100644
+--- a/lib/rpmte.c
++++ b/lib/rpmte.c
+@@ -889,7 +889,7 @@ rpmRC rpmteSetupCollectionPlugins(rpmte te)
+     rpmteOpen(te, 0);
+     for (; colls && *colls; colls++) {
+ 	if (!rpmpluginsPluginAdded(plugins, *colls)) {
+-	    rc = rpmpluginsAddCollectionPlugin(plugins, *colls);
++	    rc = rpmpluginsAddPlugin(plugins, "collection", *colls);
+ 	    if (rc != RPMRC_OK) {
+ 		break;
+ 	    }
+diff --git a/lib/transaction.c b/lib/transaction.c
+index 45c30b5..08a5643 100644
+--- a/lib/transaction.c
++++ b/lib/transaction.c
+@@ -22,6 +22,8 @@
+ #include "lib/rpmts_internal.h"
+ #include "rpmio/rpmhook.h"
+ 
++#include "lib/rpmplugins.h"
++
+ /* XXX FIXME: merge with existing (broken?) tests in system.h */
+ /* portability fiddles */
+ #if STATFS_IN_SYS_STATVFS
+@@ -1435,12 +1437,43 @@ static int rpmtsProcess(rpmts ts)
+     return rc;
+ }
+ 
++static rpmRC rpmtsSetupTransactionPlugins(rpmts ts)
++{
++    rpmRC rc = RPMRC_OK;
++    char *plugins = NULL, *plugin = NULL;
++    const char *delims = ",";
++
++    plugins = rpmExpand("%{?__transaction_plugins}", NULL);
++    if (!plugins || rstreq(plugins, "")) {
++	goto exit;
++    }
++
++    plugin = strtok(plugins, delims);
++    while(plugin != NULL) {
++	rpmlog(RPMLOG_DEBUG, "plugin is %s\n", plugin);
++	if (!rpmpluginsPluginAdded(ts->plugins, (const char*)plugin)) {
++	    if (rpmpluginsAddPlugin(ts->plugins, "transaction",
++				    (const char*)plugin) == RPMRC_FAIL) {
++		/* any configured plugin failing to load is a failure */
++		rc = RPMRC_FAIL;
++	    }
++	}
++	plugin = strtok(NULL, delims);
++    }
++
++exit:
++    free(plugins);
++    return rc;
++}
++
+ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
+ {
+     int rc = -1; /* assume failure */
+     tsMembers tsmem = rpmtsMembers(ts);
+     rpmlock lock = NULL;
+     rpmps tsprobs = NULL;
++    int TsmPreDone = 0; /* TsmPre hook hasn't been called */
++    
+     /* Force default 022 umask during transaction for consistent results */
+     mode_t oldmask = umask(022);
+ 
+@@ -1462,11 +1495,21 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
+ 	goto exit;
+     }
+ 
++    if (rpmtsSetupTransactionPlugins(ts) == RPMRC_FAIL) {
++	goto exit;
++    }
++
+     rpmtsSetupCollections(ts);
+ 
+     /* Check package set for problems */
+     tsprobs = checkProblems(ts);
+ 
++    /* Run pre transaction hook for all plugins */
++    TsmPreDone = 1;
++    if (rpmpluginsCallTsmPre(ts->plugins, ts) == RPMRC_FAIL) {
++	goto exit;
++    }
++
+     /* Run pre-transaction scripts, but only if there are no known
+      * problems up to this point and not disabled otherwise. */
+     if (!((rpmtsFlags(ts) & (RPMTRANS_FLAG_BUILD_PROBS|RPMTRANS_FLAG_NOPRE))
+@@ -1511,6 +1554,10 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
+     }
+ 
+ exit:
++    /* Run post transaction hook for all plugins */
++    if (TsmPreDone) /* If TsmPre hook has been called, call the TsmPost hook */
++	rpmpluginsCallTsmPost(ts->plugins, ts, rc);
++
+     /* Finish up... */
+     (void) umask(oldmask);
+     (void) rpmtsFinish(ts);
+diff --git a/macros.in b/macros.in
+index 3aaebcd..fb030b5 100644
+--- a/macros.in
++++ b/macros.in
+@@ -1032,6 +1032,9 @@ done \
+ %__collection_sepolicy		%{__plugindir}/sepolicy.so
+ %__collection_sepolicy_flags	1
+ 
++# Transaction plugin macros
++%__transaction_systemd_inhibit	%{__plugindir}/systemd_inhibit.so
++
+ #------------------------------------------------------------------------------
+ # Macros for further automated spec %setup and patch application
+ 
+diff --git a/plugins/Makefile.am b/plugins/Makefile.am
+index a9c962c..0c0a410 100644
+--- a/plugins/Makefile.am
++++ b/plugins/Makefile.am
+@@ -24,3 +24,10 @@ sepolicy_la_LIBADD = $(top_builddir)/lib/librpm.la $(top_builddir)/rpmio/librpmi
+ 
+ plugins_LTLIBRARIES += sepolicy.la
+ endif
++
++if DBUS
++systemd_inhibit_la_SOURCES = systemd_inhibit.c
++systemd_inhibit_la_CPPFLAGS = $(AM_CPPFLAGS) @DBUS_CFLAGS@
++systemd_inhibit_la_LIBADD = $(top_builddir)/lib/librpm.la $(top_builddir)/rpmio/librpmio.la @DBUS_LIBS@
++plugins_LTLIBRARIES += systemd_inhibit.la
++endif
+diff --git a/plugins/plugin.h b/plugins/plugin.h
+index 5156f93..ad4171a 100644
+--- a/plugins/plugin.h
++++ b/plugins/plugin.h
+@@ -7,9 +7,23 @@
+ #include "lib/rpmplugins.h"
+ #include "lib/rpmchroot.h"
+ 
++/* general plugin hooks */
+ rpmRC PLUGINHOOK_INIT_FUNC(rpmts ts, const char * name, const char * opts);
+ rpmRC PLUGINHOOK_CLEANUP_FUNC(void);
++
++/* collection plugin hooks */
+ rpmRC PLUGINHOOK_OPENTE_FUNC(rpmte te);
+ rpmRC PLUGINHOOK_COLL_POST_ANY_FUNC(void);
+ rpmRC PLUGINHOOK_COLL_POST_ADD_FUNC(void);
+ rpmRC PLUGINHOOK_COLL_PRE_REMOVE_FUNC(void);
++
++/* per transaction plugin hooks */
++rpmRC PLUGINHOOK_TSM_PRE_FUNC(rpmts ts);
++rpmRC PLUGINHOOK_TSM_POST_FUNC(rpmts ts, int res);
++
++/* per transaction element plugin hooks */
++rpmRC PLUGINHOOK_PSM_PRE_FUNC(rpmte te);
++rpmRC PLUGINHOOK_PSM_POST_FUNC(rpmte te, int res);
++
++/*per script plugin hooks */
++rpmRC PLUGINHOOK_SCRIPT_SETUP_FUNC(char* path);
+diff --git a/plugins/systemd_inhibit.c b/plugins/systemd_inhibit.c
+new file mode 100644
+index 0000000..e990bec
+--- /dev/null
++++ b/plugins/systemd_inhibit.c
+@@ -0,0 +1,111 @@
++#include <dbus/dbus.h>
++#include <sys/types.h>
++#include <sys/stat.h>
++#include <unistd.h>
++#include <rpm/rpmlog.h>
++#include <rpm/rpmts.h>
++#include "plugin.h"
++
++rpmPluginHook PLUGIN_HOOKS = (
++    PLUGINHOOK_INIT |
++    PLUGINHOOK_CLEANUP |
++    PLUGINHOOK_TSM_PRE |
++    PLUGINHOOK_TSM_POST
++);
++
++static int lock_fd = -1;
++
++rpmRC PLUGINHOOK_INIT_FUNC(rpmts ts, const char *name, const char *opts)
++{
++    struct stat st;
++
++    if (lstat("/run/systemd/system/", &st) == 0) {
++        if (S_ISDIR(st.st_mode)) {
++            return RPMRC_OK;
++        }
++    }
++
++    return RPMRC_NOTFOUND;
++}
++
++rpmRC PLUGINHOOK_CLEANUP_FUNC(void)
++{
++    return RPMRC_OK;
++}
++
++static int inhibit(void)
++{
++    DBusError err;
++    DBusConnection *bus = NULL;
++    DBusMessage *msg = NULL;
++    DBusMessage *reply = NULL;
++    int fd = -1;
++
++    dbus_error_init(&err);
++    bus = dbus_bus_get_private(DBUS_BUS_SYSTEM, &err);
++
++    if (bus) {
++	msg = dbus_message_new_method_call("org.freedesktop.login1",
++					   "/org/freedesktop/login1",
++					   "org.freedesktop.login1.Manager",
++					   "Inhibit");
++    }
++
++    if (msg) {
++	const char *what = "shutdown";
++	const char *mode = "block";
++	const char *who = "RPM";
++	const char *reason = "Transaction running";
++
++	dbus_message_append_args(msg,
++				 DBUS_TYPE_STRING, &what,
++				 DBUS_TYPE_STRING, &who,
++				 DBUS_TYPE_STRING, &reason,
++				 DBUS_TYPE_STRING, &mode,
++				 DBUS_TYPE_INVALID);
++
++	reply = dbus_connection_send_with_reply_and_block(bus, msg, -1, &err);
++	dbus_message_unref(msg);
++    }
++
++    if (reply) {
++	dbus_message_get_args(reply, &err,
++			      DBUS_TYPE_UNIX_FD, &fd,
++			      DBUS_TYPE_INVALID);
++	dbus_message_unref(reply);
++    }
++    
++    if (dbus_error_is_set(&err))
++	dbus_error_free(&err);
++    if (bus)
++	dbus_connection_close(bus);
++
++    return fd;
++}
++
++rpmRC PLUGINHOOK_TSM_PRE_FUNC(rpmts ts)
++{
++    if (rpmtsFlags(ts) & (RPMTRANS_FLAG_TEST|RPMTRANS_FLAG_BUILD_PROBS))
++	return RPMRC_OK;
++
++    lock_fd = inhibit();
++
++    if (lock_fd < 0) {
++	rpmlog(RPMLOG_WARNING,
++	       "Unable to get systemd shutdown inhibition lock\n");
++    } else {
++	rpmlog(RPMLOG_DEBUG, "System shutdown blocked (fd %d)\n", lock_fd);
++    }
++
++    return RPMRC_OK;
++}
++
++rpmRC PLUGINHOOK_TSM_POST_FUNC(rpmts ts, int res)
++{
++    if (lock_fd >= 0) {
++	close(lock_fd);
++	lock_fd = -1;
++	rpmlog(RPMLOG_DEBUG, "System shutdown unblocked\n");
++    }
++    return RPMRC_OK;
++}
diff --git a/SOURCES/rpm-4.8.0-ignore-multiline2.patch b/SOURCES/rpm-4.8.0-ignore-multiline2.patch
new file mode 100644
index 0000000..6992f17
--- /dev/null
+++ b/SOURCES/rpm-4.8.0-ignore-multiline2.patch
@@ -0,0 +1,39 @@
+From 4c621e97776a47c2b4e7f17c1cd2a7961453babf Mon Sep 17 00:00:00 2001
+From: Lubos Kardos <lkardos@redhat.com>
+Date: Wed, 3 Dec 2014 14:01:14 +0100
+Subject: [PATCH] Ignore "use" or "requires" within multi-line print or assign
+ statement
+
+- Now script perl.req ignores "use" and "requires" on lines that are
+  part of printing or assigning multi-line string i. e. string that
+  hasn't starting and ending quote on the same line.
+  (RhBug:1024517)
+---
+ scripts/perl.req | 13 +++++++++++++
+ 1 file changed, 13 insertions(+)
+
+--- rpm-4.8.0/scripts/perl.req.ignore-multiline2
++++ rpm-4.8.0/scripts/perl.req
+@@ -174,6 +174,19 @@ sub process_file {
+         $_ = <FILE>;
+     }
+ 
++    # Skip multiline print and assign statements
++    if ( m/\$\S+\s*=\s*(")([^"\\]|(\\.))*$/ ||
++         m/\$\S+\s*=\s*(')([^'\\]|(\\.))*$/ ||
++         m/print\s+(")([^"\\]|(\\.))*$/ ||
++         m/print\s+(')([^'\\]|(\\.))*$/ ) {
++
++        my $quote = $1;
++        while (<FILE>) {
++          m/^([^\\$quote]|(\\.))*$quote/ && last;
++        }
++        $_ = <FILE>;
++    }
++
+     if (
+ 
+ # ouch could be in a eval, perhaps we do not want these since we catch
+-- 
+1.9.3
+
diff --git a/SOURCES/rpm-4.8.x-error-in-log.patch b/SOURCES/rpm-4.8.x-error-in-log.patch
new file mode 100644
index 0000000..d22abe8
--- /dev/null
+++ b/SOURCES/rpm-4.8.x-error-in-log.patch
@@ -0,0 +1,20 @@
+--- rpm-4.8.0/rpmio/rpmlog.c.error-in-log	2015-02-23 13:18:29.696116399 +0100
++++ rpm-4.8.0/rpmio/rpmlog.c	2015-02-23 13:28:19.630394971 +0100
+@@ -127,10 +127,14 @@
+         break;
+     }
+ 
+-    (void) fputs(rpmlogLevelPrefix(rec->pri), msgout);
++    if (fputs(rpmlogLevelPrefix(rec->pri), msgout) == EOF)
++	perror("Error occurred during writing of a log message");
+ 
+-    (void) fputs(rec->message, msgout);
+-    (void) fflush(msgout);
++    if (fputs(rec->message, msgout) == EOF)
++	perror("Error occurred during writing of a log message");
++
++    if (fflush(msgout) == EOF)
++	perror("Error occurred during writing of a log message");
+ 
+     return (rec->pri <= RPMLOG_CRIT ? RPMLOG_EXIT : 0);
+ }
diff --git a/SOURCES/rpm-4.9.90-armhfp.patch b/SOURCES/rpm-4.9.90-armhfp.patch
index 869ab26..6337d9f 100644
--- a/SOURCES/rpm-4.9.90-armhfp.patch
+++ b/SOURCES/rpm-4.9.90-armhfp.patch
@@ -13,13 +13,15 @@ diff -uNr rpm-4.9.0-orig//macros.in rpm-4.9.0/macros.in
 diff -uNr rpm-4.9.0-orig//rpmrc.in rpm-4.9.0/rpmrc.in
 --- rpm-4.9.0-orig//rpmrc.in	2011-08-05 12:23:04.000000000 -0500
 +++ rpm-4.9.0/rpmrc.in	2011-08-05 12:26:34.000000000 -0500
-@@ -66,6 +66,8 @@
+@@ -66,8 +66,10 @@
  optflags: armv5tejl -O2 -g -march=armv5te
  optflags: armv6l -O2 -g -march=armv6
  optflags: armv7l -O2 -g -march=armv7
 +optflags: armv7hl -O2 -g -march=armv7-a -mfloat-abi=hard -mfpu=vfpv3-d16
 +optflags: armv7hnl -O2 -g -march=armv7-a -mfloat-abi=hard -mfpu=neon
  
+ optflags: m68k -O2 -g -fomit-frame-pointer
+ 
  optflags: atarist -O2 -g -fomit-frame-pointer
  optflags: atariste -O2 -g -fomit-frame-pointer
 @@ -140,6 +142,8 @@
@@ -31,22 +33,26 @@ diff -uNr rpm-4.9.0-orig//rpmrc.in rpm-4.9.0/rpmrc.in
  
  arch_canon:	m68kmint: m68kmint	13
  arch_canon:	atarist: m68kmint	13
-@@ -248,6 +252,8 @@
+@@ -248,8 +252,10 @@
  buildarchtranslate: armv5tejl: armv5tejl
  buildarchtranslate: armv6l: armv6l
  buildarchtranslate: armv7l: armv7l
 +buildarchtranslate: armv7hl: armv7hl
 +buildarchtranslate: armv7hnl: armv7hnl
  
+ buildarchtranslate: m68k: m68k
+ 
  buildarchtranslate: atarist: m68kmint
  buildarchtranslate: atariste: m68kmint
-@@ -336,6 +342,8 @@
+@@ -336,8 +342,10 @@
  arch_compat: armv4tl: armv4l
  arch_compat: armv4l: armv3l
  arch_compat: armv3l: noarch
 +arch_compat: armv7hnl: armv7hl
 +arch_compat: armv7hl: noarch
  
+ arch_compat: m68k: noarch
+ 
  arch_compat: atarist: m68kmint noarch
  arch_compat: atariste: m68kmint noarch
 @@ -441,6 +449,9 @@
diff --git a/SPECS/rpm.spec b/SPECS/rpm.spec
index a8785be..f0e85a0 100644
--- a/SPECS/rpm.spec
+++ b/SPECS/rpm.spec
@@ -5,13 +5,13 @@
 # run internal testsuite?
 %bcond_with check
 # disable plugins initially
-%bcond_with plugins
+%bcond_without plugins
 
 %{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")}
 
 %define rpmhome /usr/lib/rpm
 
-%define rpmver 4.11.1
+%define rpmver 4.11.3
 %define srcver %{rpmver}%{?snapver:-%{snapver}}
 
 %define bdbname libdb
@@ -21,7 +21,7 @@
 Summary: The RPM package management system
 Name: rpm
 Version: %{rpmver}
-Release: %{?snapver:0.%{snapver}.}25%{?dist}
+Release: %{?snapver:0.%{snapver}.}17%{?dist}
 Group: System Environment/Base
 Url: http://www.rpm.org/
 Source0: http://rpm.org/releases/rpm-4.11.x/%{name}-%{srcver}.tar.bz2
@@ -31,6 +31,7 @@ Source1: db-%{bdbver}.tar.gz
 BuildRequires: libdb-devel
 %endif
 Source10: libsymlink.attr
+Source11: rpm
 
 # Fedora specspo is setup differently than what rpm expects, considering
 # this as Fedora-specific patch for now
@@ -44,25 +45,30 @@ Patch5: rpm-4.9.90-armhfp.patch
 Patch6: rpm-4.9.0-armhfp-logic.patch
 
 # Patches already in upstream
-Patch100: rpm-4.11.1-instprefix.patch
-Patch101: rpm-4.11.1-reloc-sanity-check.patch
-Patch102: rpm-4.11.1-caps-doublefree.patch
-Patch103: rpm-4.11.1-empty-lua-script.patch
-Patch104: rpm-4.11.1-headersort.patch
-Patch105: rpm-4.11.1-digests-max.patch
-Patch106: rpm-4.11.x-reset-fileactions.patch
-Patch107: rpm-4.11.1-ppc64le.patch
 Patch108: rpm-4.11.1-libtool-ppc64le.patch
-Patch109: rpm-4.11.1-python-bytecompile-path.patch
 
 # Patches already in upstream but not in 4.11.x branch
 Patch150: rpm-4.11.x-dirlink-verify.patch
+Patch151: rpm-4.11.x-defattr-permissions.patch
+Patch152: rpm-4.8.x-error-in-log.patch
+Patch153: rpm-4.11.x-setperms-setugids-mutual-exclusion.patch
+Patch154: rpm-4.8.0-ignore-multiline2.patch
+Patch155: rpm-4.11.x-deprecate-addsign.patch
+Patch156: rpm-4.11.x-Add-make_build-macro.patch
+Patch157: rpm-4.11.x-color-skipping.patch
+Patch158: rpm-4.11.x-fix-stripping-of-binaries.patch
+Patch159: rpm-4.11.x-fix-debuginfo-creation.patch
+Patch160: rpm-4.11.x-systemd-inhibit.patch
+Patch161: rpm-4.11.x-parametrized-macro-invocations.patch
+Patch162: rpm-4.11.x-broken-pipe.patch
+# Belongs to Patch 161
+Patch163: rpm-4.11.x-Handle-line-continuation.patch
+# Belongs to Patch 160
+Patch164: rpm-4.11.3-Initialize-plugins-based-on-DSO-discovery.patch
 
 # Filter soname dependencies by name
 Patch200: rpm-4.11.x-filter-soname-deps.patch
 Patch201: rpm-4.11.x-do-not-filter-ld64.patch
-Patch202: rpm-4.11.x-64-bit-big-endian.patch
-Patch203: rpm-4.11.x-RPMSIGTAG_LONGSIZE-detection.patch
 
 # These are not yet upstream
 Patch301: rpm-4.6.0-niagara.patch
@@ -83,6 +89,10 @@ Patch310: rpm-4.11.x-CVE-2014-8118.patch
 
 # Temporary Patch to provide support for updates
 Patch400: rpm-4.10.90-rpmlib-filesystem-check.patch
+# Disable plugins
+Patch401: rpm-4.11.3-disable-collection-plugins.patch
+# Remove EVR check
+Patch402: rpm-4.11.3-EVR-validity-check.patch
 
 # Partially GPL/LGPL dual-licensed and some bits with BSD
 # SourceLicense: (GPLv2+ and LGPLv2+ with exceptions) and BSD 
@@ -129,8 +139,15 @@ BuildRequires: libacl-devel%{_isa}
 %if ! %{without xz}
 BuildRequires: xz-devel%{_isa} >= 4.999.8
 %endif
+%if %{with plugins}
+# Required for systemd-inhibit plugin
+BuildRequires: dbus-devel
+%endif
+
 # Only required by sepdebugcrcfix patch
 BuildRequires: binutils-devel
+# Also required as sepdebugcrcfix messes with all the make files
+BuildRequires: automake
 
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
@@ -244,31 +261,45 @@ Requires: crontabs logrotate rpm = %{version}-%{release}
 This package contains a cron job which creates daily logs of installed
 packages on a system.
 
+%if %{with plugins}
+%package plugin-systemd-inhibit
+Summary: Rpm plugin for systemd inhibit functionality
+Group: System Environment/Base
+Requires: rpm-libs%{_isa} = %{version}-%{release}
+
+%description plugin-systemd-inhibit
+%{summary}
+%endif
+
+
 %prep
 %setup -q -n %{name}-%{srcver} %{?with_int_bdb:-a 1}
 %patch2 -p1 -b .fedora-specspo
 %patch3 -p1 -b .no-man-dirs
 %patch4 -p1 -b .use-gpg2
 
-%patch100 -p1 -b .instprefix
-%patch101 -p1 -b .reloc-sanity-check
-%patch102 -p1 -b .caps-doublefree
-%patch103 -p1 -b .empty-lua-script
-%patch104 -p1 -b .headersort
-%patch105 -p1 -b .digests-max
-%patch106 -p1 -b .reset-fileactions
-%patch107 -p1 -b .ppc64le
 %ifarch ppc64le
 %patch108 -p2 -b .ppc64le
 %endif
-%patch109 -p1 -b .python-bytecompile-path
 
 %patch150 -p1 -b .dirlink-verify
+%patch151 -p1 -b .defattr-permissions
+%patch152 -p1 -b .error-in-log
+%patch153 -p1 -b .setperms-setugids
+%patch154 -p1 -b .ignore-multiline2
+%patch155 -p1 -b .deprecate-addsign
+%patch156 -p1 -b .make-build
+%patch157 -p1 -b .skip-color
+%patch158 -p1 -b .strip-binaries
+%patch159 -p1 -b .debuginfo
+%patch160 -p1 -b .systemd-inihibit
+%patch161 -p1 -b .macro-expansion
+%patch162 -p1 -b .broken-pipe
+%patch163 -p1 -b .line-continuation
+%patch164 -p1 -b .plugin-detection
 
 %patch200 -p1 -b .filter-soname-deps
 %patch201 -p1 -b .dont-filter-ld64
-%patch202 -p1 -b .64bit-big-endian
-%patch203 -p1 -b .RPMSIGTAG_LONGSIZE
 
 %patch301 -p1 -b .niagara
 %patch302 -p1 -b .geode
@@ -281,6 +312,8 @@ packages on a system.
 %patch310 -p1 -b .namesize
 
 %patch400 -p1 -b .rpmlib-filesystem-check
+%patch401 -p1 -b .disable-collection-plugins
+%patch402 -p1 -b .remove-EVR-check
 
 %patch5 -p1 -b .armhfp
 # this patch cant be applied on softfp builds
@@ -327,6 +360,9 @@ rm -rf $RPM_BUILD_ROOT
 
 make DESTDIR="$RPM_BUILD_ROOT" install
 
+# remove all plugins except systemd_inhibit
+rm -f ${RPM_BUILD_ROOT}%{_libdir}/rpm-plugins/{exec.so,sepolicy.so}
+
 # Save list of packages through cron
 mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/cron.daily
 install -m 755 scripts/rpm.daily ${RPM_BUILD_ROOT}%{_sysconfdir}/cron.daily/rpm
@@ -341,6 +377,8 @@ mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/rpm
 mkdir -p $RPM_BUILD_ROOT%{rpmhome}/macros.d
 
 install -m 644 %{SOURCE10} ${RPM_BUILD_ROOT}%{rpmhome}/fileattrs/libsymlink.attr
+mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/bash-completion/completions
+install -m 644 %{SOURCE11} ${RPM_BUILD_ROOT}%{_datadir}/bash-completion/completions/rpm
 
 mkdir -p $RPM_BUILD_ROOT/var/lib/rpm
 for dbi in \
@@ -417,6 +455,8 @@ exit 0
 %{_mandir}/man8/rpmkeys.8*
 %{_mandir}/man8/rpm2cpio.8*
 
+%{_datadir}/bash-completion/completions/rpm
+
 # XXX this places translated manuals to wrong package wrt eg rpmbuild
 %lang(fr) %{_mandir}/fr/man[18]/*.[18]*
 %lang(ko) %{_mandir}/ko/man[18]/*.[18]*
@@ -444,8 +484,11 @@ exit 0
 %defattr(-,root,root)
 %{_libdir}/librpmio.so.*
 %{_libdir}/librpm.so.*
+
 %if %{with plugins}
+%files plugin-systemd-inhibit
 %{_libdir}/rpm-plugins
+%{_libdir}/rpm-plugins/systemd_inhibit.so
 %endif
 
 %files build-libs
@@ -507,6 +550,64 @@ exit 0
 %doc COPYING doc/librpm/html/*
 
 %changelog
+* Fri Sep 11 2015 Florian Festi <ffesti@redhat.com> - 4.11.3-17
+- Detect plugins by DSO file name. Needed for #1160401
+
+* Thu Aug 20 2015 Florian Festi <ffesti@redhat.com> - 4.11.3-16
+- Add fix for the fix for #1225118
+
+* Wed Aug 19 2015 Florian Festi <ffesti@redhat.com> - 4.11.3-15
+- Remove incompatible check for multiple separators in version or release
+  (#1250538)
+
+* Wed Aug 19 2015 Florian Festi <ffesti@redhat.com> - 4.11.3-14
+- Enable plugin system but disable collection plugins. Needed for
+  systemd-inhibit plugin (#1160401)
+- Move systemd-inhibit plugin into its own sub packge
+
+* Tue Jul 21 2015 Florian Festi <ffesti@redhat.com> - 4.11.3-13
+- Don't show error message if log function fails because of broken pipe
+ (#1244687)
+
+* Wed Jul 08 2015 Florian Festi <ffesti@redhat.com> - 4.11.3-12
+- Dont eat newlines on parametrized macro invocations (#1225118)
+
+* Tue Jul 07 2015 Florian Festi <ffesti@redhat.com> - 4.11.3-11
+- Back port rpm-plugin-systemd-inhibit (#1160401)
+
+* Thu Jul 02 2015 Florian Festi <ffesti@redhat.com> - 4.11.3-10
+- Fix stripping and debuginfo creation of binaries for changed file output.
+  (#1206312)
+
+* Tue Jun 30 2015 Florian Festi <ffesti@redhat.com> - 4.11.3-9
+- Fix color skipping of multiple files with the same content (#1170119)
+
+* Mon Jun 29 2015 Florian Festi <ffesti@redhat.com> - 4.11.3-8
+- Add %make_build macro for hiding parallel-build magic from specs (#1221357)
+
+* Fri Jun 26 2015 Florian Festi <ffesti@redhat.com> - 4.11.3-7
+- Add deprecation warning to description of --addsign (#1165414)
+
+* Fri Jun 26 2015 Florian Festi <ffesti@redhat.com> - 4.11.3-6
+- Add bash completion (#1183032)
+
+* Fri Jun 26 2015 Florian Festi <ffesti@redhat.com> - 4.11.3-5
+- Fix producing bogus dependencies by perl.req (#1191121)
+
+* Thu Jun 25 2015 Florian Festi <ffesti@redhat.com> - 4.11.3-4
+- Clearly state that --setperms and --setugids are mutually exclusive
+  (#1192000)
+
+* Thu Jun 25 2015 Florian Festi <ffesti@redhat.com> - 4.11.3-3
+- If an error occurs during printing log message then print the error on stderr
+  (#1202753)
+
+* Thu Jun 25 2015 Florian Festi <ffesti@redhat.com> - 4.11.3-2
+- File mode from %%defattr is applied to directories with warning (#1204674)
+
+* Fri Jun 19 2015 Florian Festi <ffesti@redhat.com> - 4.11.3-1
+- Rebase to upstream release 4.11.3 (#1145970)
+
 * Mon Jan 12 2015 Florian Festi <ffesti@redhat.com> - 4.11.1-25
 - Check for malicious CPIO file name size (#1163061)
 - Fixes CVE-2014-8118