summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorJianfeng Zhang2017-03-01 22:32:22 +0800
committerJianfeng Zhang2017-03-01 22:32:22 +0800
commit05a462359406f945638ade40f5f3fdd03946f840 (patch)
tree3a857e44dad098fd6a5ae2b613076d6fb1b2a571
downloadaur-05a462359406f945638ade40f5f3fdd03946f840.tar.gz
initial commit
-rw-r--r--.SRCINFO33
-rw-r--r--PKGBUILD55
-rwxr-xr-xalpm-hook167
-rw-r--r--dkms-install.hook14
-rw-r--r--dkms-remove.hook16
5 files changed, 285 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..f7019825fe72
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,33 @@
+# Generated by mksrcinfo v8
+# 三 3月 1 14:32:18 UTC 2017
+pkgbase = dkms-sorted
+ pkgdesc = Dynamic Kernel Modules Systemi (modified alpm hook to handle dependencies)
+ pkgver = 2.3
+ pkgrel = 1
+ url = https://github.com/dell/dkms
+ arch = any
+ license = GPL2
+ makedepends = git
+ depends = bash
+ depends = kmod
+ depends = gcc
+ depends = make
+ depends = patch
+ optdepends = linux-headers: build modules against the Arch kernel
+ optdepends = linux-lts-headers: build modules against the LTS kernel
+ optdepends = linux-zen-headers: build modules against the ZEN kernel
+ optdepends = linux-grsec-headers: build modules against the GRSEC kernel
+ provides = dkms
+ conflicts = dkms
+ backup = etc/dkms/framework.conf
+ source = git+https://github.com/dell/dkms.git#tag=2.3
+ source = dkms-install.hook
+ source = dkms-remove.hook
+ source = alpm-hook
+ sha256sums = SKIP
+ sha256sums = 6f2fe43f98cd3e043330e599689d3471108e5022ca7edf69ad645f609ccc33ac
+ sha256sums = a145a3a8880449a8bc824374b8409750f3cb7c003395fff5a8b9e5ff803c1328
+ sha256sums = a897269345bdcbea4a3feca371cf24767762ae75b7cd2d7f3a4abb50797c3dbd
+
+pkgname = dkms-sorted
+
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..16d3c483263e
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,55 @@
+# Maintainer: Jianfeng Zhang <swordfeng123@gmail.com> 5A11FEDDF991B901B98FF2C3732AFCA703D1198A
+# Maintainer: Sébastien Luttringer
+# Contributor: Balwinder S "bsd" Dheeman (bdheeman AT gmail.com)
+
+pkgname=dkms-sorted
+pkgver=2.3
+pkgrel=1
+pkgdesc='Dynamic Kernel Modules Systemi (modified alpm hook to handle dependencies)'
+arch=('any')
+url='https://github.com/dell/dkms'
+license=('GPL2')
+depends=('bash' 'kmod' 'gcc' 'make' 'patch')
+makedepends=('git')
+optdepends=('linux-headers: build modules against the Arch kernel'
+ 'linux-lts-headers: build modules against the LTS kernel'
+ 'linux-zen-headers: build modules against the ZEN kernel'
+ 'linux-grsec-headers: build modules against the GRSEC kernel')
+backup=('etc/dkms/framework.conf')
+source=("git+https://github.com/dell/dkms.git#tag=${pkgver}"
+ 'dkms-install.hook'
+ 'dkms-remove.hook'
+ 'alpm-hook')
+provides=('dkms')
+conflicts=('dkms')
+sha256sums=('SKIP'
+ '6f2fe43f98cd3e043330e599689d3471108e5022ca7edf69ad645f609ccc33ac'
+ 'a145a3a8880449a8bc824374b8409750f3cb7c003395fff5a8b9e5ff803c1328'
+ 'a897269345bdcbea4a3feca371cf24767762ae75b7cd2d7f3a4abb50797c3dbd')
+
+
+prepare() {
+ cd dkms
+
+ # /usr move
+ msg2 '/usr move patching'
+ for i in dkms{,_framework.conf,.bash-completion,.8,_common.postinst}; do
+ sed -ri 's,/lib/modules,/usr/lib/modules,g' "$i"
+ done
+}
+
+package() {
+ # alpm hook
+ install -D -m 644 dkms-install.hook "$pkgdir/usr/share/libalpm/hooks/70-dkms-install.hook"
+ install -D -m 644 dkms-remove.hook "$pkgdir/usr/share/libalpm/hooks/70-dkms-remove.hook"
+ install -D -m 755 alpm-hook "$pkgdir/usr/lib/dkms/alpm-hook"
+ # upstream installer
+ cd dkms
+ # we don't need kconf files, so we install them outside $pkgdir
+ make \
+ DESTDIR="$pkgdir" \
+ SBIN="$pkgdir/usr/bin" \
+ BASHDIR="$pkgdir/usr/share/bash-completion/completions" \
+ KCONF="$srcdir"/kconf \
+ install
+}
diff --git a/alpm-hook b/alpm-hook
new file mode 100755
index 000000000000..1e5f83b1e050
--- /dev/null
+++ b/alpm-hook
@@ -0,0 +1,167 @@
+#!/bin/bash
+
+#
+# Copyright © 2017 Sébastien Luttringer
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+# display what to run and run it quietly
+run() {
+ echo "==> $*"
+ "$@" > /dev/null
+}
+
+# check kernel is valid for action
+# it means kernel and its headers are installed
+# $1: kernel version
+check_kernel() {
+ local kver="$1"; shift
+ if [[ ! -d "$install_tree/$kver/kernel" ]]; then
+ echo "==> No kernel $kver modules. You must install them to use DKMS!"
+ return 1
+ elif [[ ! -d "$install_tree/$kver/build/Makefile" ]]; then
+ echo "==> No kernel $kver headers. You must install them to use DKMS!"
+ return 1
+ fi
+ return 0
+}
+
+# handle actions on module addition/upgrade/removal
+# $1: module name
+# $2: module version
+# $3: dkms action
+parse_module() {
+ pushd "$install_tree" >/dev/null
+ local path
+ for path in */build/; do
+ local kver="${path%%/*}"
+ dkms_register "$1" "$2" "$kver" "$3"
+ done
+ popd >/dev/null
+}
+
+# handle actions on kernel addition/upgrade/removal
+# $1: kernel version
+# $2: dkms action
+parse_kernel() {
+ local path
+ for path in "$source_tree"/*-*/dkms.conf; do
+ if [[ -f "$path" && "$path" =~ ^$source_tree/([^/]+)-([^/]+)/dkms\.conf$ ]]; then
+ dkms_register "${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}" "$1" "$2"
+ fi
+ done
+}
+
+# register a dkms call
+# this function suppress echo call for a module
+# $1: module name, $2: module version, $3: kernel version, $4: action
+dkms_register() {
+ DKMS_ACTION["$1/$2/$3"]="$4"
+}
+
+# check whether the dependencies of a module are installed
+# $1: module name/module version
+# $2: kernel version
+check_dependency() {
+ local BUILD_DEPENDS
+ mod_name=${1%/*}
+ mod_ver=${1#*/}
+ readarray -t BUILD_DEPENDS <<<$(source "$source_tree/$mod_name-$mod_ver/dkms.conf"; printf '%s\n' "${BUILD_DEPENDS[@]}")
+ [ "$BUILD_DEPENDS" = "" ] && unset BUILD_DEPENDS
+ for dep in "${BUILD_DEPENDS[@]}"; do
+ if [ ! "$(dkms status -m "$dep" -k "$2" | grep -o installed)" = "installed" ]; then
+ return 1
+ fi
+ done
+ return 0
+}
+
+# run registered dkms commands
+dkms_run() {
+ local nvk mod kver cont
+ cont=y
+ while [ "$cont" = "y" ]; do
+ cont=n
+ for nvk in "${!DKMS_ACTION[@]}"; do
+ mod=${nvk%/*}
+ kver=${nvk##*/}
+ check_kernel "$kver" || continue
+ if [ "${DKMS_ACTION[$nvk]}" = "install" ]; then
+ check_dependency "$mod" "$kver" || continue
+ fi
+ run dkms "${DKMS_ACTION[$nvk]}" "$mod" -k "$kver"
+ cont=y
+ unset DKMS_ACTION[$nvk]
+ done
+ done
+ # show warning for modules not installed
+ for nvk in "${!DKMS_ACTION[@]}"; do
+ [ "${DKMS_ACTION[$nvk]}" = "install" ] || continue
+ mod=${nvk%/*}
+ kver=${nvk##*/}
+ check_kernel "$kver" || continue
+ echo "==> WARNING: Cannot resolve dependencies for module $mod, kernel version $kver"
+ done
+}
+
+# emulated program entry point
+main() {
+ [[ -n "$DKMS_ALPM_HOOK_DEBUG" ]] && set -x
+
+ # prevent to have all each dkms call to fail
+ if (( EUID )); then
+ echo 'You must be root to use this hook' >&2
+ exit 1
+ fi
+
+ # check args count
+ if (( $# < 1 )); then
+ echo "usage: ${0##*/} dkms-arguments" >&2
+ exit 1
+ fi
+
+ # dkms path from framework config
+ # note: the alpm hooks which trigger this script use static path
+ source_tree='/usr/src'
+ install_tree='/usr/lib/modules'
+ source /etc/dkms/framework.conf
+
+ # check source_tree and install_tree exists
+ local path
+ for path in "$source_tree" "$install_tree"; do
+ if [[ ! -d "$path" ]]; then
+ echo "==> Missing mandatory directory: $path. Exiting!"
+ return 1
+ fi
+ done
+
+ # Storage for DKMS action to run
+ declare -A DKMS_ACTION
+
+ # parse stdin paths to guess what do do
+ while read -r path; do
+ if [[ "/$path" =~ ^$source_tree/([^/]+)-([^/]+)/dkms\.conf$ ]]; then
+ parse_module "${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}" "$@"
+ elif [[ "/$path" =~ ^$install_tree/([^/]+)/ ]]; then
+ parse_kernel "${BASH_REMATCH[1]}" "$@"
+ fi
+ done
+
+ dkms_run
+
+ return 0
+}
+
+main "$@"
diff --git a/dkms-install.hook b/dkms-install.hook
new file mode 100644
index 000000000000..0ad5151c3933
--- /dev/null
+++ b/dkms-install.hook
@@ -0,0 +1,14 @@
+[Trigger]
+Operation = Install
+Operation = Upgrade
+Type = File
+Target = usr/src/*/dkms.conf
+Target = usr/lib/modules/*/build/Makefile
+Target = usr/lib/modules/*/kernel/
+
+[Action]
+Description = Install DKMS modules
+Depends = dkms
+When = PostTransaction
+Exec = /usr/lib/dkms/alpm-hook install
+NeedsTargets
diff --git a/dkms-remove.hook b/dkms-remove.hook
new file mode 100644
index 000000000000..138a68c041d8
--- /dev/null
+++ b/dkms-remove.hook
@@ -0,0 +1,16 @@
+[Trigger]
+Operation = Upgrade
+Operation = Remove
+Type = File
+Target = usr/src/*/dkms.conf
+Target = usr/lib/modules/*/build/Makefile
+Target = usr/lib/modules/*/kernel/
+
+[Action]
+Description = Remove DKMS modules
+Depends = dkms
+When = PreTransaction
+# SIGPIPE workaround. See FS#49816
+#Exec = /usr/lib/dkms/alpm-hook remove
+Exec = /usr/bin/perl -e "$SIG{PIPE}='DEFAULT'; exec('/usr/lib/dkms/alpm-hook', 'remove');"
+NeedsTargets