1
0
Fork 0
mirror of https://github.com/xHyroM/void-packages.git synced 2024-11-24 15:21:06 +01:00
void-packages/srcpkgs/xbps-triggers/files/binfmts

62 lines
1.2 KiB
Text
Raw Normal View History

2024-03-30 14:09:59 +01:00
#!/bin/sh
#
# binfmts trigger.
#
# Binaries can be specified like:
# binfmts="<path> [<args> ...]"
#
# Arguments: $ACTION = [run/targets]
# $TARGET = [post-install/pre-remove]
# $PKGNAME
# $VERSION
# $UPDATE = [yes/no]
#
ACTION="$1"
TARGET="$2"
PKGNAME="$3"
VERSION="$4"
UPDATE="$5"
export PATH="usr/bin:usr/sbin:/usr/sbin:/usr/bin:/sbin:/bin"
case "$ACTION" in
targets)
echo "post-install pre-remove"
;;
run)
[ -x /usr/bin/update-binfmts ] || exit 0
[ -z "${binfmts}" ] && exit 0
case "$TARGET" in
post-install)
echo "$binfmts" | tr '\' '&' 2> /dev/null | while read line; do
line=$(echo $line | tr '&' '\' 2> /dev/null)
set -- ${line}
_bin="$1"; shift; _args="$@"; _bname="$(basename ${_bin})"
update-binfmts --package ${PKGNAME} --install ${_bname} ${_bin} ${_args}
done
;;
pre-remove)
echo "$binfmts" | tr '\' '&' 2> /dev/null | while read line; do
line=$(echo $line | tr '&' '\' 2> /dev/null)
set -- ${line}
_bin="$1"; shift; _args="$@"; _bname="$(basename ${_bin})"
if [ -f /var/lib/binfmts/${_bname} ]; then
update-binfmts --package ${PKGNAME} --remove ${_bname} ${_bin}
fi
done
;;
*)
exit 1
;;
esac
;;
*)
exit 1
;;
esac
exit 0
# end
# end