xbps-triggers: remove initramfs-tools, improve systemd-service.
The systemd-service trigger has been improved and now will also handle files in modules-load.d(5) and tmpfiles.d(5).
This commit is contained in:
parent
ca19cb992d
commit
178e50545d
3 changed files with 39 additions and 64 deletions
|
@ -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
|
|
|
@ -1,13 +1,19 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# Enable and disable systemd services. The systemd_services environmental
|
# systemd trigger to enable/disable services, create/remove files via
|
||||||
# variable is expected to be set as follows:
|
# systemd-tmpfiles(5) and load/unload modules via modules-load.d(5).
|
||||||
#
|
#
|
||||||
# SERVICE_NAME RESTART
|
# The following env vars are recognized:
|
||||||
# foo.service off
|
# - systemd_services (expects at least two arguments: service name
|
||||||
# blah.service on
|
# 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]
|
# Arguments: $ACTION = [run/targets]
|
||||||
# $TARGET = [post-install/pre-remove]
|
# $TARGET = [post-install/pre-remove]
|
||||||
|
@ -29,7 +35,7 @@ targets)
|
||||||
;;
|
;;
|
||||||
run)
|
run)
|
||||||
[ ! -x bin/systemctl ] && exit 0
|
[ ! -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
|
systemd-notify --booted
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
|
@ -59,8 +65,9 @@ run)
|
||||||
# Package update, just disable the unit.
|
# Package update, just disable the unit.
|
||||||
echo "Disabling systemd service ${_srv}..."
|
echo "Disabling systemd service ${_srv}..."
|
||||||
systemctl --no-reload disable ${_srv} >/dev/null 2>&1 || :
|
systemctl --no-reload disable ${_srv} >/dev/null 2>&1 || :
|
||||||
|
|
||||||
fi
|
fi
|
||||||
elif [ "$TARGET" = "post-install" ]; then
|
else
|
||||||
if [ "$UPDATE" = "no" ]; then
|
if [ "$UPDATE" = "no" ]; then
|
||||||
# package is being installed.
|
# package is being installed.
|
||||||
# enable (but don't start) the unit by default.
|
# enable (but don't start) the unit by default.
|
||||||
|
@ -106,6 +113,25 @@ _EOF
|
||||||
fi
|
fi
|
||||||
shift; shift
|
shift; shift
|
||||||
done
|
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
|
exit 1
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
# Template file for 'xbps-triggers'
|
# Template file for 'xbps-triggers'
|
||||||
pkgname=xbps-triggers
|
pkgname=xbps-triggers
|
||||||
version=0.46
|
version=0.47
|
||||||
revision=1
|
revision=1
|
||||||
noarch=yes
|
|
||||||
noextract=yes
|
|
||||||
bootstrap=yes
|
|
||||||
short_desc="XBPS triggers"
|
short_desc="XBPS triggers"
|
||||||
maintainer="Juan RP <xtraeme@gmail.com>"
|
maintainer="Juan RP <xtraeme@gmail.com>"
|
||||||
homepage="http://code.google.com/p/xbps"
|
homepage="http://code.google.com/p/xbps"
|
||||||
|
@ -12,6 +9,10 @@ license="Simplified BSD"
|
||||||
long_desc="
|
long_desc="
|
||||||
This package installs the triggers used by the XBPS binary packages."
|
This package installs the triggers used by the XBPS binary packages."
|
||||||
|
|
||||||
|
noarch=yes
|
||||||
|
noextract=yes
|
||||||
|
bootstrap=yes
|
||||||
|
|
||||||
do_install() {
|
do_install() {
|
||||||
_triggersdir=var/db/xbps/triggers
|
_triggersdir=var/db/xbps/triggers
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue