vim, vim-core: upgraded packages to upstream

Upgraded app-editors/vim to version 8.2.0814-r100 on amd64, arm64
Upgraded app-editors/vim-core to version 8.2.0814 on amd64, arm64

This upgrade does not address the linked vulnerabilities. Upstream does
not have fixes for the linked vulnerabilities yet. I will send a fix to
upstream, but since our vim is pretty far behind, let's get caught up
before upstream releases a new version.

BUG=b/201202353,b/201202221,b/199713966
TEST=sudo emerge vim, run vim --version, emerge-lakitu vim,
emerge-lakitu-arm64 vim
RELEASE_NOTE=Upgraded vim to version 8.2.0814-r100.

Change-Id: I58b9c80d4e3724f47bd331f408329d7719011ebc
Reviewed-on: https://cos-review.googlesource.com/c/third_party/overlays/portage-stable/+/23131
Reviewed-by: Vaibhav Rustagi <vaibhavrustagi@google.com>
Reviewed-by: Sam Kunz <samkunz@google.com>
Tested-by: Cusky Presubmit Bot <presubmit@cos-infra-prod.iam.gserviceaccount.com>
diff --git a/app-editors/vim-core/Manifest b/app-editors/vim-core/Manifest
index 51d665e..9f17c29 100644
--- a/app-editors/vim-core/Manifest
+++ b/app-editors/vim-core/Manifest
@@ -1,2 +1,2 @@
-DIST vim-8.2.0210-gentoo-patches.tar.bz2 2755 BLAKE2B 21f1fb97c95d4f2eb45968783add80e11011be12fd2d701c267644a44da9782214828e022667c1a0a2ed08aedb7c12b6756a8b8adea4db5c7a3cb7dc94b75fd8 SHA512 c942c33dc033d63569e07523fa7652d1c53685aa64f9e7a4bf4e6126012790ec0ec820a7a9209cfe64096679ba8a9f9394ed92696a933e3c8be10658d16b8a7b
-DIST vim-8.2.0360.tar.gz 14842830 BLAKE2B fe3a13cb4bef4ada1bd13cdc80aa9a4ab275d1ff16a7f5308109adc7c5a3459393e1c8153fa32a972141b27cce3aaff50c59416d1ba32e4dca03074be49705a9 SHA512 183bcb5cc73290193de99beb69b56b64efa37db9d905c6e76a51ac727f4447f76346dde632e2dfae9d289abb4b9ca11a14f7e350eaa699fc2c3c7c2e35fc20b2
+DIST vim-8.2.0360-gentoo-patches.tar.xz 2612 BLAKE2B a9273a686b31dd873b25bfc07f7bc254f11038bde275ae4e6f56513a14e0268fdc1032ae847d1d7f8539f8a657217011770ccb4685998f34722383ec7bfb1a15 SHA512 00bc8eb8b20a4a6f3bbd179bb90d42fa6727c8eaae5b625e95e52c33638d456ef36d06b51c542ecaffb237c0b4f7aa72dc3bae7fe00144d55ab0d2fa51950f3b
+DIST vim-8.2.0814.tar.gz 14953478 BLAKE2B fd4155ec749bd9a705e8114ff7f8cc321182c9286733ff2f665e265ec0af830f9e70c730b8d0215f6db1f73a8e2f878d22932a72c8dbfe921591be7adcdaab00 SHA512 4ddd9e2d30719f931cadd1a4de5700736f641f4b074378d9ea1462a90b81975ce8e8c3ca2e3a1e15ac0288824eef5b0f0a3e31482f7637c450c6d7e52c8f40d2
diff --git a/app-editors/vim-core/metadata.xml b/app-editors/vim-core/metadata.xml
index 3979743..841e555 100644
--- a/app-editors/vim-core/metadata.xml
+++ b/app-editors/vim-core/metadata.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
 <pkgmetadata>
 	<maintainer type="project">
 		<email>vim@gentoo.org</email>
diff --git a/app-editors/vim-core/vim-core-8.2.0360.ebuild b/app-editors/vim-core/vim-core-8.2.0814.ebuild
similarity index 97%
rename from app-editors/vim-core/vim-core-8.2.0360.ebuild
rename to app-editors/vim-core/vim-core-8.2.0814.ebuild
index c7276fa..56875ff 100644
--- a/app-editors/vim-core/vim-core-8.2.0360.ebuild
+++ b/app-editors/vim-core/vim-core-8.2.0814.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2020 Gentoo Authors
+# Copyright 1999-2021 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=7
@@ -11,7 +11,7 @@
 	EGIT_CHECKOUT_DIR=${WORKDIR}/vim-${PV}
 else
 	SRC_URI="https://github.com/vim/vim/archive/v${PV}.tar.gz -> vim-${PV}.tar.gz
-		https://dev.gentoo.org/~radhermit/vim/vim-8.2.0210-gentoo-patches.tar.bz2"
+		https://dev.gentoo.org/~zlogene/distfiles/app-editors/vim/vim-8.2.0360-gentoo-patches.tar.xz"
 	KEYWORDS="*"
 fi
 
@@ -77,7 +77,7 @@
 	# which isn't even in the source file being invalid, we'll do some trickery
 	# to make the error never occur. bug 66162 (02 October 2004 ciaranm)
 	find "${S}" -name '*.c' | while read c; do
-	    echo >> "$c" || die "echo failed"
+		echo >> "$c" || die "echo failed"
 	done
 
 	# Try to avoid sandbox problems. Bug #114475.
diff --git a/app-editors/vim/Manifest b/app-editors/vim/Manifest
index 51d665e..9f17c29 100644
--- a/app-editors/vim/Manifest
+++ b/app-editors/vim/Manifest
@@ -1,2 +1,2 @@
-DIST vim-8.2.0210-gentoo-patches.tar.bz2 2755 BLAKE2B 21f1fb97c95d4f2eb45968783add80e11011be12fd2d701c267644a44da9782214828e022667c1a0a2ed08aedb7c12b6756a8b8adea4db5c7a3cb7dc94b75fd8 SHA512 c942c33dc033d63569e07523fa7652d1c53685aa64f9e7a4bf4e6126012790ec0ec820a7a9209cfe64096679ba8a9f9394ed92696a933e3c8be10658d16b8a7b
-DIST vim-8.2.0360.tar.gz 14842830 BLAKE2B fe3a13cb4bef4ada1bd13cdc80aa9a4ab275d1ff16a7f5308109adc7c5a3459393e1c8153fa32a972141b27cce3aaff50c59416d1ba32e4dca03074be49705a9 SHA512 183bcb5cc73290193de99beb69b56b64efa37db9d905c6e76a51ac727f4447f76346dde632e2dfae9d289abb4b9ca11a14f7e350eaa699fc2c3c7c2e35fc20b2
+DIST vim-8.2.0360-gentoo-patches.tar.xz 2612 BLAKE2B a9273a686b31dd873b25bfc07f7bc254f11038bde275ae4e6f56513a14e0268fdc1032ae847d1d7f8539f8a657217011770ccb4685998f34722383ec7bfb1a15 SHA512 00bc8eb8b20a4a6f3bbd179bb90d42fa6727c8eaae5b625e95e52c33638d456ef36d06b51c542ecaffb237c0b4f7aa72dc3bae7fe00144d55ab0d2fa51950f3b
+DIST vim-8.2.0814.tar.gz 14953478 BLAKE2B fd4155ec749bd9a705e8114ff7f8cc321182c9286733ff2f665e265ec0af830f9e70c730b8d0215f6db1f73a8e2f878d22932a72c8dbfe921591be7adcdaab00 SHA512 4ddd9e2d30719f931cadd1a4de5700736f641f4b074378d9ea1462a90b81975ce8e8c3ca2e3a1e15ac0288824eef5b0f0a3e31482f7637c450c6d7e52c8f40d2
diff --git a/app-editors/vim/metadata.xml b/app-editors/vim/metadata.xml
index acc712b..cd2ce2b 100644
--- a/app-editors/vim/metadata.xml
+++ b/app-editors/vim/metadata.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
 <pkgmetadata>
   <maintainer type="project">
     <email>vim@gentoo.org</email>
@@ -7,6 +7,7 @@
   </maintainer>
   <use>
     <flag name="cscope">Enable cscope interface</flag>
+    <flag name="ipv6">Enable IPv6 support in channel</flag>
     <flag name="racket">Enable support for Scheme using <pkg>dev-scheme/racket</pkg></flag>
     <flag name="terminal">Enable terminal emulation support</flag>
     <flag name="vim-pager">Install vimpager and vimmanpager links</flag>
diff --git a/app-editors/vim/vim-8.2.0360.ebuild b/app-editors/vim/vim-8.2.0814-r100.ebuild
similarity index 89%
rename from app-editors/vim/vim-8.2.0360.ebuild
rename to app-editors/vim/vim-8.2.0814-r100.ebuild
index 6ba0302..04a9d49 100644
--- a/app-editors/vim/vim-8.2.0360.ebuild
+++ b/app-editors/vim/vim-8.2.0814-r100.ebuild
@@ -1,20 +1,21 @@
-# Copyright 1999-2020 Gentoo Authors
+# Copyright 1999-2021 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=7
 VIM_VERSION="8.2"
