diff --git a/srcpkgs/xbps-triggers/files/initramfs-tools b/srcpkgs/xbps-triggers/files/initramfs-tools deleted file mode 100755 index 816b52da91..0000000000 --- a/srcpkgs/xbps-triggers/files/initramfs-tools +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh -e -# -# Runs update-initramfs(8) to update initramfs for all installed kernels. -# -# 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" - -update_initramfs=usr/sbin/update-initramfs - -case "$ACTION" in -targets) - echo "post-install post-remove" - ;; -run) - # Exit if the command cannot be executed. - [ ! -x ${update_initramfs} ] && exit 0 - - # Cannot continue if /proc and /sys not mounted! - if [ ! -e ./proc/filesystems -a ! -e ./sys/kernel/vmcoreinfo ]; then - echo "initramfs-tools trigger:" - echo "WARNING: /proc and /sys (relative to cwd) are not mounted" - echo "WARNING: cannot continue, exiting..." - exit 0 - fi - - # Always use relative paths to create the initramfs! - initramfs_args="-b ./boot" - - # Update initramfs for all kernels - initramfs_args="$initramfs_args -u -t -k all" - - env ROOTDIR="." ${update_initramfs} ${initramfs_args} - exit $? - - ;; -*) - exit 1 - ;; -esac - -exit 0 diff --git a/srcpkgs/xbps-triggers/files/systemd-service b/srcpkgs/xbps-triggers/files/systemd-service index 72b665b532..8ccb637e55 100755 --- a/srcpkgs/xbps-triggers/files/systemd-service +++ b/srcpkgs/xbps-triggers/files/systemd-service @@ -1,13 +1,19 @@ #!/bin/sh # -# Enable and disable systemd services. The systemd_services environmental -# variable is expected to be set as follows: +# systemd trigger to enable/disable services, create/remove files via +# systemd-tmpfiles(5) and load/unload modules via modules-load.d(5). # -# SERVICE_NAME RESTART -# foo.service off -# blah.service on +# The following env vars are recognized: +# - systemd_services (expects at least two arguments: service name +# and a boolean to restart automatically the service on upgrade). +# - systemd_tmpfiles (expects a black separated list of fileanmes). +# - systemd_modules (expects a blank separated list of filenames). # -# i.e systemd_services='foo.service off blah.service on' +# Examples: + +# systemd_services="foo.service off blah.service on" +# systemd_tmpfiles="foo.conf blah.conf" +# systemd_modules="foo.conf blah.conf" # # Arguments: $ACTION = [run/targets] # $TARGET = [post-install/pre-remove] @@ -29,7 +35,7 @@ targets) ;; run) [ ! -x bin/systemctl ] && exit 0 - [ -z "${systemd_services}" ] && exit 1 + [ -z "$systemd_services" -a -z "$systemd_tmpfiles" -a -z "$systemd_modules" ] && exit 1 systemd-notify --booted if [ $? -eq 0 ]; then @@ -59,8 +65,9 @@ run) # Package update, just disable the unit. echo "Disabling systemd service ${_srv}..." systemctl --no-reload disable ${_srv} >/dev/null 2>&1 || : + fi - elif [ "$TARGET" = "post-install" ]; then + else if [ "$UPDATE" = "no" ]; then # package is being installed. # enable (but don't start) the unit by default. @@ -106,6 +113,25 @@ _EOF fi shift; shift done + if [ "$TARGET" = "pre-remove" ]; then + # Unload the modules specified in systemd_modules files. + for f in ${systemd_modules}; do + for j in $(cat usr/lib/modules-load.d/${f}); do + modprobe -rq ${j} || : + done + done + else + # Create stuff specified in systemd_tmpfiles files. + for f in ${systemd_tmpfiles}; do + systemd-tmpfiles --create ${f} || : + done + # Load modules specified in systemd_modules files. + for f in ${systemd_modules}; do + for j in $(cat usr/lib/modules-load.d/${f}); do + modprobe -q ${j} || : + done + done + fi ;; *) exit 1 diff --git a/srcpkgs/xbps-triggers/template b/srcpkgs/xbps-triggers/template index f821b2c3f1..4bb0ad372b 100644 --- a/srcpkgs/xbps-triggers/template +++ b/srcpkgs/xbps-triggers/template @@ -1,10 +1,7 @@ # Template file for 'xbps-triggers' pkgname=xbps-triggers -version=0.46 +version=0.47 revision=1 -noarch=yes -noextract=yes -bootstrap=yes short_desc="XBPS triggers" maintainer="Juan RP " homepage="http://code.google.com/p/xbps" @@ -12,6 +9,10 @@ license="Simplified BSD" long_desc=" This package installs the triggers used by the XBPS binary packages." +noarch=yes +noextract=yes +bootstrap=yes + do_install() { _triggersdir=var/db/xbps/triggers