diff --git a/auto-config-update-riscv64.diff b/auto-config-update-riscv64.diff
new file mode 100644
index 0000000..38f9940
--- /dev/null
+++ b/auto-config-update-riscv64.diff
@@ -0,0 +1,10 @@
+--- ./build/parseBuildInstallClean.c.orig	2018-02-22 10:11:50.088160024 +0000
++++ ./build/parseBuildInstallClean.c	2018-02-22 10:11:37.592198130 +0000
+@@ -55,6 +55,7 @@ int parseBuildInstallClean(rpmSpec spec,
+             "         grep -q config-patches@ $c || continue\n"
+             "         grep -q aarch64 $c || install -m 755 $ref/config.$s $c\n"
+             "         grep -q ppc64le $c || install -m 755 $ref/config.$s $c\n"
++            "         grep -q 'riscv64[-:]' $c || install -m 755 $ref/config.$s $c\n"
+             "     done\n"
+             "done\n"
+         );
diff --git a/findksyms.diff b/findksyms.diff
index 891a35f..2472f7d 100644
--- a/findksyms.diff
+++ b/findksyms.diff
@@ -1,5 +1,5 @@
---- ./scripts/Makefile.am.orig	2018-01-31 13:08:32.644956731 +0000
-+++ ./scripts/Makefile.am	2018-01-31 13:09:24.081819852 +0000
+--- ./scripts/Makefile.am.orig	2018-02-14 09:42:12.958726157 +0000
++++ ./scripts/Makefile.am	2018-02-14 09:43:26.605515718 +0000
 @@ -19,6 +19,7 @@ EXTRA_DIST = \
  	tgpg vpkg-provides.sh \
  	find-requires find-provides \
@@ -16,9 +16,9 @@
  	metainfo.prov \
  	mono-find-requires mono-find-provides \
  	pkgconfigdeps.sh libtooldeps.sh \
---- ./scripts/find-provides.ksyms.orig	2018-01-31 13:08:40.820934977 +0000
-+++ ./scripts/find-provides.ksyms	2018-01-31 13:08:40.820934977 +0000
-@@ -0,0 +1,60 @@
+--- ./scripts/find-provides.ksyms.orig	2018-02-14 09:42:54.757606752 +0000
++++ ./scripts/find-provides.ksyms	2018-02-14 09:42:39.165651303 +0000
+@@ -0,0 +1,81 @@
 +#! /bin/bash
 +
 +IFS=$'\n'
@@ -40,6 +40,7 @@
 +
 +while read f; do
 +    test -e "$f" || continue
++    is_module=""
 +    case "$f" in
 +    *.debug)
 +        continue
@@ -48,9 +49,11 @@
 +        flavor=${f##*/vmlinu[xz]-}
 +        flavor=${flavor%.gz}
 +        echo "kernel-uname-r = $flavor"
++        version=${flavor}
 +        flavor=${flavor##*-}
 +        ;;
 +    */lib/modules/*/*.ko | */lib/modules/*/*.ko.gz | */boot/vmlinu[xz]*)
++        is_module="1"
 +        ;;
 +    *)
 +        continue
@@ -66,21 +69,39 @@
 +    if $unzip && gzip -cd "$f" >"$tmp"; then
 +        f=$tmp
 +    fi
-+    if test -z "$flavor"; then
++    if test -z "$flavor" -a -n "$is_module" ; then
 +        flavor=$(/sbin/modinfo -F vermagic "$f")
 +        flavor=${flavor%% *}
