--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <maintainer type="person">
+ <email>max@friedersdorff.com</email>
+ <name>Maximilian Friedersdorff</name>
+ </maintainer>
+ <use>
+ <flag name="module">Compile the actual rtl8812AU kernel module. Most certainly you want this enabled, unless you're doing something strange.</flag>
+ <flag name="module-src">Install the module source code to /usr/src, in case you like building kernel modules yourself.</flag>
+ </use>
+</pkgmetadata>
--- /dev/null
+# Copyright 1999-2018 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+MODULES_OPTIONAL_USE="module"
+inherit linux-mod bash-completion-r1
+
+DESCRIPTION="Driver module for Realtek 8811, 8812, 8814 and 8821 chipsets. From aircrack-ng"
+HOMEPAGE="https://github.com/aircrack-ng/rtl8812au.git"
+
+if [[ ${PV} == 9999 ]]; then
+ inherit git-r3
+ EGIT_REPO_URI="https://github.com/aircrack-ng/rtl8812au"
+ KEYWORDS=""
+else
+ die "Only support building directly from git for now"
+fi
+
+LICENSE="GPL-2"
+SLOT="0"
+IUSE="+module module-src"
+
+MODULE_NAMES="88XXau(kernel/drivers/net/wireless)"
+BUILD_TARGETS="modules"
+CONFIG_CHECK=""
+
+pkg_setup() {
+ if use module; then
+ linux-mod_pkg_setup
+ kernel_is -lt 3 10 0 && die "This version of ${PN} requires Linux >= 3.10"
+ fi
+}
+
+src_compile() {
+ BUILD_PARAMS="KERNELDIR=${KERNEL_DIR}"
+ use module && linux-mod_src_compile
+}
+
+src_install() {
+ use module && linux-mod_src_install
+ use module-src && dodir /usr/src && cp -r "${S}" "${ED}/usr/src/${PN}"
+}
+
+pkg_postinst() {
+ if use module-src && ! use module; then
+ einfo
+ einfo "You have enabled the module-src USE flag without the module USE"
+ einfo "flag. This means that sources are installed to"
+ einfo "${ROOT}usr/src/88XXau instead of having the"
+ einfo "kernel module compiled. You will need to compile the module"
+ einfo "yourself. Most likely, you don't want this USE flag, and should"
+ einfo "rather use USE=module"
+ einfo
+ fi
+ use module && linux-mod_pkg_postinst
+
+ if use module; then
+ local old new
+ if [[ $(uname -r) != "${KV_FULL}" ]]; then
+ ewarn
+ ewarn "You have just built the rtl8812AU driver for kernel ${KV_FULL}, yet the currently running"
+ ewarn "kernel is $(uname -r). If you intend to use this driver module on the currently"
+ ewarn "running machine, you will first need to reboot it into the kernel ${KV_FULL}, for"
+ ewarn "which this module was built."
+ ewarn
+ elif [[ -f /sys/module/88XXau/version ]] && \
+ old="$(< /sys/module/88XXau/version)" && \
+ new="$(modinfo -F version "${ROOT}/lib/modules/${KV_FULL}/net/wireless/88XXau.ko" 2>/dev/null)" && \
+ [[ $old != "$new" ]]; then
+ ewarn
+ ewarn "You appear to have just upgraded rtl8812AU from version v$old to v$new."
+ ewarn "However, the old version is still running on your system. In order to use the"
+ ewarn "new version, you will need to remove the old module and load the new one. As"
+ ewarn "root, you can accomplish this with the following commands:"
+ ewarn
+ ewarn " # rmmod 88XXau"
+ ewarn " # modprobe 88XXau"
+ ewarn
+ fi
+ fi
+}