void-packages

Void Source Packages
git clone git://ezup.dev/void-packages.git
Log | Files | Refs | README | LICENSE

binfmts (1215B)


      1#!/bin/sh
      2#
      3# binfmts trigger.
      4#
      5# Binaries can be specified like:
      6#  binfmts="<path> [<args> ...]"
      7#
      8# Arguments:	$ACTION = [run/targets]
      9#		$TARGET = [post-install/pre-remove]
     10#		$PKGNAME
     11#		$VERSION
     12#		$UPDATE = [yes/no]
     13#
     14ACTION="$1"
     15TARGET="$2"
     16PKGNAME="$3"
     17VERSION="$4"
     18UPDATE="$5"
     19
     20export PATH="usr/bin:usr/sbin:/usr/sbin:/usr/bin:/sbin:/bin"
     21
     22case "$ACTION" in
     23targets)
     24	echo "post-install pre-remove"
     25	;;
     26run)
     27	[ -x /usr/bin/update-binfmts ] || exit 0
     28	[ -z "${binfmts}" ] && exit 0
     29
     30	case "$TARGET" in
     31	post-install)
     32		echo "$binfmts" | tr '\' '&' 2> /dev/null | while read line; do
     33			line=$(echo $line | tr '&' '\' 2> /dev/null)
     34			set -- ${line}
     35			_bin="$1"; shift; _args="$@"; _bname="$(basename ${_bin})"
     36			update-binfmts --package ${PKGNAME} --install ${_bname} ${_bin} ${_args}
     37		done
     38		;;
     39	pre-remove)
     40		echo "$binfmts" | tr '\' '&' 2> /dev/null | while read line; do
     41			line=$(echo $line | tr '&' '\' 2> /dev/null)
     42			set -- ${line}
     43			_bin="$1"; shift; _args="$@"; _bname="$(basename ${_bin})"
     44			if [ -f /var/lib/binfmts/${_bname} ]; then
     45				update-binfmts --package ${PKGNAME} --remove ${_bname} ${_bin}
     46			fi
     47		done
     48		;;
     49	*)
     50		exit 1
     51		;;
     52	esac
     53	;;
     54*)
     55	exit 1
     56	;;
     57esac
     58
     59exit 0
     60# end
     61# end