From 8f19147495b3b01e9b9068fbdef3b82e8e7fbe94 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Thu, 23 Dec 2010 14:29:59 +0100 Subject: [PATCH] xbps-triggers: added a 'dkms' trigger, bump to 0.12. --- srcpkgs/xbps-triggers/files/dkms | 100 +++++++++++++++++++++++++++++++ srcpkgs/xbps-triggers/template | 3 +- 2 files changed, 102 insertions(+), 1 deletion(-) create mode 100755 srcpkgs/xbps-triggers/files/dkms diff --git a/srcpkgs/xbps-triggers/files/dkms b/srcpkgs/xbps-triggers/files/dkms new file mode 100755 index 00000000000..253ec861bcc --- /dev/null +++ b/srcpkgs/xbps-triggers/files/dkms @@ -0,0 +1,100 @@ +#!/bin/sh +# +# DKMS trigger. Used to add/build/install or remove the specified modules +# from all kernels. +# +# Modules can be specified like: +# dkms_modules=" ..." +# +# Arguments: $ACTION = [run/targets] +# $TARGET = [post-install/pre-remove] +# $PKGNAME +# $VERSION +# $UPDATE = [yes/no] +# +ACTION="$1" +TARGET="$2" +PKGNAME="$3" +VERSION="$4" +UPDATE="$5" + +DKMS=usr/sbin/dkms + +remove_modules() +{ + # Remove the specified modules from all kernels. + set -- ${dkms_modules} + while [ $# -gt 0 ]; do + if $DKMS status -m $1 | egrep -q '(added|built|installed)' > /dev/null; then + echo -n "Removing DKMS module '$1-$2'... " + $DKMS remove -m $1 -v $2 --all >/dev/null 2>&1 + if [ $? -eq 0 ]; then + echo "done." + else + echo "FAILED!" + fi + fi + shift; shift; + done +} + +add_modules() +{ + # Add/build and install the specified modules for all kernels. + set -- ${dkms_modules} + while [ $# -gt 0 ]; do + $DKMS add -m "$1" -v "$2" >/dev/null 2>&1 + if [ $? -eq 0 ]; then + echo "Added DKMS module '$1-$2'." + else + echo "Failed to add DKMS module: '$1-$2'..." + err=1 + fi + shift; shift; + done + [ -n "$err" ] && exit $err + + for f in $(echo lib/modules/*); do + _kver=$(basename $f) + set -- ${dkms_modules} + while [ $# -gt 0 ]; do + echo -n "Installing DKMS module '$1-$2' for kernel ${_kver}... " + $DKMS build -m "$1" -v "$2" -k "${_kver}" >/dev/null 2>&1 && \ + $DKMS install -m "$1" -v "$2" -k "${_kver}" >/dev/null 2>&1 + if [ $? -eq 0 ]; then + echo "done." + else + echo "FAILED!" + echo "DKMS module '$1-$2' failed to install, please do this manually" + echo "and check for errors in the log file." + fi + shift; shift; + done + done +} + +case "$ACTION" in +targets) + echo "post-install pre-remove" + ;; +run) + [ ! -x $DKMS -o -z "$dkms_modules" ] && exit 0 + + case "$TARGET" in + post-install) + add_modules + ;; + pre-remove) + remove_modules + ;; + *) + exit 1 + ;; + esac + ;; +*) + exit 1 + ;; +esac + +exit 0 diff --git a/srcpkgs/xbps-triggers/template b/srcpkgs/xbps-triggers/template index 9aaaa407f65..4d7e7777260 100644 --- a/srcpkgs/xbps-triggers/template +++ b/srcpkgs/xbps-triggers/template @@ -1,6 +1,6 @@ # Template file for 'xbps-triggers' pkgname=xbps-triggers -version=0.11 +version=0.12 build_style=custom-install short_desc="XBPS triggers" maintainer="Juan RP " @@ -8,6 +8,7 @@ long_desc=" This package installs the triggers used by the XBPS binary packages." noarch=yes +noextract=yes base_chroot=yes do_install()