[arch-commits] Commit in dkms/trunk (PKGBUILD hook.install hook.remove hook.sh)

Sébastien Luttringer seblu at archlinux.org
Sat Mar 12 16:38:57 UTC 2016


    Date: Saturday, March 12, 2016 @ 17:38:56
  Author: seblu
Revision: 261368

upgpkg: dkms 2.2.0.3+git151023-7

- massive use of function in the hook script
- display warning when headers/kernel are missing
- only call dkms when both headers and kernel are installed
- add others arch kernels as optdeps

Modified:
  dkms/trunk/PKGBUILD
  dkms/trunk/hook.install
  dkms/trunk/hook.remove
  dkms/trunk/hook.sh

--------------+
 PKGBUILD     |   32 +++++++++-------
 hook.install |    4 +-
 hook.remove  |    4 +-
 hook.sh      |  114 ++++++++++++++++++++++++++++++++++++++-------------------
 4 files changed, 101 insertions(+), 53 deletions(-)

Modified: PKGBUILD
===================================================================
--- PKGBUILD	2016-03-12 16:34:18 UTC (rev 261367)
+++ PKGBUILD	2016-03-12 16:38:56 UTC (rev 261368)
@@ -4,7 +4,7 @@
 
 pkgname=dkms
 pkgver=2.2.0.3+git151023
-pkgrel=6
+pkgrel=7
 pkgdesc='Dynamic Kernel Modules System'
 arch=('any')
 url='http://linux.dell.com/dkms/'
@@ -11,8 +11,10 @@
 license=('GPL2')
 depends=('bash' 'kmod' 'gcc' 'make' 'patch')
 makedepends=('git')
-optdepends=('linux-headers: build modules against Arch kernel'
-            'linux-lts-headers: build modules against LTS Arch kernel')
+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')
 install=$pkgname.install
 source=('git+git://linux.dell.com/dkms.git#commit=7b6e78f'
@@ -22,20 +24,22 @@
         'hook.sh')
 md5sums=('SKIP'
          '82d520c39c99c34977e48b313a189c6c'
-         '8fe2064106958bcfd386e83494c8959a'
-         '41fcecb1c2dfc59a4b648fddcd8b462f'
-         '22f9fc3633b13e548e78bcc48192d817')
+         'e6eada07fc3a56a491e14dfeafec746f'
+         '57d90c89a221c52d78d0ec3953fe2fcf'
+         'd11d8bfbcf61330aa84d6dd9e93ca957')
 
 prepare() {
   cd dkms
-  # patching
-  patches=("$srcdir"/*.patch)
-  if (( ${#patches[*]} > 0 )); then
-    for p in "${patches[@]}"; do
-      msg2 "Apply patch: ${p##*/}"
-      patch -p1 -i "$p"
-    done
-  fi
+
+  # apply patch from the source array (should be a pacman feature)
+  local filename
+  for filename in "${source[@]}"; do
+    if [[ "$filename" =~ \.patch$ ]]; then
+      msg2 "Applying patch $filename"
+      patch -p1 -i "$srcdir/$filename"
+    fi
+  done
+
   # /usr move
   msg2 '/usr move patching'
   for i in dkms{,_framework.conf,.bash-completion,.8,_common.postinst}; do

Modified: hook.install
===================================================================
--- hook.install	2016-03-12 16:34:18 UTC (rev 261367)
+++ hook.install	2016-03-12 16:38:56 UTC (rev 261368)
@@ -3,7 +3,9 @@
 Operation = Upgrade
 Type = File
 Target = usr/src/*/dkms.conf
-Target = usr/lib/modules/*/build/include/
+Target = usr/lib/modules/*/
+Target = !usr/lib/modules/extramodules-*
+Target = !usr/lib/modules/*/?*
 
 [Action]
 Description = Install DKMS modules

Modified: hook.remove
===================================================================
--- hook.remove	2016-03-12 16:34:18 UTC (rev 261367)
+++ hook.remove	2016-03-12 16:38:56 UTC (rev 261368)
@@ -3,7 +3,9 @@
 Operation = Remove
 Type = File
 Target = usr/src/*/dkms.conf
-Target = usr/lib/modules/*/build/include/
+Target = usr/lib/modules/*/
+Target = !usr/lib/modules/extramodules-*
+Target = !usr/lib/modules/*/?*
 
 [Action]
 Description = Remove DKMS modules

Modified: hook.sh
===================================================================
--- hook.sh	2016-03-12 16:34:18 UTC (rev 261367)
+++ hook.sh	2016-03-12 16:38:56 UTC (rev 261368)
@@ -17,46 +17,86 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
-# 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 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 "==> Kernel $kver modules are missing. Nothing will be done for this kernel!"
+		echo '==> You have to install the matching kernel package to use dkms'
+		return 1
+	elif [[ ! -d "$install_tree/$kver/build/include" ]]; then
+		echo "==> Kernel $kver headers are missing. Nothing will be done for this kernel!"
+		echo '==> You have to install the matching kernel headers package to use dkms'
+		return 1
+	fi
+	return 0
+}
 
