diff --git a/.gitignore b/.gitignore
index 8301e32..1cd7cc9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -50,3 +50,4 @@
 /rpm-4.17.0-beta1.tar.bz2
 /rpm-4.17.0-rc1.tar.bz2
 /rpm-4.17.0.tar.bz2
+/rpm-4.18.0-alpha1.tar.bz2
diff --git a/0001-Fix-OpenPGP-key-ID-parsing-regression.patch b/0001-Fix-OpenPGP-key-ID-parsing-regression.patch
new file mode 100644
index 0000000..ad05b37
--- /dev/null
+++ b/0001-Fix-OpenPGP-key-ID-parsing-regression.patch
@@ -0,0 +1,31 @@
+From 329e2ec47f6cd3bc7ecf85abd9f2ab179c59914f Mon Sep 17 00:00:00 2001
+Message-Id: <329e2ec47f6cd3bc7ecf85abd9f2ab179c59914f.1650871821.git.pmatilai@redhat.com>
+From: Demi Marie Obenour <demi@invisiblethingslab.com>
+Date: Thu, 14 Apr 2022 15:38:11 -0400
+Subject: [PATCH] Fix OpenPGP key ID parsing regression
+
+This fixes a regression in 598a771d8b4f4f480d4990ccf59b978d537201dd,
+which caused RPM to parse key flags from a hashed key ID subpacket.  As
+a result, RPM would wrongly reject a signature that had both key ID and
+key usage flags subpackets in the hashed section.
+
+(backported from commit 7f830132fe717d4b31c035bb3d08379451e3cd81)
+---
+ rpmio/rpmpgp.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/rpmio/rpmpgp.c b/rpmio/rpmpgp.c
+index deea65eae..242b34e19 100644
+--- a/rpmio/rpmpgp.c
++++ b/rpmio/rpmpgp.c
+@@ -528,6 +528,7 @@ static int pgpPrtSubType(const uint8_t *h, size_t hlen, pgpSigType sigtype,
+ 		_digp->saved |= PGPDIG_SAVED_ID;
+ 		memcpy(_digp->signid, p+1, sizeof(_digp->signid));
+ 	    }
++	    break;
+ 	case PGPSUBTYPE_KEY_FLAGS: /* Key usage flags */
+ 	    /* Subpackets in the unhashed section cannot be trusted */
+ 	    if (!hashed)
+-- 
+2.35.1
+
diff --git a/0001-Fix-spurious-transfiletriggerpostun-execution-RhBug-.patch b/0001-Fix-spurious-transfiletriggerpostun-execution-RhBug-.patch
deleted file mode 100644
index dc8074f..0000000
--- a/0001-Fix-spurious-transfiletriggerpostun-execution-RhBug-.patch
+++ /dev/null
@@ -1,120 +0,0 @@
-From b3d672a5523dfec033160e5cc866432a0e808649 Mon Sep 17 00:00:00 2001
-Message-Id: <b3d672a5523dfec033160e5cc866432a0e808649.1642160603.git.pmatilai@redhat.com>
-From: Panu Matilainen <pmatilai@redhat.com>
-Date: Tue, 16 Nov 2021 11:49:18 +0200
-Subject: [PATCH] Fix spurious %transfiletriggerpostun execution
- (RhBug:2023311)
-
-If a package has multiple %transfiletriggerpostun triggers, any one
-of them matching would cause all of them to run, due to disconnect
-in the intel gathering stage: we'd gather all the headers with matching
-files into a lump, and then add any postun triggers found in them,
-but this loses the triggering file information and causes all postuns
-to run.
-
-The triggers need to be added while looping over the file matches,
-like runFileTriggers() does. Doing so actually simplifies the code.
-These should really be unified to use the same code, but leaving
-that exercise to another rainy day.
----
- lib/rpmtriggers.c | 64 +++++++++++++++++++++++------------------------
- 1 file changed, 31 insertions(+), 33 deletions(-)
-
-diff --git a/lib/rpmtriggers.c b/lib/rpmtriggers.c
-index d541974e8..6fe4db65d 100644
---- a/lib/rpmtriggers.c
-+++ b/lib/rpmtriggers.c
-@@ -97,19 +97,37 @@ static void rpmtriggersSortAndUniq(rpmtriggers trigs)
-     }
- }
- 
-+static void addTriggers(rpmts ts, Header trigH, rpmsenseFlags filter)
-+{
-+    int tix = 0;
-+    rpmds ds;
-+    rpmds triggers = rpmdsNew(trigH, RPMTAG_TRANSFILETRIGGERNAME, 0);
-+
-+    while ((ds = rpmdsFilterTi(triggers, tix))) {
-+	if ((rpmdsNext(ds) >= 0) && (rpmdsFlags(ds) & filter)) {
-+	    struct rpmtd_s priorities;
-+
-+	    if (headerGet(trigH, RPMTAG_TRANSFILETRIGGERPRIORITIES,
-+			&priorities, HEADERGET_MINMEM)) {
-+		rpmtdSetIndex(&priorities, tix);
-+		rpmtriggersAdd(ts->trigs2run, headerGetInstance(trigH),
-+				tix, *rpmtdGetUint32(&priorities));
-+	    }
-+	}
-+	rpmdsFree(ds);
-+	tix++;
-+    }
-+    rpmdsFree(triggers);
-+}
-+
- void rpmtriggersPrepPostUnTransFileTrigs(rpmts ts, rpmte te)
- {
--    rpmdbMatchIterator mi;
-     rpmdbIndexIterator ii;
--    Header trigH;
-     const void *key;
-     size_t keylen;
-     rpmfiles files;
--    rpmds rpmdsTriggers;
--    rpmds rpmdsTrigger;
- 
-     ii = rpmdbIndexIteratorInit(rpmtsGetRdb(ts), RPMDBI_TRANSFILETRIGGERNAME);
--    mi = rpmdbNewIterator(rpmtsGetRdb(ts), RPMDBI_PACKAGES);
-     files = rpmteFiles(te);
- 
-     /* Iterate over file triggers in rpmdb */
-@@ -121,39 +139,19 @@ void rpmtriggersPrepPostUnTransFileTrigs(rpmts ts, rpmte te)
- 	rpmfi fi = rpmfilesFindPrefix(files, pfx);
- 	while (rpmfiNext(fi) >= 0) {
- 	    if (RPMFILE_IS_INSTALLED(rpmfiFState(fi))) {
--		/* If yes then store it */
--		rpmdbAppendIterator(mi, rpmdbIndexIteratorPkgOffsets(ii),
--				rpmdbIndexIteratorNumPkgs(ii));
--		break;
-+		unsigned int npkg = rpmdbIndexIteratorNumPkgs(ii);
-+		const unsigned int *offs = rpmdbIndexIteratorPkgOffsets(ii);
-+		/* Save any matching postun triggers */
-+		for (int i = 0; i < npkg; i++) {
-+		    Header h = rpmdbGetHeaderAt(rpmtsGetRdb(ts), offs[i]);
-+		    addTriggers(ts, h, RPMSENSE_TRIGGERPOSTUN);
-+		    headerFree(h);
-+		}
- 	    }
- 	}
- 	rpmfiFree(fi);
-     }
-     rpmdbIndexIteratorFree(ii);
--
--    if (rpmdbGetIteratorCount(mi)) {
--	/* Filter triggers and save only trans postun triggers into ts */
--	while ((trigH = rpmdbNextIterator(mi)) != NULL) {
--	    int tix = 0;
--	    rpmdsTriggers = rpmdsNew(trigH, RPMTAG_TRANSFILETRIGGERNAME, 0);
--	    while ((rpmdsTrigger = rpmdsFilterTi(rpmdsTriggers, tix))) {
--		if ((rpmdsNext(rpmdsTrigger) >= 0) &&
--		    (rpmdsFlags(rpmdsTrigger) & RPMSENSE_TRIGGERPOSTUN)) {
--		    struct rpmtd_s priorities;
--
--		    headerGet(trigH, RPMTAG_TRANSFILETRIGGERPRIORITIES,
--				&priorities, HEADERGET_MINMEM);
--		    rpmtdSetIndex(&priorities, tix);
--		    rpmtriggersAdd(ts->trigs2run, rpmdbGetIteratorOffset(mi),
--				    tix, *rpmtdGetUint32(&priorities));
--		}
--		rpmdsFree(rpmdsTrigger);
--		tix++;
--	    }
--	    rpmdsFree(rpmdsTriggers);
--	}
--    }
--    rpmdbFreeIterator(mi);
-     rpmfilesFree(files);
- }
- 
--- 
-2.34.1
-
diff --git a/0001-Really-fix-spurious-transfiletriggerpostun-execution.patch b/0001-Really-fix-spurious-transfiletriggerpostun-execution.patch
deleted file mode 100644
index 72f42b6..0000000
--- a/0001-Really-fix-spurious-transfiletriggerpostun-execution.patch
+++ /dev/null
@@ -1,64 +0,0 @@
-From 2d85f74afc3ccfa584dd8f0981673ff2b06277d1 Mon Sep 17 00:00:00 2001
-Message-Id: <2d85f74afc3ccfa584dd8f0981673ff2b06277d1.1643803240.git.pmatilai@redhat.com>
-From: Panu Matilainen <pmatilai@redhat.com>
-Date: Wed, 2 Feb 2022 13:46:23 +0200
-Subject: [PATCH] Really fix spurious %transfiletriggerpostun execution
- (RhBug:2023311)
-
-Commit b3d672a5523dfec033160e5cc866432a0e808649 got the base reasoning
-in the ballpark but the code all wrong, introducing a severe performance
-regression without actually fixing what it claimed to.
-
-The missing incredient is actually comparing the current prefix with the
-triggers in matched package (trying to describe this makes my head
-spin): a package may have multiple triggers on multiple prefixes and
-we need to make sure we only execute triggers of this type, from this
-prefix.
-
-Fixes: b3d672a5523dfec033160e5cc866432a0e808649
----
- lib/rpmtriggers.c | 11 +++++++----
- 1 file changed, 7 insertions(+), 4 deletions(-)
-
-diff --git a/lib/rpmtriggers.c b/lib/rpmtriggers.c
-index 6fe4db65d..3f8fa22d0 100644
---- a/lib/rpmtriggers.c
-+++ b/lib/rpmtriggers.c
-@@ -97,14 +97,16 @@ static void rpmtriggersSortAndUniq(rpmtriggers trigs)
-     }
- }
- 
--static void addTriggers(rpmts ts, Header trigH, rpmsenseFlags filter)
-+static void addTriggers(rpmts ts, Header trigH, rpmsenseFlags filter,
-+			const char *prefix)
- {
-     int tix = 0;
-     rpmds ds;
-     rpmds triggers = rpmdsNew(trigH, RPMTAG_TRANSFILETRIGGERNAME, 0);
- 
-     while ((ds = rpmdsFilterTi(triggers, tix))) {
--	if ((rpmdsNext(ds) >= 0) && (rpmdsFlags(ds) & filter)) {
-+	if ((rpmdsNext(ds) >= 0) && (rpmdsFlags(ds) & filter) &&
-+		strcmp(prefix, rpmdsN(ds)) == 0) {
- 	    struct rpmtd_s priorities;
- 
- 	    if (headerGet(trigH, RPMTAG_TRANSFILETRIGGERPRIORITIES,
-@@ -141,12 +143,13 @@ void rpmtriggersPrepPostUnTransFileTrigs(rpmts ts, rpmte te)
- 	    if (RPMFILE_IS_INSTALLED(rpmfiFState(fi))) {
- 		unsigned int npkg = rpmdbIndexIteratorNumPkgs(ii);
- 		const unsigned int *offs = rpmdbIndexIteratorPkgOffsets(ii);
--		/* Save any matching postun triggers */
-+		/* Save any postun triggers matching this prefix */
- 		for (int i = 0; i < npkg; i++) {
- 		    Header h = rpmdbGetHeaderAt(rpmtsGetRdb(ts), offs[i]);
--		    addTriggers(ts, h, RPMSENSE_TRIGGERPOSTUN);
-+		    addTriggers(ts, h, RPMSENSE_TRIGGERPOSTUN, pfx);
- 		    headerFree(h);
- 		}
-+		break;
- 	    }
- 	}
- 	rpmfiFree(fi);
--- 
-2.34.1
-
diff --git a/0001-Revert-Fix-shared-colored-files-not-removed-on-erasu.patch b/0001-Revert-Fix-shared-colored-files-not-removed-on-erasu.patch
new file mode 100644
index 0000000..1993ef5
--- /dev/null
+++ b/0001-Revert-Fix-shared-colored-files-not-removed-on-erasu.patch
@@ -0,0 +1,98 @@
+From 474ba1c63e3b790221b21fbd835427146431f874 Mon Sep 17 00:00:00 2001
+Message-Id: <474ba1c63e3b790221b21fbd835427146431f874.1650878284.git.pmatilai@redhat.com>
+From: Panu Matilainen <pmatilai@redhat.com>
+Date: Mon, 25 Apr 2022 12:17:19 +0300
+Subject: [PATCH] Revert "Fix shared colored files not removed on erasure
+ regression in >= 4.14.0"
+
+This causes a worse regression by removing files on update, revert
+for further investigation.
+
+This reverts commit 9e4caf0fc536d1244b298abd9dc4c535b6560d69.
+---
+ lib/transaction.c | 34 +++-------------------------------
+ tests/rpme.at     |  2 ++
+ 2 files changed, 5 insertions(+), 31 deletions(-)
+
+diff --git a/lib/transaction.c b/lib/transaction.c
+index ee3552c48..456c0c6de 100644
+--- a/lib/transaction.c
++++ b/lib/transaction.c
+@@ -516,28 +516,6 @@ static void handleInstInstalledFile(const rpmts ts, rpmte p, rpmfiles fi, int fx
+     }
+ }
+ 
+-static rpmFileAction getSkipAction(rpmfiles files, int i)
+-{
+-    rpmFileAction action = FA_UNKNOWN;
+-
+-    switch (rpmfilesFState(files, i)) {
+-    case RPMFILE_STATE_REPLACED:
+-    case RPMFILE_STATE_NOTINSTALLED:
+-	action = FA_SKIPNSTATE;
+-	break;
+-    case RPMFILE_STATE_NETSHARED:
+-	action = FA_SKIPNETSHARED;
+-	break;
+-    case RPMFILE_STATE_WRONGCOLOR:
+-	action = FA_SKIPCOLOR;
+-	break;
+-    default:
+-	break;
+-    }
+-
+-    return action;
+-}
+-
+ /**
+  * Update disk space needs on each partition for this package's files.
+  */
+@@ -706,22 +684,16 @@ assert(otherFi != NULL);
+                 /* Here is an overlapped added file we don't want to nuke. */
+ 		if (rpmfsGetAction(otherFs, otherFileNum) != FA_ERASE) {
+ 		    /* On updates, don't remove files. */
+-		    if (!getSkipAction(otherFi, otherFileNum)) {
+-			rpmfsSetAction(fs, i, FA_SKIP);
+-			break;
+-		    }
++		    rpmfsSetAction(fs, i, FA_SKIP);
++		    break;
+ 		}
+ 		/* Here is an overlapped removed file: skip in previous. */
+ 		rpmfsSetAction(otherFs, otherFileNum, FA_SKIP);
+ 	    }
+ 	    if (XFA_SKIPPING(rpmfsGetAction(fs, i)))
+ 		break;
+-
+ 	    if (rpmfilesFState(fi, i) != RPMFILE_STATE_NORMAL) {
+-		rpmFileAction skip = getSkipAction(fi, i);
+-		if (skip) {
+-		    rpmfsSetAction(fs, i, skip);
+-		}
++		rpmfsSetAction(fs, i, FA_SKIP);
+ 		break;
+ 	    }
+ 		
+diff --git a/tests/rpme.at b/tests/rpme.at
+index ec73700c3..f46d64a6b 100644
+--- a/tests/rpme.at
++++ b/tests/rpme.at
+@@ -167,6 +167,7 @@ AT_CLEANUP
+ 
+ # Test that shared colored files actually get removed regardless of order 1
+ AT_SETUP([rpm -e and verify colored files removed 2.1])
++AT_XFAIL_IF([test $RPM_XFAIL -ne 0])
+ AT_KEYWORDS([install erase rpmdb])
+ RPMDB_INIT
+ AT_CHECK([
+@@ -191,6 +192,7 @@ AT_CLEANUP
+ 
+ # Test that shared colored files actually get removed regardless of order 2
+ AT_SETUP([rpm -e and verify colored files removed 2.2])
++AT_XFAIL_IF([test $RPM_XFAIL -ne 0])
+ AT_KEYWORDS([install erase rpmdb])
+ RPMDB_INIT
+ AT_CHECK([
+-- 
+2.35.1
+
diff --git a/rpm.spec b/rpm.spec
index 7f56974..a45df0d 100644
--- a/rpm.spec
+++ b/rpm.spec
@@ -28,9 +28,9 @@
 
 %define rpmhome /usr/lib/rpm
 
-%global rpmver 4.17.0
-#global snapver rc1
-%global baserelease 10
+%global rpmver 4.18.0
+%global snapver alpha1
+%global baserelease 1
 %global sover 9
 
 %global srcver %{rpmver}%{?snapver:-%{snapver}}
@@ -56,8 +56,8 @@ Patch1: rpm-4.17.x-siteconfig.patch
 Patch3: rpm-4.9.90-no-man-dirs.patch
 
 # Patches already upstream:
-Patch100: 0001-Fix-spurious-transfiletriggerpostun-execution-RhBug-.patch
-Patch101: 0001-Really-fix-spurious-transfiletriggerpostun-execution.patch
+Patch100: 0001-Fix-OpenPGP-key-ID-parsing-regression.patch
+Patch101: 0001-Revert-Fix-shared-colored-files-not-removed-on-erasu.patch
 
 # These are not yet upstream
 Patch906: rpm-4.7.1-geode-i686.patch
@@ -567,11 +567,13 @@ fi
 %{_bindir}/rpmbuild
 %{_bindir}/gendiff
 %{_bindir}/rpmspec
+%{_bindir}/rpmlua
 
 %{_mandir}/man1/gendiff.1*
 %{_mandir}/man8/rpmbuild.8*
 %{_mandir}/man8/rpmdeps.8*
 %{_mandir}/man8/rpmspec.8*
+%{_mandir}/man8/rpmlua.8*
 
 %{rpmhome}/brp-*
 %{rpmhome}/check-*
@@ -584,6 +586,7 @@ fi
 %{rpmhome}/mkinstalldirs
 %{rpmhome}/fileattrs/*
 %{rpmhome}/find-debuginfo.sh
+%{rpmhome}/rpmuncompress
 
 %files sign
 %{_bindir}/rpmsign
@@ -609,6 +612,10 @@ fi
 %doc docs/librpm/html/*
 
 %changelog
+* Mon Apr 25 2022 Panu Matilainen <pmatilai@redhat.com> - 4.18.0-0.alpha1.1
+- Rebase to 4.18.0 alpha (https://fedoraproject.org/wiki/Changes/RPM-4.18)
+- Add patches for two late discovered regressions
+
 * Mon Mar 21 2022 Neal Gompa <ngompa@fedoraproject.org> - 4.17.0-10
 - Create rpmdb directory symlink in posttrans by default (#2066427)
 
diff --git a/sources b/sources
index 5966020..cc7cdc4 100644
--- a/sources
+++ b/sources
@@ -1 +1 @@
-SHA512 (rpm-4.17.0.tar.bz2) = d32af8649c6d47796a645b6ecbe580df97f5423bfb17414d5ed0016373f5cfab86ebcfad6c480fb8bfafaf3a960f9bc095ef6faad7b40bdb208cc60e4080b0c8
+SHA512 (rpm-4.18.0-alpha1.tar.bz2) = e9d88edc7755543d760cf9273cc015cd1266422da7b57916c8e8abaa8e284c351121da9991a37b88bf335381e02bd85daca94836b57327e6a88bb2a8118eef3e