++        version=${flavor}
 +        flavor=${flavor##*-}
 +    fi
 +    if test -z "$flavor"; then
 +        echo "warning: cannot determine kernel flavor from $(/sbin/modinfo -F vermagic "$f" 2>&1)" >&2
 +        continue
 +    fi
-+    nm "$f" \
-+    | sed -r -ne "s/^0*([0-9a-f]+) A __crc_(.+)/ksym($flavor:\\2) = \\1/p"
++    objdir=$(readlink /lib/modules/$version/build)
++    objdir_build=$RPM_BUILD_ROOT$(readlink $RPM_BUILD_ROOT/lib/modules/$version/build)
++    for i in $objdir_build $objdir ; do
++            ksym_provides=$i/scripts/mod/ksym-provides
++            [ -x $ksym_provides ] && break
++    done
++    if [ -x $ksym_provides ] ; then
++            $ksym_provides $flavor $f
++    else
++            major=${version%%.*}
++            sub=${version#*.}
++            sub=${sub%%.*}
++            if [ "$major" -ge 4 -a "$sub" -ge 10 ] ; then
++                    echo "error: cannot determine ksym provides of $f - missing ksym-povides tool." >&2
++            else
++                    nm "$f" \
++                            | sed -r -ne "s/^0*([0-9a-f]+) A __crc_(.+)/ksym($flavor:\\2) = \\1/p"
++            fi
++    fi
 +done \
 +| sort -u
---- ./scripts/find-requires.ksyms.orig	2018-01-31 13:08:40.821934974 +0000
-+++ ./scripts/find-requires.ksyms	2018-01-31 13:08:40.820934977 +0000
+--- ./scripts/find-requires.ksyms.orig	2018-02-14 09:43:00.437590470 +0000
++++ ./scripts/find-requires.ksyms	2018-02-14 09:42:45.621632854 +0000
 @@ -0,0 +1,29 @@
 +#! /bin/bash
 +
diff --git a/hardlinks.diff b/hardlinks.diff
new file mode 100644
index 0000000..dba3a6b
--- /dev/null
+++ b/hardlinks.diff
@@ -0,0 +1,92 @@
+--- lib/rpmfiles.h.orig
++++ lib/rpmfiles.h
+@@ -156,7 +156,7 @@ typedef rpmFlags rpmfiFlags;
+ 
+ #define RPMFI_FLAGS_ERASE \
+     (RPMFI_NOFILECLASS | RPMFI_NOFILELANGS | \
+-     RPMFI_NOFILEMTIMES | RPMFI_NOFILERDEVS | RPMFI_NOFILEINODES | \
++     RPMFI_NOFILEMTIMES | RPMFI_NOFILERDEVS | \
+      RPMFI_NOFILEVERIFYFLAGS)
+ 
+ #define RPMFI_FLAGS_INSTALL \
+--- lib/transaction.c.orig
++++ lib/transaction.c
+@@ -231,11 +231,11 @@ static void rpmtsUpdateDSI(const rpmts ts, dev_t dev, const char *dirName,
+ 	dsi->bneeded += bneeded;
+ 	dsi->ineeded++;
+ 	if (prevSize) {
+-	    dsi->bdelta += BLOCK_ROUND(prevSize, dsi->bsize);
++	    dsi->bdelta += BLOCK_ROUND(prevSize - 1, dsi->bsize);
+ 	    dsi->idelta++;
+ 	}
+ 	if (fixupSize) {
+-	    dsi->bdelta += BLOCK_ROUND(fixupSize, dsi->bsize);
++	    dsi->bdelta += BLOCK_ROUND(fixupSize - 1, dsi->bsize);
+ 	    dsi->idelta++;
+ 	}
+ 
+@@ -412,6 +412,9 @@ static void handleInstInstalledFile(const rpmts ts, rpmte p, rpmfiles fi, int fx
+ {
+     rpmfs fs = rpmteGetFileStates(p);
+     int isCfgFile = ((rpmfilesFFlags(otherFi, ofx) | rpmfilesFFlags(fi, fx)) & RPMFILE_CONFIG);
++    rpm_loff_t otherFileSize;
++    int nlink;
++    const int *links;
+ 
+     if (XFA_SKIPPING(rpmfsGetAction(fs, fx)))
+ 	return;
+@@ -481,7 +484,15 @@ static void handleInstInstalledFile(const rpmts ts, rpmte p, rpmfiles fi, int fx
+ 	}
+     }
+ 
+-    rpmfilesSetFReplacedSize(fi, fx, rpmfilesFSize(otherFi, ofx));
++    otherFileSize = rpmfilesFSize(otherFi, ofx);
++
++    /* Only account for the last file of a hardlink set */
++    nlink = rpmfilesFLinks(otherFi, ofx, &links);
++    if (nlink > 1 && links[nlink - 1] != ofx)
++	otherFileSize = 0;
++
++    /* Add one to make sure the size is not zero */
++    rpmfilesSetFReplacedSize(fi, fx, otherFileSize + 1);
+ }
+ 
+ /**
+@@ -506,6 +517,9 @@ static void handleOverlappedFiles(rpmts ts, fingerPrintCache fpc, rpmte p, rpmfi
+ 	rpmfileAttrs FFlags;
+ 	struct rpmffi_s * recs;
+ 	int numRecs;
++	rpm_loff_t fileSize;
++	int nlink;
++	const int *links;
+ 
+ 	if (XFA_SKIPPING(rpmfsGetAction(fs, i)))
+ 	    continue;
+@@ -628,7 +642,8 @@ assert(otherFi != NULL);
+ 		break;
+ 
+ 	    /* Try to get the disk accounting correct even if a conflict. */
+-	    fixupSize = rpmfilesFSize(otherFi, otherFileNum);
++	    /* Add one to make sure the size is not zero */
++	    fixupSize = rpmfilesFSize(otherFi, otherFileNum) + 1;
+ 
+ 	    if (rpmfilesConfigConflict(fi, i)) {
+ 		/* Here is an overlapped  pre-existing config file. */
+@@ -675,9 +690,16 @@ assert(otherFi != NULL);
+ 	}
+ 	rpmfilesFree(otherFi);
+ 
++	fileSize = rpmfilesFSize(fi, i);
++	nlink = rpmfilesFLinks(fi, i, &links);
++	if (nlink > 1 && links[nlink - 1] != i) {
++	    /* Only account for the last file of a hardlink set */
++	    fileSize = 0;
++	    fixupSize = fixupSize ? 1 : 0;
++	}
+ 	/* Update disk space info for a file. */
+ 	rpmtsUpdateDSI(ts, fpEntryDev(fpc, fiFps), fpEntryDir(fpc, fiFps),
+-		       rpmfilesFSize(fi, i), rpmfilesFReplacedSize(fi, i),
++		       fileSize, rpmfilesFReplacedSize(fi, i),
+ 		       fixupSize, rpmfsGetAction(fs, i));
+ 
+     }
diff --git a/rpm.changes b/rpm.changes
index e3b532b..d54aec8 100644
--- a/rpm.changes
+++ b/rpm.changes
@@ -1,3 +1,28 @@
+-------------------------------------------------------------------
+Thu Feb 22 11:14:38 CET 2018 - mls@suse.de
+
+- split riscv64 part from auto-config-update-aarch64-ppc64le.diff
+  to make the change rust-proof.
+  new patch: auto-config-update-riscv64.diff
+
+-------------------------------------------------------------------
+Thu Feb 15 11:11:21 UTC 2018 - schwab@suse.de
+
+- auto-config-update-aarch64-ppc64le.diff: Update for riscv64 and enable
+  it there
+
+-------------------------------------------------------------------
+Wed Feb 14 10:45:25 CET 2018 - mls@suse.de
+
+- change disk usage handling to take hardlinks into account
+  [bnc#720150]
+  new patch: hardlinks.diff
+
+-------------------------------------------------------------------
+Wed Feb  7 17:23:48 UTC 2018 - msuchanek@suse.com
+
+- Use ksym-provides tool (bsc#1077692).
+
 -------------------------------------------------------------------
 Wed Feb  7 09:13:41 UTC 2018 - dimstar@opensuse.org
 
diff --git a/rpm.spec b/rpm.spec
index d5b86e9..eb4f96a 100644
--- a/rpm.spec
+++ b/rpm.spec
@@ -130,7 +130,9 @@ Patch103:       find-lang-qt-qm.patch
 Patch108:       debugedit-macro.diff
 Patch109:       pythondistdeps.diff
 Patch111:       debugedit-bnc1076819.diff
+Patch112:       hardlinks.diff
 Patch6464:      auto-config-update-aarch64-ppc64le.diff
+Patch6465:      auto-config-update-riscv64.diff
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 #
 # avoid bootstrapping problem
@@ -226,11 +228,14 @@ rm -f rpmdb/db.h
 %patch                               -P 85
 %patch                   -P 93 -P 94                         -P 99
 %patch -P 100        -P 102 -P 103                             -P 108
-%patch -P 109 -P 111
+%patch -P 109 -P 111 -P 112
 
-%ifarch aarch64 ppc64le
+%ifarch aarch64 ppc64le riscv64
 %patch6464
 %endif
+%ifarch riscv64
+%patch6465
+%endif
 
 cp config.guess config.sub db/dist/
 cp config.guess config.sub beecrypt/
@@ -351,7 +356,7 @@ for i in /usr/share/automake-*/*; do
   fi
 done
 popd
-%ifarch aarch64 ppc64le
+%ifarch aarch64 ppc64le riscv64
 install -m 755 config.guess %{buildroot}/usr/lib/rpm
 install -m 755 config.sub %{buildroot}/usr/lib/rpm
 %endif