-PYTHON_COMPAT=( python3_{6,7,8} )
+LUA_COMPAT=( lua5-1 luajit )
+PYTHON_COMPAT=( python3_{6..9} )
 PYTHON_REQ_USE="threads(+)"
 USE_RUBY="ruby24 ruby25 ruby26 ruby27"
 
-inherit vim-doc flag-o-matic bash-completion-r1 python-single-r1 ruby-single desktop xdg-utils
+inherit vim-doc flag-o-matic bash-completion-r1 lua-single python-single-r1 ruby-single desktop xdg-utils
 
 if [[ ${PV} == 9999* ]] ; then
 	inherit git-r3
 	EGIT_REPO_URI="https://github.com/vim/vim.git"
 else
 	SRC_URI="https://github.com/vim/vim/archive/v${PV}.tar.gz -> ${P}.tar.gz
-		https://dev.gentoo.org/~radhermit/vim/vim-8.2.0210-gentoo-patches.tar.bz2"
+		https://dev.gentoo.org/~zlogene/distfiles/app-editors/vim/vim-8.2.0360-gentoo-patches.tar.xz"
 	KEYWORDS="*"
 fi
 
@@ -23,8 +24,9 @@
 
 SLOT="0"
 LICENSE="vim"
-IUSE="X acl cscope debug gpm lua luajit minimal nls perl python racket ruby selinux sound tcl terminal vim-pager"
+IUSE="X acl cscope debug gpm lua ipv6 minimal nls perl python racket ruby selinux sound tcl terminal vim-pager"
 REQUIRED_USE="
+	lua? ( ${LUA_REQUIRED_USE} )
 	python? ( ${PYTHON_REQUIRED_USE} )
 	vim-pager? ( !minimal )
 "
@@ -36,9 +38,8 @@
 	acl? ( kernel_linux? ( sys-apps/acl ) )
 	cscope? ( dev-util/cscope )
 	gpm? ( >=sys-libs/gpm-1.19.3 )