-# check args count
-if (( $# < 1 )); then
-	echo "usage: ${0##*/} dkms-arguments" >&2
-	exit 1
-fi
+# handle actions on module addition/upgrade/removal
+# $1: module name
+# $2: module version
+# $*: dkms args
+do_module() {
+	local modname="$1"; shift
+	local modver="$2"; shift
+	pushd "$install_tree" >/dev/null
+	# do $@ for each kernel with headers for $modname v$modver
+	local path
+	for path in */build/; do
+		local kver="${path%%/*}"
+		check_kernel "$kver" || return
+		dkms "$@" -m "$modname" -v "$modver" -k "$kver"
+	done
+	popd >/dev/null
+}
 
-# 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
+# handle actions on kernel addition/upgrade/removal
+# $1: kernel version
+# $*: dkms args
+do_kernel() {
+	local kver="$1"; shift
+	check_kernel "$kver" || return
+	# do $@ once for each dkms module in $source_tree
+	local path
+	for path in "$source_tree"/*-*/dkms.conf; do
+		if [[ "$path" =~ ^$source_tree/([^/]+)-([^/]+)/dkms\.conf$ ]]; then
+			dkms "$@" -m "${BASH_REMATCH[1]}" -v "${BASH_REMATCH[2]}" -k "$kver"
+		fi
+	done
+}
 
-shopt -s nullglob
+# emulated program entry point
+main() {
+	# 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
 
-# parse stdin path to guess what do do
-while read -r path; do
-	if [[ "/$path" =~ ^$source_tree/([^/]+)-([^/]+)/dkms\.conf$ ]]; then
-		# do $@ for each kernel with headers
-		pushd "$install_tree" >/dev/null
-		for incpath in */build/include; do
-			dkms "$@" -m "${BASH_REMATCH[1]}" -v "${BASH_REMATCH[2]}" -k "${incpath%%/*}"
-		done
-		popd >/dev/null
-	elif [[ "/$path" =~ ^$install_tree/([^/]+)/ ]]; then
-		kver="${BASH_REMATCH[1]}"
-		# do $@ once for each dkms module in $source_tree
-		for path in "$source_tree"/*-*/dkms.conf; do
-			if [[ "$path" =~ ^$source_tree/([^/]+)-([^/]+)/dkms\.conf$ ]]; then
-				dkms "$@" -m "${BASH_REMATCH[1]}" -v "${BASH_REMATCH[2]}" -k "$kver"
-			fi
-		done
-	else
-		echo "Skipping invalid path: $path" >&2
+	# check args count
+	if (( $# < 1 )); then
+		echo "usage: ${0##*/} dkms-arguments" >&2
+		exit 1
 	fi
-done
 
-true
+	# 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
+
+	# parse stdin paths to guess what do do
+	while read -r path; do
+		if [[ "/$path" =~ ^$source_tree/([^/]+)-([^/]+)/dkms\.conf$ ]]; then
+			do_module "${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}" "$@"
+		elif [[ "/$path" =~ ^$install_tree/([^/]+)/ ]]; then
+			do_kernel "${BASH_REMATCH[1]}" "$@"
+		fi
+	done
+
+	return 0
+}
+
+main "$@"



More information about the arch-commits mailing list