From 9416d77890de35f56c810c6eb9ed49b2c39cb9fa Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sun, 10 Jul 2011 00:03:17 +0200 Subject: [PATCH] xbps-triggers: new kernel-hooks trigger, simplify initramfs-tools. --- srcpkgs/xbps-triggers/files/initramfs-tools | 22 ++------- srcpkgs/xbps-triggers/files/kernel-hooks | 55 +++++++++++++++++++++ srcpkgs/xbps-triggers/template | 11 ++--- 3 files changed, 62 insertions(+), 26 deletions(-) create mode 100755 srcpkgs/xbps-triggers/files/kernel-hooks diff --git a/srcpkgs/xbps-triggers/files/initramfs-tools b/srcpkgs/xbps-triggers/files/initramfs-tools index 81416d23704..a8b3bce98da 100755 --- a/srcpkgs/xbps-triggers/files/initramfs-tools +++ b/srcpkgs/xbps-triggers/files/initramfs-tools @@ -1,8 +1,6 @@ #!/bin/sh -e # -# Runs update-initramfs(8) to create/update an initramfs for specified -# version (if the pkg that is triggering it) or for the currently -# installed kernel otherwise. +# Runs update-initramfs(8) to update initramfs for all installed kernels. # # Arguments: $ACTION = [run/targets] # $TARGET = [post-install/post-remove] @@ -39,22 +37,8 @@ run) # Always use relative paths to create the initramfs! initramfs_args="-b ./boot" - if [ "$PKGNAME" = "kernel" ]; then - if [ "$TARGET" = "post-remove" ]; then - # Remove the initramfs if removing. - initramfs_args="$initramfs_args -d -k ${VERSION}" - fi - if [ ! -f var/lib/initramfs-tools/${VERSION} ]; then - # Create new initramfs - initramfs_args="$initramfs_args -c -t -k ${VERSION}" - else - # Update existing initramfs - initramfs_args="$initramfs_args -B -u -t -k ${VERSION}" - fi - else - # Update initramfs for all kernels - initramfs_args="$initramfs_args -B -u -t -k all" - fi + # Update initramfs for all kernels + initramfs_args="$initramfs_args -u -t -k all" ${update_initramfs} ${initramfs_args} exit $? diff --git a/srcpkgs/xbps-triggers/files/kernel-hooks b/srcpkgs/xbps-triggers/files/kernel-hooks new file mode 100755 index 00000000000..2faa6368750 --- /dev/null +++ b/srcpkgs/xbps-triggers/files/kernel-hooks @@ -0,0 +1,55 @@ +#!/bin/sh -e +# +# Run scripts found in /etc/kernel.d/ directories. +# +# Arguments: $ACTION = [run/targets] +# $TARGET = [post-install/post-remove] +# $PKGNAME +# $VERSION +# $UPDATE = [yes/no] +# +ACTION="$1" +TARGET="$2" +PKGNAME="$3" +VERSION="$4" +UPDATE="$5" + +export PATH="$PATH:/usr/local/bin" + +RUN_TARGETS="pre-install post-install pre-remove post-remove" + +case "$ACTION" in +targets) + echo "${RUN_TARGETS}" + ;; +run) + # Ignore pre-remove when updating a package. + if [ "${TARGET}" = "pre-remove" ]; then + [ "${UPDATE}" = "yes" ] && exit 0 + fi + + # Create required dirs when necessary. + for _dir_ in ${RUN_TARGETS}; do + [ ! -d etc/kernel.d/${_dir_} ] && mkdir -p etc/kernel.d/${_dir_} + done + + # Execute kernel hooks for the specified target. + for _file_ in /etc/kernel.d/${TARGET}/*; do + [ ! -x "${_file_}" ] && continue + echo "Executing ${TARGET} kernel hook: $(basename ${_file_}) ..." + + # A package may export "kernel_hooks_version" as a hint + # to pass this version to the hooks. + if [ -n "${kernel_hooks_version}" ]; then + ${_file_} ${PKGNAME} ${kernel_hooks_version} + else + ${_file_} ${PKGNAME} ${VERSION} + fi + done + ;; +*) + exit 1 + ;; +esac + +exit 0 diff --git a/srcpkgs/xbps-triggers/template b/srcpkgs/xbps-triggers/template index 74acbaa6302..b12e299312e 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.17 +version=0.18 build_style=custom-install short_desc="XBPS triggers" maintainer="Juan RP " @@ -15,14 +15,11 @@ bootstrap=yes do_install() { - _triggersdir=${DESTDIR}/var/db/xbps/triggers - - install -d ${_triggersdir} + _triggersdir=var/db/xbps/triggers for f in ${FILESDIR}/*; do _trigger=$(basename $f) - install -m750 ${FILESDIR}/${_trigger} \ - ${_triggersdir}/${_trigger} - echo "# end" >> ${_triggersdir}/${_trigger} + vinstall ${FILESDIR}/${_trigger} 750 ${_triggersdir} + echo "# end" >> ${DESTDIR}/${_triggersdir}/${_trigger} done }