-	lua? (
-		luajit? ( dev-lang/luajit:2= )
-		!luajit? ( dev-lang/lua:0[deprecated] )
+	lua? ( ${LUA_DEPS}
+		$(lua_gen_impl_dep 'deprecated' lua5-1)
 	)
 	!minimal? ( ~app-editors/vim-core-${PV} )
 	vim-pager? ( app-editors/vim-core[-minimal] )
@@ -57,6 +58,8 @@
 	sys-devel/autoconf
 	nls? ( sys-devel/gettext )
 "
+# configure runs the Lua interpreter
+BDEPEND="lua? ( ${LUA_DEPS} )"
 
 pkg_setup() {
 	# people with broken alphabets run into trouble. bug 82186.
@@ -67,6 +70,7 @@
 	mkdir -p "${T}"/home || die "mkdir failed"
 	export HOME="${T}"/home
 
+	use lua && lua-single_pkg_setup
 	use python && python-single-r1_pkg_setup
 }
 
@@ -110,7 +114,7 @@
 	# which isn't even in the source file being invalid, we'll do some trickery
 	# to make the error never occur. bug 66162 (02 October 2004 ciaranm)
 	find "${S}" -name '*.c' | while read c; do
-	    echo >> "$c" || die "echo failed"
+		echo >> "$c" || die "echo failed"
 	done
 
 	# conditionally make the manpager.sh script
@@ -198,13 +202,10 @@
 			$(use_enable acl)
 			$(use_enable cscope)
 			$(use_enable gpm)
-			$(use_enable lua luainterp)
-			$(usex lua "--with-lua-prefix=${EPREFIX}/usr" "")
-			$(use_with luajit)
 			$(use_enable nls)
 			$(use_enable perl perlinterp)
 			$(use_enable python python3interp)
-			$(use_with python python3-command $(type -P $(eselect python show --python3)))
+			$(use_with python python3-command "${PYTHON}")
 			$(use_enable racket mzschemeinterp)
 			$(use_enable ruby rubyinterp)
 			$(use_enable selinux)
@@ -219,6 +220,20 @@
 				'/# define FEAT_CSCOPE/d' src/feature.h || die "sed failed"
 		fi
 
+		if use lua; then
+			myconf+=(
+				--enable-luainterp
+				$(use_with lua_single_target_luajit luajit)
+				--with-lua-prefix="${EPREFIX}/usr"
+			)
+		fi
+
+		if ! use ipv6; then
+			myconf+=(
+				vim_cv_ipv6_networking=no
+			)
+		fi
+
 		# don't test USE=X here ... see bug #19115
 		# but need to provide a way to link against X ... see bug #20093
 		myconf+=(
@@ -276,7 +291,9 @@
 	# Note: Do not install symlinks for 'vi', 'ex', or 'view', as these are
 	#       managed by eselect-vi
 	dobin src/vim
-	dosym vim /usr/bin/vimdiff
+	if ! use minimal ; then
+		dosym vim /usr/bin/vimdiff
+	fi
 	dosym vim /usr/bin/rvim
 	dosym vim /usr/bin/rview
 	if use vim-pager ; then
diff --git a/eclass/eapi8-dosym.eclass b/eclass/eapi8-dosym.eclass
new file mode 100644
index 0000000..52f0ffe
--- /dev/null
+++ b/eclass/eapi8-dosym.eclass
@@ -0,0 +1,108 @@
+# Copyright 2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: eapi8-dosym.eclass
+# @MAINTAINER:
+# PMS team <pms@gentoo.org>
+# @AUTHOR:
+# Ulrich Müller <ulm@gentoo.org>
+# @SUPPORTED_EAPIS: 5 6 7
+# @BLURB: Testing implementation of EAPI 8 dosym -r option
+# @DESCRIPTION:
+# A stand-alone implementation of the dosym command aimed for EAPI 8.
+# Intended to be used for wider testing of the proposed option and to
+# allow ebuilds to switch to the new model early, with minimal change
+# needed for actual EAPI 8.
+#
+# https://bugs.gentoo.org/708360
+
+case ${EAPI} in
+	5|6|7) ;;
+	*) die "${ECLASS}: EAPI=${EAPI:-0} not supported" ;;
+esac
+
+# @FUNCTION: _dosym8_canonicalize
+# @USAGE: <path>
+# @INTERNAL
+# @DESCRIPTION:
+# Transparent bash-only replacement for GNU "realpath -m -s".
+# Resolve references to "/./", "/../" and remove extra "/" characters
+# from <path>, without touching any actual file.
+_dosym8_canonicalize() {
+	local path slash i prev out IFS=/
+
+	path=( $1 )
+	[[ $1 == /* ]] && slash=/
+
+	while true; do
+		# Find first instance of non-".." path component followed by "..",
+		# or as a special case, "/.." at the beginning of the path.
+		# Also drop empty and "." path components as we go along.
+		prev=
+		for i in ${!path[@]}; do
+			if [[ -z ${path[i]} || ${path[i]} == . ]]; then
+				unset "path[i]"
+			elif [[ ${path[i]} != .. ]]; then
+				prev=${i}
+			elif [[ ${prev} || ${slash} ]]; then
+				# Found, remove path components and reiterate
+				[[ ${prev} ]] && unset "path[prev]"
+				unset "path[i]"
+				continue 2
+			fi
+		done
+		# No (further) instance found, so we're done
+		break
+	done
+
+	out="${slash}${path[*]}"
+	echo "${out:-.}"
+}
+
+# @FUNCTION: dosym8
+# @USAGE: [-r] <target> <link>
+# @DESCRIPTION:
+# Create a symbolic link <link>, pointing to <target>.  If the
+# directory containing the new link does not exist, create it.
+#
+# If called with option -r, expand <target> relative to the apparent
+# path of the directory containing <link>.  For example, "dosym8 -r
+# /bin/foo /usr/bin/foo" will create a link named "../../bin/foo".
+dosym8() {
+	local option_r
+
+	case $1 in
+		-r) option_r=t; shift ;;
+	esac
+
+	[[ $# -eq 2 ]] || die "${FUNCNAME}: bad number of arguments"
+
+	local target=$1 link=$2
+
+	if [[ ${option_r} ]]; then
+		local linkdir comp
+
+		# Expansion makes sense only for an absolute target path
+		[[ ${target} == /* ]] \
+			|| die "${FUNCNAME}: -r specified but no absolute target path"
+
+		target=$(_dosym8_canonicalize "${target}")
+		linkdir=$(_dosym8_canonicalize "/${link#/}")
+		linkdir=${linkdir%/*}	# poor man's dirname(1)
+		linkdir=${linkdir:-/}	# always keep the initial "/"
+
+		local ifs_save=${IFS-$' \t\n'} IFS=/
+		for comp in ${linkdir}; do
+			if [[ ${target%%/*} == "${comp}" ]]; then
+				target=${target#"${comp}"}
+				target=${target#/}
+			else
+				target=..${target:+/}${target}
+			fi
+		done
+		IFS=${ifs_save}
+		target=${target:-.}
+	fi
+
+	dosym "${target}" "${link}"
+}
diff --git a/eclass/lua-single.eclass b/eclass/lua-single.eclass
new file mode 100644
index 0000000..2f4ebaa
--- /dev/null
+++ b/eclass/lua-single.eclass
@@ -0,0 +1,536 @@
+# Copyright 1999-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: lua-single.eclass
+# @MAINTAINER:
+# William Hubbs <williamh@gentoo.org>
+# Marek Szuba <marecki@gentoo.org>
+# @AUTHOR:
+# Marek Szuba <marecki@gentoo.org>
+# Based on python-single-r1.eclass by Michał Górny <mgorny@gentoo.org> et al.
+# @SUPPORTED_EAPIS: 7 8
+# @PROVIDES: lua-utils
+# @BLURB: An eclass for Lua packages not installed for multiple implementations.
+# @DESCRIPTION:
+# An extension of lua.eclass suite for packages which don't support being
+# installed for multiple Lua implementations. This mostly includes software
+# embedding Lua.
+#
+# This eclass sets correct IUSE.  It also provides LUA_DEPS
+# and LUA_REQUIRED_USE that need to be added to appropriate ebuild
+# metadata variables.
+#
+# The eclass exports LUA_SINGLE_USEDEP that is suitable for depending
+# on other packages using the eclass.  Dependencies on packages using
+# lua.eclass should be created via lua_gen_cond_dep() function, using
+# LUA_USEDEP placeholder.
+#
+# Please note that packages support multiple Lua implementations
+# (using lua.eclass) cannot depend on packages not supporting
+# them (using this eclass).
+#
+# Note that since this eclass always inherits lua-utils as well, in ebuilds
+# using the former there is no need to explicitly inherit the latter in order
+# to use helper functions such as lua_get_CFLAGS.
+#
+# @EXAMPLE:
+# @CODE
+# EAPI=8
+#
+# LUA_COMPAT=( lua5-{3..4} )
+#
+# inherit lua-single
+#
+# [...]
+#
+# REQUIRED_USE="${LUA_REQUIRED_USE}"
+# DEPEND="${LUA_DEPS}"
+# RDEPEND="${DEPEND}
+#     $(lua_gen_cond_dep '
+#         dev-lua/foo[${LUA_USEDEP}]
+#     ')
+# "
+# BDEPEND="virtual/pkgconfig"
+#
+# # Only neeed if the setup phase has to do more than just call lua-single_pkg_setup
+# pkg_setup() {
+#     lua-single_pkg_setup
+#     [...]
+# }
+#
+# src_install() {
+#     emake LUA_VERSION="$(lua_get_version)" install
+# }
+# @CODE
+
+case ${EAPI} in
+	7|8)
+		;;
+	*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
+esac
+
+if [[ ! ${_LUA_SINGLE_R0} ]]; then
+
+if [[ ${_LUA_R0} ]]; then
+	die 'lua-single.eclass cannot be used with lua.eclass.'
+fi
+
+inherit lua-utils
+
+fi
+
+EXPORT_FUNCTIONS pkg_setup
+
+# @ECLASS-VARIABLE: LUA_COMPAT
+# @REQUIRED
+# @PRE_INHERIT
+# @DESCRIPTION:
+# This variable contains a list of Lua implementations the package
+# supports. It must be set before the `inherit' call. It has to be
+# an array.
+#
+# Example:
+# @CODE
+# LUA_COMPAT=( lua5-1 lua5-3 lua5-4 )
+# @CODE
+#
+# Please note that you can also use bash brace expansion if you like:
+# @CODE
+# LUA_COMPAT=( lua5-{1..3} )
+# @CODE
+
+# @ECLASS-VARIABLE: LUA_COMPAT_OVERRIDE
+# @USER_VARIABLE
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# This variable can be used when working with ebuilds to override
+# the in-ebuild LUA_COMPAT. It is a string listing all
+# the implementations which package will be built for. It need be
+# specified in the calling environment, and not in ebuilds.
+#
+# It should be noted that in order to preserve metadata immutability,
+# LUA_COMPAT_OVERRIDE does not affect IUSE nor dependencies.
+# The state of LUA_TARGETS is ignored, and all the implementations
+# in LUA_COMPAT_OVERRIDE are built. Dependencies need to be satisfied
+# manually.
+#
+# Example:
+# @CODE
+# LUA_COMPAT_OVERRIDE='luajit' emerge -1v dev-lua/foo
+# @CODE
+
+# @ECLASS-VARIABLE: LUA_REQ_USE
+# @DEFAULT_UNSET
+# @PRE_INHERIT
+# @DESCRIPTION:
+# The list of USE flags required to be enabled on the chosen Lua
+# implementations, formed as a USE-dependency string. It should be valid
+# for all implementations in LUA_COMPAT, so it may be necessary to
+# use USE defaults.
+# This must be set before calling `inherit'.
+#
+# Example:
+# @CODE
+# LUA_REQ_USE="deprecated"
+# @CODE
+#
+# It will cause the Lua dependencies to look like:
+# @CODE
+# lua_targets_luaX-Y? ( dev-lang/lua:X.Y[deprecated] )
+# @CODE
+
+# @ECLASS-VARIABLE: LUA_DEPS
+# @OUTPUT_VARIABLE
+# @DESCRIPTION:
+# This is an eclass-generated Lua dependency string for all
+# implementations listed in LUA_COMPAT.
+#
+# Example use:
+# @CODE
+# RDEPEND="${LUA_DEPS}
+#     dev-foo/mydep"
+# DEPEND="${RDEPEND}"
+# @CODE
+#
+# Example value:
+# @CODE
+# lua_targets_lua5-1? ( dev-lang/lua:5.1 )
+# lua_targets_lua5-3? ( dev-lang/lua:5.3 )
+# @CODE
+
+# @ECLASS-VARIABLE: LUA_REQUIRED_USE
+# @OUTPUT_VARIABLE
+# @DESCRIPTION:
+# This is an eclass-generated required-use expression which ensures at
+# least one Lua implementation has been enabled.
+#
+# This expression should be utilized in an ebuild by including it in
+# REQUIRED_USE, optionally behind a use flag.
+#
+# Example use:
+# @CODE
+# REQUIRED_USE="lua? ( ${LUA_REQUIRED_USE} )"
+# @CODE
+#
+# Example value:
+# @CODE
+# || ( lua_targets_lua5-1 lua_targets_lua5-3 )
+# @CODE
+
+# @ECLASS-VARIABLE: LUA_SINGLE_USEDEP
+# @OUTPUT_VARIABLE
+# @DESCRIPTION:
+# This is an eclass-generated USE-dependency string which can be used
+# to depend on another lua-single package being built for the same
+# Lua implementations.
+#
+# If you need to depend on a multi-impl (lua.eclass) package, use
+# lua_gen_cond_dep with LUA_USEDEP placeholder instead.
+#
+# Example use:
+# @CODE
+# RDEPEND="dev-lua/foo[${LUA_SINGLE_USEDEP}]"
+# @CODE
+#
+# Example value:
+# @CODE
+# lua_single_target_lua5-1(-)?
+# @CODE
+
+# @ECLASS-VARIABLE: LUA_USEDEP
+# @OUTPUT_VARIABLE
+# @DESCRIPTION:
+# This is an eclass-generated USE-dependency string which can be used to
+# depend on another Lua package being built for the same Lua
+# implementations.
+#
+# Example use:
+# @CODE
+# RDEPEND="dev-lua/foo[${LUA_USEDEP}]"
+# @CODE
+#
+# Example value:
+# @CODE
+# lua_targets_lua5-1(-)?,lua_targets_lua5-3(-)?
+# @CODE
+
+# @FUNCTION: _lua_single_set_globals
+# @INTERNAL
+# @DESCRIPTION:
+# Sets all the global output variables provided by this eclass.
+# This function must be called once, in global scope.
+_lua_single_set_globals() {
+	_lua_set_impls
+
+	local flags=( "${_LUA_SUPPORTED_IMPLS[@]/#/lua_single_target_}" )
+
+	if [[ ${#_LUA_SUPPORTED_IMPLS[@]} -eq 1 ]]; then
+		# if only one implementation is supported, use IUSE defaults
+		# to avoid requesting the user to enable it
+		IUSE="+${flags[0]}"
+	else
+		IUSE="${flags[*]}"
+	fi
+
+	local requse="^^ ( ${flags[*]} )"
+	local single_flags="${flags[@]/%/(-)?}"
+	local single_usedep=${single_flags// /,}
+
+	local deps= i LUA_PKG_DEP
+	for i in "${_LUA_SUPPORTED_IMPLS[@]}"; do
+		_lua_export "${i}" LUA_PKG_DEP
+		deps+="lua_single_target_${i}? ( ${LUA_PKG_DEP} ) "
+	done
+
+	if [[ ${LUA_DEPS+1} ]]; then
+		if [[ ${LUA_DEPS} != "${deps}" ]]; then
+			eerror "LUA_DEPS have changed between inherits (LUA_REQ_USE?)!"
+			eerror "Before: ${LUA_DEPS}"
+			eerror "Now   : ${deps}"
+			die "LUA_DEPS integrity check failed"
+		fi
+
+		# these two are formality -- they depend on LUA_COMPAT only
+		if [[ ${LUA_REQUIRED_USE} != ${requse} ]]; then
+			eerror "LUA_REQUIRED_USE have changed between inherits!"
+			eerror "Before: ${LUA_REQUIRED_USE}"
+			eerror "Now   : ${requse}"
+			die "LUA_REQUIRED_USE integrity check failed"
+		fi
+
+		if [[ ${LUA_SINGLE_USEDEP} != "${single_usedep}" ]]; then
+			eerror "LUA_SINGLE_USEDEP have changed between inherits!"
+			eerror "Before: ${LUA_SINGLE_USEDEP}"
+			eerror "Now   : ${single_usedep}"
+			die "LUA_SINGLE_USEDEP integrity check failed"
+		fi
+	else
+		LUA_DEPS=${deps}
+		LUA_REQUIRED_USE=${requse}
+		LUA_SINGLE_USEDEP=${single_usedep}
+		LUA_USEDEP='%LUA_USEDEP-NEEDS-TO-BE-USED-IN-LUA_GEN_COND_DEP%'
+		readonly LUA_DEPS LUA_REQUIRED_USE LUA_SINGLE_USEDEP LUA_USEDEP
+	fi
+}
+
+_lua_single_set_globals
+unset -f _lua_single_set_globals
+
+if [[ ! ${_LUA_SINGLE_R0} ]]; then
+
+# @FUNCTION: _lua_gen_usedep
+# @USAGE: [<pattern>...]
+# @INTERNAL
+# @DESCRIPTION:
+# Output a USE dependency string for Lua implementations which
+# are both in LUA_COMPAT and match any of the patterns passed
+# as parameters to the function.
+#
+# The patterns can be fnmatch-style patterns (matched via bash == operator
+# against LUA_COMPAT values). Remember to escape or quote the fnmatch
+# patterns to prevent accidental shell filename expansion.
+#
+# This is an internal function used to implement lua_gen_cond_dep.
+_lua_gen_usedep() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	local impl matches=()
+
+	_lua_verify_patterns "${@}"
+	for impl in "${_LUA_SUPPORTED_IMPLS[@]}"; do
+		if _lua_impl_matches "${impl}" "${@}"; then
+			matches+=(
+				"lua_single_target_${impl}(-)?"
+			)
+		fi
+	done
+
+	[[ ${matches[@]} ]] || die "No supported implementations match lua_gen_usedep patterns: ${@}"
+
+	local out=${matches[@]}
+	echo "${out// /,}"
+}
+
+# @FUNCTION: _lua_impl_matches
+# @USAGE: <impl> [<pattern>...]
+# @INTERNAL
+# @DESCRIPTION:
+# Check whether the specified <impl> matches at least one
+# of the patterns following it. Return 0 if it does, 1 otherwise.
+# Matches if no patterns are provided.
+#
+# <impl> can be in LUA_COMPAT or ELUA form. The patterns can be
+# fnmatch-style patterns, e.g. 'lua5*', '..
+_lua_impl_matches() {
+	[[ ${#} -ge 1 ]] || die "${FUNCNAME}: takes at least 1 parameter"
+	[[ ${#} -eq 1 ]] && return 0
+
+	local impl=${1} pattern
+	shift
+
+	for pattern; do
+		# unify value style to allow lax matching
+		if [[ ${impl/./-} == ${pattern/./-} ]]; then
+			return 0
+		fi
+	done
+
+	return 1
+}
+
+# @FUNCTION: _lua_verify_patterns
+# @USAGE: <pattern>...
+# @INTERNAL
+# @DESCRIPTION:
+# Verify whether the patterns passed to the eclass function are correct
+# (i.e. can match any valid implementation).  Dies on wrong pattern.
+_lua_verify_patterns() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	local impl pattern
+	for pattern; do
+		for impl in "${_LUA_ALL_IMPLS[@]}" "${_LUA_HISTORICAL_IMPLS[@]}"; do
+			[[ ${impl} == ${pattern/./-} ]] && continue 2
+		done
+
+		die "Invalid implementation pattern: ${pattern}"
+	done
+}
+
+# @FUNCTION: lua_gen_cond_dep
+# @USAGE: <dependency> [<pattern>...]
+# @DESCRIPTION:
+# Output a list of <dependency>-ies made conditional to USE flags
+# of Lua implementations which are both in LUA_COMPAT and match
+# any of the patterns passed as the remaining parameters.
+#
+# The patterns can be fnmatch-style patterns (matched via bash == operator
+# against LUA_COMPAT values). Remember to escape or quote the fnmatch
+# patterns to prevent accidental shell filename expansion.
+#
+# In order to enforce USE constraints on the packages, verbatim
+# '${LUA_SINGLE_USEDEP}' and '${LUA_USEDEP}' (quoted!) may
+# be placed in the dependency specification. It will get expanded within
+# the function into a proper USE dependency string.
+#
+# Example:
+# @CODE
+# LUA_COMPAT=( lua5-{1..3} )
+# RDEPEND="$(lua_gen_cond_dep \
+#     'dev-lua/backported_core_module[${LUA_USEDEP}]' lua5-1 lua5-3 )"
+# @CODE
+#
+# It will cause the variable to look like:
+# @CODE
+# RDEPEND="lua_single_target_lua5-1? (
+#     dev-lua/backported_core_module[lua_targets_lua5-1(-)?,...] )
+#	lua_single_target_lua5-3? (
+#     dev-lua/backported_core_module[lua_targets_lua5-3(-)?,...] )"
+# @CODE
+lua_gen_cond_dep() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	local impl matches=()
+
+	local dep=${1}
+	shift
+
+	_lua_verify_patterns "${@}"
+	for impl in "${_LUA_SUPPORTED_IMPLS[@]}"; do
+		if _lua_impl_matches "${impl}" "${@}"; then
+			# substitute ${LUA_SINGLE_USEDEP} if used
+			# (since lua_gen_usedep() will not return
+			#  ${LUA_SINGLE_USEDEP}, the code is run at most once)
+			if [[ ${dep} == *'${LUA_SINGLE_USEDEP}'* ]]; then
+				local usedep=$(_lua_gen_usedep "${@}")
+				dep=${dep//\$\{LUA_SINGLE_USEDEP\}/${usedep}}
+			fi
+			local multi_usedep="lua_targets_${impl}(-)"
+
+			local subdep=${dep//\$\{LUA_MULTI_USEDEP\}/${multi_usedep}}
+			matches+=( "lua_single_target_${impl}? (
+				${subdep//\$\{LUA_USEDEP\}/${multi_usedep}} )" )
+		fi
+	done
+
+	echo "${matches[@]}"
+}
+
+# @FUNCTION: lua_gen_impl_dep
+# @USAGE: [<requested-use-flags> [<impl-pattern>...]]
+# @DESCRIPTION:
+# Output a dependency on Lua implementations with the specified USE
+# dependency string appended, or no USE dependency string if called
+# without the argument (or with empty argument). If any implementation
+# patterns are passed, the output dependencies will be generated only
+# for the implementations matching them.
+#
+# The patterns can be fnmatch-style patterns (matched via bash == operator
+# against LUA_COMPAT values). Remember to escape or quote the fnmatch
+# patterns to prevent accidental shell filename expansion.
+#
+# Use this function when you need to request different USE flags
+# on the Lua interpreter depending on package's USE flags. If you
+# only need a single set of interpreter USE flags, just set
+# LUA_REQ_USE and use ${LUA_DEPS} globally.
+#
+# Example:
+# @CODE
+# LUA_COMPAT=( lua5-{1..3} )
+# RDEPEND="foo? ( $(lua_gen_impl_dep 'deprecated(+)' lua5-4 ) )"
+# @CODE
+#
+# It will cause the variable to look like:
+# @CODE
+# RDEPEND="foo? (
+#	lua_single_target_lua5-4? ( dev-lang/lua:5.3[deprecated(+)] )
+# )"
+# @CODE
+lua_gen_impl_dep() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	local impl
+	local matches=()
+
+	local LUA_REQ_USE=${1}
+	shift
+
+	_lua_verify_patterns "${@}"
+	for impl in "${_LUA_SUPPORTED_IMPLS[@]}"; do
+		if _lua_impl_matches "${impl}" "${@}"; then
+			local LUA_PKG_DEP
+			_lua_export "${impl}" LUA_PKG_DEP
+			matches+=( "lua_single_target_${impl}? ( ${LUA_PKG_DEP} )" )
+		fi
+	done
+
+	echo "${matches[@]}"
+}
+
+# @FUNCTION: lua_setup
+# @DESCRIPTION:
+# Determine what the selected Lua implementation is and set
+# the Lua build environment up for it.
+lua_setup() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	unset ELUA
+
+	# support developer override
+	if [[ ${LUA_COMPAT_OVERRIDE} ]]; then
+		local impls=( ${LUA_COMPAT_OVERRIDE} )
+		[[ ${#impls[@]} -eq 1 ]] || die "LUA_COMPAT_OVERRIDE must name exactly one implementation for lua-single"
+
+		ewarn "WARNING: LUA_COMPAT_OVERRIDE in effect. The following Lua"
+		ewarn "implementation will be used:"
+		ewarn
+		ewarn "	${LUA_COMPAT_OVERRIDE}"
+		ewarn
+		ewarn "Dependencies won't be satisfied, and LUA_SINGLE_TARGET flags will be ignored."
+
+		_lua_export "${impls[0]}" ELUA LUA
+		_lua_wrapper_setup
+		einfo "Using ${ELUA} to build"
+		return
+	fi
+
+	local impl
+	for impl in "${_LUA_SUPPORTED_IMPLS[@]}"; do
+		if use "lua_single_target_${impl}"; then
+			if [[ ${ELUA} ]]; then
+				eerror "Your LUA_SINGLE_TARGET setting lists more than a single Lua"
+				eerror "implementation. Please set it to just one value. If you need"
+				eerror "to override the value for a single package, please use package.env"
+				eerror "or an equivalent solution (man 5 portage)."
+				echo
+				die "More than one implementation in LUA_SINGLE_TARGET."
+			fi
+
+			_lua_export "${impl}" ELUA LUA
+			_lua_wrapper_setup
+			einfo "Using ${ELUA} to build"
+		fi
+	done
+
+	if [[ ! ${ELUA} ]]; then
+		eerror "No Lua implementation selected for the build. Please set"
+		eerror "the LUA_SINGLE_TARGET variable in your make.conf to one"
+		eerror "of the following values:"
+		eerror
+		eerror "${_LUA_SUPPORTED_IMPLS[@]}"
+		echo
+		die "No supported Lua implementation in LUA_SINGLE_TARGET."
+	fi
+}
+
+# @FUNCTION: lua-single_pkg_setup
+# @DESCRIPTION:
+# Runs lua_setup.
+lua-single_pkg_setup() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	[[ ${MERGE_TYPE} != binary ]] && lua_setup
+}
+
+_LUA_SINGLE_R0=1
+fi
diff --git a/eclass/lua-utils.eclass b/eclass/lua-utils.eclass
new file mode 100644
index 0000000..3b24f38
--- /dev/null
+++ b/eclass/lua-utils.eclass
@@ -0,0 +1,540 @@
+# Copyright 1999-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: lua-utils.eclass
+# @MAINTAINER:
+# William Hubbs <williamh@gentoo.org>
+# Marek Szuba <marecki@gentoo.org>
+# @AUTHOR:
+# Marek Szuba <marecki@gentoo.org>
+# Based on python-utils-r1.eclass by Michał Górny <mgorny@gentoo.org> et al.
+# @SUPPORTED_EAPIS: 7 8
+# @BLURB: Utility functions for packages with Lua parts
+# @DESCRIPTION:
+# A utility eclass providing functions to query Lua implementations,
+# install Lua modules and scripts.
+#
+# This eclass neither sets any metadata variables nor exports any phase
+# functions. It can be inherited safely.
+
+case ${EAPI} in
+	7|8)
+		;;
+	*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
+esac
+
+if [[ ! ${_LUA_UTILS_R0} ]]; then
+
+inherit toolchain-funcs
+
+# @ECLASS-VARIABLE: _LUA_ALL_IMPLS
+# @INTERNAL
+# @DESCRIPTION:
+# All supported Lua implementations, most preferred last
+_LUA_ALL_IMPLS=(
+	luajit
+	lua5-1
+	lua5-3
+	lua5-4
+)
+readonly _LUA_ALL_IMPLS
+
+# @ECLASS-VARIABLE: _LUA_HISTORICAL_IMPLS
+# @INTERNAL
+# @DESCRIPTION:
+# All historical Lua implementations that are no longer supported.
+_LUA_HISTORICAL_IMPLS=(
+	lua5-2
+)
+readonly _LUA_HISTORICAL_IMPLS
+
+# @FUNCTION: _lua_set_impls
+# @INTERNAL
+# @DESCRIPTION:
+# Check LUA_COMPAT for well-formedness and validity, then set
+# two global variables:
+#
+# - _LUA_SUPPORTED_IMPLS containing valid implementations supported
+#   by the ebuild (LUA_COMPAT minus dead implementations),
+#
+# - and _LUA_UNSUPPORTED_IMPLS containing valid implementations that
+#   are not supported by the ebuild.
+#
+# Implementations in both variables are ordered using the pre-defined
+# eclass implementation ordering.
+#
+# This function must only be called once.
+_lua_set_impls() {
+	local i
+
+	if ! declare -p LUA_COMPAT &>/dev/null; then
+		die 'LUA_COMPAT not declared.'
+	fi
+	if [[ $(declare -p LUA_COMPAT) != "declare -a"* ]]; then
+		die 'LUA_COMPAT must be an array.'
+	fi
+
+	local supp=() unsupp=()
+
+	for i in "${_LUA_ALL_IMPLS[@]}"; do
+		if has "${i}" "${LUA_COMPAT[@]}"; then
+			supp+=( "${i}" )
+		else
+			unsupp+=( "${i}" )
+		fi
+	done
+
+	if [[ ! ${supp[@]} ]]; then
+		die "No supported implementation in LUA_COMPAT."
+	fi
+
+	if [[ ${_LUA_SUPPORTED_IMPLS[@]} ]]; then
+		# set once already, verify integrity
+		if [[ ${_LUA_SUPPORTED_IMPLS[@]} != ${supp[@]} ]]; then
+			eerror "Supported impls (LUA_COMPAT) changed between inherits!"
+			eerror "Before: ${_LUA_SUPPORTED_IMPLS[*]}"
+			eerror "Now   : ${supp[*]}"
+			die "_LUA_SUPPORTED_IMPLS integrity check failed"
+		fi
+		if [[ ${_LUA_UNSUPPORTED_IMPLS[@]} != ${unsupp[@]} ]]; then
+			eerror "Unsupported impls changed between inherits!"
+			eerror "Before: ${_LUA_UNSUPPORTED_IMPLS[*]}"
+			eerror "Now   : ${unsupp[*]}"
+			die "_LUA_UNSUPPORTED_IMPLS integrity check failed"
+		fi
+	else
+		_LUA_SUPPORTED_IMPLS=( "${supp[@]}" )
+		_LUA_UNSUPPORTED_IMPLS=( "${unsupp[@]}" )
+		readonly _LUA_SUPPORTED_IMPLS _LUA_UNSUPPORTED_IMPLS
+	fi
+}
+
+# @FUNCTION: _lua_wrapper_setup
+# @USAGE: [<path> [<impl>]]
+# @INTERNAL
+# @DESCRIPTION:
+# Create proper Lua executables and pkg-config wrappers
+# (if available) in the directory named by <path>. Set up PATH
+# and PKG_CONFIG_PATH appropriately. <path> defaults to ${T}/${ELUA}.
+#
+# The wrappers will be created for implementation named by <impl>,
+# or for one named by ${ELUA} if no <impl> passed.
+#
+# If the named directory contains a lua symlink already, it will
+# be assumed to contain proper wrappers already and only environment
+# setup will be done. If wrapper update is requested, the directory
+# shall be removed first.
+_lua_wrapper_setup() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	local workdir=${1:-${T}/${ELUA}}
+	local impl=${2:-${ELUA}}
+
+	[[ ${workdir} ]] || die "${FUNCNAME}: no workdir specified."
+	[[ ${impl} ]] || die "${FUNCNAME}: no impl nor ELUA specified."
+
+	if [[ ! -x ${workdir}/bin/lua ]]; then
+		mkdir -p "${workdir}"/{bin,pkgconfig} || die
+
+		# Clean up, in case we were supposed to do a cheap update
+		rm -f "${workdir}"/bin/lua{,c} || die
+		rm -f "${workdir}"/pkgconfig/lua.pc || die
+
+		local ELUA LUA
+		_lua_export "${impl}" ELUA LUA
+
+		# Lua interpreter
+		ln -s "${EPREFIX}"/usr/bin/${ELUA} "${workdir}"/bin/lua || die
+
+		# Lua compiler, or a stub for it in case of luajit
+		if [[ ${ELUA} == luajit ]]; then
+			# Just in case
+			ln -s "${EPREFIX}"/bin/true "${workdir}"/bin/luac || die
+		else
+			ln -s "${EPREFIX}"/usr/bin/${ELUA/a/ac} "${workdir}"/bin/luac || die
+		fi
+
+		# pkg-config
+		ln -s "${EPREFIX}"/usr/$(get_libdir)/pkgconfig/${ELUA}.pc \
+			"${workdir}"/pkgconfig/lua.pc || die
+	fi
+
+	# Now, set the environment.
+	# But note that ${workdir} may be shared with something else,
+	# and thus already on top of PATH.
+	if [[ ${PATH##:*} != ${workdir}/bin ]]; then
+		PATH=${workdir}/bin${PATH:+:${PATH}}
+	fi
+	if [[ ${PKG_CONFIG_PATH##:*} != ${workdir}/pkgconfig ]]; then
+		PKG_CONFIG_PATH=${workdir}/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}}
+	fi
+	export PATH PKG_CONFIG_PATH
+}
+
+# @ECLASS-VARIABLE: ELUA
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# The executable name of the current Lua interpreter. This variable is set
+# automatically in functions called by lua_foreach_impl().
+#
+# Example value:
+# @CODE
+# lua5.1
+# @CODE
+
+# @ECLASS-VARIABLE: LUA
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# The absolute path to the current Lua interpreter. This variable is set
+# automatically in functions called by lua_foreach_impl().
+#
+# Example value:
+# @CODE
+# /usr/bin/lua5.1
+# @CODE
+
+# @FUNCTION: _lua_get_library_file
+# @USAGE: <impl>
+# @INTERNAL
+# @DESCRIPTION:
+# Get the core part (i.e. without the extension) of the library name,
+# with path, of the given Lua implementation.
+# Used internally by _lua_export().
+_lua_get_library_file() {
+	local impl="${1}"
+	local libdir libname
+
+	case ${impl} in
+		luajit)
+			libname=lib$($(tc-getPKG_CONFIG) --variable libname ${impl}) || die
+			;;
+		lua*)
+			libname=lib${impl}
+			;;
+		*)
+			die "Invalid implementation: ${impl}"
+			;;
+	esac
+
+	libdir=$($(tc-getPKG_CONFIG) --variable libdir ${impl}) || die
+	libdir="${libdir#${ESYSROOT#${SYSROOT}}}"
+
+	debug-print "${FUNCNAME}: libdir = ${libdir}, libname = ${libname}"
+	echo "${libdir}/${libname}"
+}
+
+# @FUNCTION: _lua_export
+# @USAGE: [<impl>] <variables>...
+# @INTERNAL
+# @DESCRIPTION:
+# Set and export the Lua implementation-relevant variables passed
+# as parameters.
+#
+# The optional first parameter may specify the requested Lua
+# implementation (either as LUA_TARGETS value, e.g. lua5-4,
+# or an ELUA one, e.g. lua5.4). If no implementation passed,
+# the current one will be obtained from ${ELUA}.
+_lua_export() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	local impl var
+
+	case "${1}" in
+		luajit)
+			impl=${1}
+			shift
+			;;
+		lua*)
+			impl=${1/-/.}
+			shift
+			;;
+		*)
+			impl=${ELUA}
+			if [[ -z ${impl} ]]; then
+				die "_lua_export called without a Lua implementation and ELUA is unset"
+			fi
+			;;
+	esac
+	debug-print "${FUNCNAME}: implementation: ${impl}"
+
+	for var; do
+		case "${var}" in
+			ELUA)
+				export ELUA=${impl}
+				debug-print "${FUNCNAME}: ELUA = ${ELUA}"
+				;;
+			LUA)
+				export LUA="${EPREFIX}"/usr/bin/${impl}
+				debug-print "${FUNCNAME}: LUA = ${LUA}"
+				;;
+			LUA_CFLAGS)
+				local val
+
+				val=$($(tc-getPKG_CONFIG) --cflags ${impl}) || die
+
+				export LUA_CFLAGS=${val}
+				debug-print "${FUNCNAME}: LUA_CFLAGS = ${LUA_CFLAGS}"
+				;;
+			LUA_CMOD_DIR)
+				local val
+
+				val=$($(tc-getPKG_CONFIG) --variable INSTALL_CMOD ${impl}) || die
+				val="${val#${ESYSROOT#${SYSROOT}}}"
+
+				export LUA_CMOD_DIR=${val}
+				debug-print "${FUNCNAME}: LUA_CMOD_DIR = ${LUA_CMOD_DIR}"
+				;;
+			LUA_INCLUDE_DIR)
+				local val
+
+				val=$($(tc-getPKG_CONFIG) --variable includedir ${impl}) || die
+				val="${val#${ESYSROOT#${SYSROOT}}}"
+
+				export LUA_INCLUDE_DIR=${val}
+				debug-print "${FUNCNAME}: LUA_INCLUDE_DIR = ${LUA_INCLUDE_DIR}"
+				;;
+			LUA_LIBS)
+				local val
+
+				val=$($(tc-getPKG_CONFIG) --libs ${impl}) || die
+
+				export LUA_LIBS=${val}
+				debug-print "${FUNCNAME}: LUA_LIBS = ${LUA_LIBS}"
+				;;
+			LUA_LMOD_DIR)
+				local val
+
+				val=$($(tc-getPKG_CONFIG) --variable INSTALL_LMOD ${impl}) || die
+				val="${val#${ESYSROOT#${SYSROOT}}}"
+
+				export LUA_LMOD_DIR=${val}
+				debug-print "${FUNCNAME}: LUA_LMOD_DIR = ${LUA_LMOD_DIR}"
+				;;
+			LUA_PKG_DEP)
+				local d
+				case ${impl} in
+					luajit)
+						LUA_PKG_DEP="dev-lang/luajit:="
+						;;
+					lua*)
+						LUA_PKG_DEP="dev-lang/lua:${impl#lua}"
+						;;
+					*)
+						die "Invalid implementation: ${impl}"
+						;;
+				esac
+
+				# use-dep
+				if [[ ${LUA_REQ_USE} ]]; then
+					LUA_PKG_DEP+=[${LUA_REQ_USE}]
+				fi
+
+				export LUA_PKG_DEP
+				debug-print "${FUNCNAME}: LUA_PKG_DEP = ${LUA_PKG_DEP}"
+				;;
+			LUA_SHARED_LIB)
+				local val=$(_lua_get_library_file ${impl})
+				export LUA_SHARED_LIB="${val}".so
+				debug-print "${FUNCNAME}: LUA_SHARED_LIB = ${LUA_SHARED_LIB}"
+				;;
+			LUA_VERSION)
+				local val
+
+				val=$($(tc-getPKG_CONFIG) --modversion ${impl}) || die
+
+				export LUA_VERSION=${val}
+				debug-print "${FUNCNAME}: LUA_VERSION = ${LUA_VERSION}"
+				;;
+			*)
+				die "_lua_export: unknown variable ${var}"
+				;;
+		esac
+	done
+}
+
+# @FUNCTION: lua_enable_tests
+# @USAGE: <test-runner> <test-directory>
+# @DESCRIPTION:
+# Set up IUSE, RESTRICT, BDEPEND and src_test() for running tests
+# with the specified test runner.  Also copies the current value
+# of RDEPEND to test?-BDEPEND.  The test-runner argument must be one of:
+#
+# - busted: dev-lua/busted
+#
+# Additionally, a second argument can be passed after <test-runner>,
+# so <test-runner> will use that directory to search for tests.
+# If not passed, a default directory of <test-runner> will be used.
+#
+# - busted: spec
+#
+# This function is meant as a helper for common use cases, and it only
+# takes care of basic setup.  You still need to list additional test
+# dependencies manually.  If you have uncommon use case, you should
+# not use it and instead enable tests manually.
+#
+# This function must be called in global scope, after RDEPEND has been
+# declared.  Take care not to overwrite the variables set by it.
+lua_enable_tests() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	[[ ${#} -ge 1 ]] || die "${FUNCNAME} takes at least one argument: test-runner (test-directory)"
+	local test_directory
+	local test_pkg
+	case ${1} in
+		busted)
+			test_directory="${2:-spec}"
+			test_pkg="dev-lua/busted"
+			if [[ ! ${_LUA_SINGLE_R0} ]]; then
+				eval "lua_src_test() {
+					busted --lua=\"\${ELUA}\" --output=\"plainTerminal\" \"${test_directory}\" || die \"Tests fail with \${ELUA}\"
+				}"
+				src_test() {
+					lua_foreach_impl lua_src_test
+				}
+			else
+				eval "src_test() {
+					busted --lua=\"\${ELUA}\" --output=\"plainTerminal\" \"${test_directory}\" || die \"Tests fail with \${ELUA}\"
+				}"
+			fi
+			;;
+		*)
+			die "${FUNCNAME}: unsupported argument: ${1}"
+	esac
+
+	local test_deps=${RDEPEND}
+	if [[ -n ${test_pkg} ]]; then
+		if [[ ! ${_LUA_SINGLE_R0} ]]; then
+			test_deps+=" ${test_pkg}[${LUA_USEDEP}]"
+		else
+			test_deps+=" $(lua_gen_cond_dep "
+				${test_pkg}[\${LUA_USEDEP}]
+			")"
+		fi
+	fi
+	if [[ -n ${test_deps} ]]; then
+		IUSE+=" test"
+		RESTRICT+=" !test? ( test )"
+		BDEPEND+=" test? ( ${test_deps} )"
+	fi
+
+	# we need to ensure successful return in case we're called last,
+	# otherwise Portage may wrongly assume sourcing failed
+	return 0
+}
+
+# @FUNCTION: lua_get_CFLAGS
+# @USAGE: [<impl>]
+# @DESCRIPTION:
+# Obtain and print the compiler flags for building against Lua,
+# for the given implementation. If no implementation is provided,
+# ${ELUA} will be used.
+#
+# Please note that this function requires Lua and pkg-config installed,
+# and therefore proper build-time dependencies need be added to the ebuild.
+lua_get_CFLAGS() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	_lua_export "${@}" LUA_CFLAGS
+	echo "${LUA_CFLAGS}"
+}
+
+# @FUNCTION: lua_get_cmod_dir
+# @USAGE: [<impl>]
+# @DESCRIPTION:
+# Obtain and print the name of the directory into which compiled Lua
+# modules are installed, for the given implementation. If no implementation
+# is provided, ${ELUA} will be used.
+#
+# Please note that this function requires Lua and pkg-config installed,
+# and therefore proper build-time dependencies need be added to the ebuild.
+lua_get_cmod_dir() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	_lua_export "${@}" LUA_CMOD_DIR
+	echo "${LUA_CMOD_DIR}"
+}
+
+# @FUNCTION: lua_get_include_dir
+# @USAGE: [<impl>]
+# @DESCRIPTION:
+# Obtain and print the name of the directory containing header files
+# of the given Lua implementation. If no implementation is provided,
+# ${ELUA} will be used.
+#
+# Please note that this function requires Lua and pkg-config installed,
+# and therefore proper build-time dependencies need be added to the ebuild.
+lua_get_include_dir() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	_lua_export "${@}" LUA_INCLUDE_DIR
+	echo "${LUA_INCLUDE_DIR}"
+}
+
+# @FUNCTION: lua_get_LIBS
+# @USAGE: [<impl>]
+# @DESCRIPTION:
+# Obtain and print the compiler flags for linking against Lua,
+# for the given implementation. If no implementation is provided,
+# ${ELUA} will be used.
+#
+# Please note that this function requires Lua and pkg-config installed,
+# and therefore proper build-time dependencies need be added to the ebuild.
+lua_get_LIBS() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	_lua_export "${@}" LUA_LIBS
+	echo "${LUA_LIBS}"
+}
+
+# @FUNCTION: lua_get_lmod_dir
+# @USAGE: [<impl>]
+# @DESCRIPTION:
+# Obtain and print the name of the directory into which native-Lua
+# modules are installed, for the given implementation. If no implementation
+# is provided, ${ELUA} will be used.
+#
+# Please note that this function requires Lua and pkg-config installed,
+# and therefore proper build-time dependencies need be added to the ebuild.
+lua_get_lmod_dir() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	_lua_export "${@}" LUA_LMOD_DIR
+	echo "${LUA_LMOD_DIR}"
+}
+
+# @FUNCTION: lua_get_shared_lib
+# @USAGE: [<impl>]
+# @DESCRIPTION:
+# Obtain and print the expected name, with path, of the main shared library
+# of the given Lua implementation. If no implementation is provided,
+# ${ELUA} will be used.
+#
+# Note that it is up to the ebuild maintainer to ensure Lua actually
+# provides a shared library.
+#
+# Please note that this function requires Lua and pkg-config installed,
+# and therefore proper build-time dependencies need be added to the ebuild.
+lua_get_shared_lib() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	_lua_export "${@}" LUA_SHARED_LIB
+	echo "${LUA_SHARED_LIB}"
+}
+
+# @FUNCTION: lua_get_version
+# @USAGE: [<impl>]
+# @DESCRIPTION:
+# Obtain and print the full version number of the given Lua implementation.
+# If no implementation is provided, ${ELUA} will be used.
+#
+# Please note that this function requires Lua and pkg-config installed,
+# and therefore proper build-time dependencies need be added to the ebuild.
+lua_get_version() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	_lua_export "${@}" LUA_VERSION
+	echo "${LUA_VERSION}"
+}
+
+_LUA_UTILS_R0=1
+fi
diff --git a/metadata/md5-cache/app-editors/vim-8.2.0360 b/metadata/md5-cache/app-editors/vim-8.2.0360
deleted file mode 100644
index af3f1e8..0000000
--- a/metadata/md5-cache/app-editors/vim-8.2.0360
+++ /dev/null
@@ -1,14 +0,0 @@
-DEFINED_PHASES=compile configure install postinst postrm prepare setup test
-DEPEND=>=app-eselect/eselect-vi-1.1 >=sys-libs/ncurses-5.2-r2:0= nls? ( virtual/libintl ) acl? ( kernel_linux? ( sys-apps/acl ) ) cscope? ( dev-util/cscope ) gpm? ( >=sys-libs/gpm-1.19.3 ) lua? ( luajit? ( dev-lang/luajit:2= ) !luajit? ( dev-lang/lua:0[deprecated] ) ) !minimal? ( ~app-editors/vim-core-8.2.0360 ) vim-pager? ( app-editors/vim-core[-minimal] ) perl? ( dev-lang/perl:= ) python? ( python_single_target_python3_6? ( dev-lang/python:3.6[threads(+)] >=dev-lang/python-exec-2:=[python_targets_python3_6] ) python_single_target_python3_7? ( dev-lang/python:3.7[threads(+)] >=dev-lang/python-exec-2:=[python_targets_python3_7] ) python_single_target_python3_8? ( dev-lang/python:3.8[threads(+)] >=dev-lang/python-exec-2:=[python_targets_python3_8] ) ) racket? ( dev-scheme/racket ) ruby? ( || ( dev-lang/ruby:2.5 dev-lang/ruby:2.4 dev-lang/ruby:2.6 dev-lang/ruby:2.7 ) virtual/rubygems ) selinux? ( sys-libs/libselinux ) sound? ( media-libs/libcanberra ) tcl? ( dev-lang/tcl:0= ) X? ( x11-libs/libXt ) sys-devel/autoconf nls? ( sys-devel/gettext )
-DESCRIPTION=Vim, an improved vi-style text editor
-EAPI=7
-HOMEPAGE=https://vim.sourceforge.io/ https://github.com/vim/vim
-IUSE=X acl cscope debug gpm lua luajit minimal nls perl python racket ruby selinux sound tcl terminal vim-pager python_single_target_python3_6 python_single_target_python3_7 python_single_target_python3_8
-KEYWORDS=*
-LICENSE=vim
-RDEPEND=>=app-eselect/eselect-vi-1.1 >=sys-libs/ncurses-5.2-r2:0= nls? ( virtual/libintl ) acl? ( kernel_linux? ( sys-apps/acl ) ) cscope? ( dev-util/cscope ) gpm? ( >=sys-libs/gpm-1.19.3 ) lua? ( luajit? ( dev-lang/luajit:2= ) !luajit? ( dev-lang/lua:0[deprecated] ) ) !minimal? ( ~app-editors/vim-core-8.2.0360 ) vim-pager? ( app-editors/vim-core[-minimal] ) perl? ( dev-lang/perl:= ) python? ( python_single_target_python3_6? ( dev-lang/python:3.6[threads(+)] >=dev-lang/python-exec-2:=[python_targets_python3_6] ) python_single_target_python3_7? ( dev-lang/python:3.7[threads(+)] >=dev-lang/python-exec-2:=[python_targets_python3_7] ) python_single_target_python3_8? ( dev-lang/python:3.8[threads(+)] >=dev-lang/python-exec-2:=[python_targets_python3_8] ) ) racket? ( dev-scheme/racket ) ruby? ( || ( dev-lang/ruby:2.5 dev-lang/ruby:2.4 dev-lang/ruby:2.6 dev-lang/ruby:2.7 ) virtual/rubygems ) selinux? ( sys-libs/libselinux ) sound? ( media-libs/libcanberra ) tcl? ( dev-lang/tcl:0= ) X? ( x11-libs/libXt )
-REQUIRED_USE=python? ( ^^ ( python_single_target_python3_6 python_single_target_python3_7 python_single_target_python3_8 ) ) vim-pager? ( !minimal )
-SLOT=0
-SRC_URI=https://github.com/vim/vim/archive/v8.2.0360.tar.gz -> vim-8.2.0360.tar.gz https://dev.gentoo.org/~radhermit/vim/vim-8.2.0210-gentoo-patches.tar.bz2
-_eclasses_=bash-completion-r1	47a7402d95930413ce25ba8d857339bb	desktop	b1d22ac8bdd4679ab79c71aca235009d	eutils	fcb2aa98e1948b835b5ae66ca52868c5	flag-o-matic	5d5921a298e95441da2f85be419894c0	multilib	2477ebe553d3e4d2c606191fe6c33602	python-single-r1	674c48c926cbb44e91b656e0399d8f54	python-utils-r1	157a6a7a3e99c7dbdf81acc9dd4f57cd	ruby-single	e6530f43a549f120f9396ccb852288f5	ruby-utils	cdb4c1e4283adb7707b7dd48ccaa7ad2	toolchain-funcs	605c126bed8d87e4378d5ff1645330cb	vim-doc	6bd5bb2529af326fe3359e975a3439d0	xdg-utils	ff2ff954e6b17929574eee4efc5152ba
-_md5_=604aa383416f88540946e961dc9d38ea
diff --git a/metadata/md5-cache/app-editors/vim-8.2.0814-r100 b/metadata/md5-cache/app-editors/vim-8.2.0814-r100
new file mode 100644
index 0000000..b47a13e
--- /dev/null
+++ b/metadata/md5-cache/app-editors/vim-8.2.0814-r100
@@ -0,0 +1,15 @@
+BDEPEND=lua? ( lua_single_target_luajit? ( dev-lang/luajit:= ) lua_single_target_lua5-1? ( dev-lang/lua:5.1 ) )
+DEFINED_PHASES=compile configure install postinst postrm prepare setup test
+DEPEND=>=app-eselect/eselect-vi-1.1 >=sys-libs/ncurses-5.2-r2:0= nls? ( virtual/libintl ) acl? ( kernel_linux? ( sys-apps/acl ) ) cscope? ( dev-util/cscope ) gpm? ( >=sys-libs/gpm-1.19.3 ) lua? ( lua_single_target_luajit? ( dev-lang/luajit:= ) lua_single_target_lua5-1? ( dev-lang/lua:5.1 ) lua_single_target_lua5-1? ( dev-lang/lua:5.1[deprecated] ) ) !minimal? ( ~app-editors/vim-core-8.2.0814 ) vim-pager? ( app-editors/vim-core[-minimal] ) perl? ( dev-lang/perl:= ) python? ( python_single_target_python3_8? ( dev-lang/python:3.8[threads(+)] >=dev-lang/python-exec-2:=[python_targets_python3_8] ) python_single_target_python3_9? ( dev-lang/python:3.9[threads(+)] >=dev-lang/python-exec-2:=[python_targets_python3_9] ) python_single_target_python3_10? ( dev-lang/python:3.10[threads(+)] >=dev-lang/python-exec-2:=[python_targets_python3_10] ) ) racket? ( dev-scheme/racket ) ruby? ( || ( dev-lang/ruby:2.5 dev-lang/ruby:2.4 dev-lang/ruby:2.6 dev-lang/ruby:2.7 ) virtual/rubygems ) selinux? ( sys-libs/libselinux ) sound? ( media-libs/libcanberra ) tcl? ( dev-lang/tcl:0= ) X? ( x11-libs/libXt ) sys-devel/autoconf nls? ( sys-devel/gettext )
+DESCRIPTION=Vim, an improved vi-style text editor
+EAPI=7
+HOMEPAGE=https://vim.sourceforge.io/ https://github.com/vim/vim
+IUSE=X acl cscope debug gpm lua ipv6 minimal nls perl python racket ruby selinux sound tcl terminal vim-pager lua_single_target_luajit lua_single_target_lua5-1 python_single_target_python3_8 python_single_target_python3_9 python_single_target_python3_10
+KEYWORDS=*
+LICENSE=vim
+RDEPEND=>=app-eselect/eselect-vi-1.1 >=sys-libs/ncurses-5.2-r2:0= nls? ( virtual/libintl ) acl? ( kernel_linux? ( sys-apps/acl ) ) cscope? ( dev-util/cscope ) gpm? ( >=sys-libs/gpm-1.19.3 ) lua? ( lua_single_target_luajit? ( dev-lang/luajit:= ) lua_single_target_lua5-1? ( dev-lang/lua:5.1 ) lua_single_target_lua5-1? ( dev-lang/lua:5.1[deprecated] ) ) !minimal? ( ~app-editors/vim-core-8.2.0814 ) vim-pager? ( app-editors/vim-core[-minimal] ) perl? ( dev-lang/perl:= ) python? ( python_single_target_python3_8? ( dev-lang/python:3.8[threads(+)] >=dev-lang/python-exec-2:=[python_targets_python3_8] ) python_single_target_python3_9? ( dev-lang/python:3.9[threads(+)] >=dev-lang/python-exec-2:=[python_targets_python3_9] ) python_single_target_python3_10? ( dev-lang/python:3.10[threads(+)] >=dev-lang/python-exec-2:=[python_targets_python3_10] ) ) racket? ( dev-scheme/racket ) ruby? ( || ( dev-lang/ruby:2.5 dev-lang/ruby:2.4 dev-lang/ruby:2.6 dev-lang/ruby:2.7 ) virtual/rubygems ) selinux? ( sys-libs/libselinux ) sound? ( media-libs/libcanberra ) tcl? ( dev-lang/tcl:0= ) X? ( x11-libs/libXt )
+REQUIRED_USE=lua? ( ^^ ( lua_single_target_luajit lua_single_target_lua5-1 ) ) python? ( ^^ ( python_single_target_python3_8 python_single_target_python3_9 python_single_target_python3_10 ) ) vim-pager? ( !minimal )
+SLOT=0
+SRC_URI=https://github.com/vim/vim/archive/v8.2.0814.tar.gz -> vim-8.2.0814.tar.gz https://dev.gentoo.org/~zlogene/distfiles/app-editors/vim/vim-8.2.0360-gentoo-patches.tar.xz
+_eclasses_=bash-completion-r1	47a7402d95930413ce25ba8d857339bb	desktop	b1d22ac8bdd4679ab79c71aca235009d	eapi8-dosym	cd7d420bb5be5ee079f27239ce76b8f5	eutils	fcb2aa98e1948b835b5ae66ca52868c5	flag-o-matic	5d5921a298e95441da2f85be419894c0	lua-single	ba92a0c9d413e015c6625cdb0b9aaf99	lua-utils	7b7cd623ac8b9dd4a7a6ee27219cada6	multilib	2477ebe553d3e4d2c606191fe6c33602	multiprocessing	c3cf317581e5bd068a4b851f03dd8cba	python-single-r1	674c48c926cbb44e91b656e0399d8f54	python-utils-r1	655fe65f186504e455c2f3116808fda8	ruby-single	e6530f43a549f120f9396ccb852288f5	ruby-utils	cdb4c1e4283adb7707b7dd48ccaa7ad2	toolchain-funcs	605c126bed8d87e4378d5ff1645330cb	vim-doc	6bd5bb2529af326fe3359e975a3439d0	xdg-utils	ff2ff954e6b17929574eee4efc5152ba
+_md5_=e1c81f06f8c32e8fb875fcf144f9e957
diff --git a/metadata/md5-cache/app-editors/vim-core-8.2.0360 b/metadata/md5-cache/app-editors/vim-core-8.2.0814
similarity index 78%
rename from metadata/md5-cache/app-editors/vim-core-8.2.0360
rename to metadata/md5-cache/app-editors/vim-core-8.2.0814
index 8dcc699..3e0e867 100644
--- a/metadata/md5-cache/app-editors/vim-core-8.2.0360
+++ b/metadata/md5-cache/app-editors/vim-core-8.2.0814
@@ -9,6 +9,6 @@
 PDEPEND=!minimal? ( app-vim/gentoo-syntax )
 RDEPEND=!!<app-editors/gvim-8.1.0648
 SLOT=0
-SRC_URI=https://github.com/vim/vim/archive/v8.2.0360.tar.gz -> vim-8.2.0360.tar.gz https://dev.gentoo.org/~radhermit/vim/vim-8.2.0210-gentoo-patches.tar.bz2
+SRC_URI=https://github.com/vim/vim/archive/v8.2.0814.tar.gz -> vim-8.2.0814.tar.gz https://dev.gentoo.org/~zlogene/distfiles/app-editors/vim/vim-8.2.0360-gentoo-patches.tar.xz
 _eclasses_=bash-completion-r1	47a7402d95930413ce25ba8d857339bb	desktop	b1d22ac8bdd4679ab79c71aca235009d	estack	686eaab303305a908fd57b2fd7617800	eutils	fcb2aa98e1948b835b5ae66ca52868c5	flag-o-matic	5d5921a298e95441da2f85be419894c0	multilib	2477ebe553d3e4d2c606191fe6c33602	prefix	e51c7882b7b721e54e684f7eb143cbfe	toolchain-funcs	605c126bed8d87e4378d5ff1645330cb	vim-doc	6bd5bb2529af326fe3359e975a3439d0	xdg-utils	ff2ff954e6b17929574eee4efc5152ba
-_md5_=67cdb76bbe7c0e090b30d2c80e29ce74
+_md5_=afee0ac91ab731b4ed578ad494b1bf8f