xbps-triggers: new kernel-hooks trigger, simplify initramfs-tools.
This commit is contained in:
parent
b2c180073d
commit
9416d77890
3 changed files with 62 additions and 26 deletions
|
@ -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 $?
|
||||
|
|
55
srcpkgs/xbps-triggers/files/kernel-hooks
Executable file
55
srcpkgs/xbps-triggers/files/kernel-hooks
Executable file
|
@ -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
|
|
@ -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 <xtraeme@gmail.com>"
|
||||
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue