|
@@ -165,21 +165,26 @@ usage() {
|
|
cat <<EOF
|
|
cat <<EOF
|
|
Usage: qemu-binfmt-conf.sh [--qemu-path PATH][--debian][--systemd CPU]
|
|
Usage: qemu-binfmt-conf.sh [--qemu-path PATH][--debian][--systemd CPU]
|
|
[--help][--credential yes|no][--exportdir PATH]
|
|
[--help][--credential yes|no][--exportdir PATH]
|
|
|
|
+ [--persistent yes|no][--qemu-suffix SUFFIX]
|
|
|
|
|
|
Configure binfmt_misc to use qemu interpreter
|
|
Configure binfmt_misc to use qemu interpreter
|
|
|
|
|
|
- --help: display this usage
|
|
|
|
- --qemu-path: set path to qemu interpreter ($QEMU_PATH)
|
|
|
|
- --debian: don't write into /proc,
|
|
|
|
- instead generate update-binfmts templates
|
|
|
|
- --systemd: don't write into /proc,
|
|
|
|
- instead generate file for systemd-binfmt.service
|
|
|
|
- for the given CPU. If CPU is "ALL", generate a
|
|
|
|
- file for all known cpus
|
|
|
|
- --exportdir: define where to write configuration files
|
|
|
|
- (default: $SYSTEMDDIR or $DEBIANDIR)
|
|
|
|
- --credential: if yes, credential and security tokens are
|
|
|
|
- calculated according to the binary to interpret
|
|
|
|
|
|
+ --help: display this usage
|
|
|
|
+ --qemu-path: set path to qemu interpreter ($QEMU_PATH)
|
|
|
|
+ --qemu-suffix: add a suffix to the default interpreter name
|
|
|
|
+ --debian: don't write into /proc,
|
|
|
|
+ instead generate update-binfmts templates
|
|
|
|
+ --systemd: don't write into /proc,
|
|
|
|
+ instead generate file for systemd-binfmt.service
|
|
|
|
+ for the given CPU. If CPU is "ALL", generate a
|
|
|
|
+ file for all known cpus
|
|
|
|
+ --exportdir: define where to write configuration files
|
|
|
|
+ (default: $SYSTEMDDIR or $DEBIANDIR)
|
|
|
|
+ --credential: if yes, credential and security tokens are
|
|
|
|
+ calculated according to the binary to interpret
|
|
|
|
+ --persistent: if yes, the interpreter is loaded when binfmt is
|
|
|
|
+ configured and remains in memory. All future uses
|
|
|
|
+ are cloned from the open file.
|
|
|
|
|
|
To import templates with update-binfmts, use :
|
|
To import templates with update-binfmts, use :
|
|
|
|
|
|
@@ -245,7 +250,15 @@ qemu_check_systemd() {
|
|
}
|
|
}
|
|
|
|
|
|
qemu_generate_register() {
|
|
qemu_generate_register() {
|
|
- echo ":qemu-$cpu:M::$magic:$mask:$qemu:$FLAGS"
|
|
|
|
|
|
+ flags=""
|
|
|
|
+ if [ "$CREDENTIAL" = "yes" ] ; then
|
|
|
|
+ flags="OC"
|
|
|
|
+ fi
|
|
|
|
+ if [ "$PERSISTENT" = "yes" ] ; then
|
|
|
|
+ flags="${flags}F"
|
|
|
|
+ fi
|
|
|
|
+
|
|
|
|
+ echo ":qemu-$cpu:M::$magic:$mask:$qemu:$flags"
|
|
}
|
|
}
|
|
|
|
|
|
qemu_register_interpreter() {
|
|
qemu_register_interpreter() {
|
|
@@ -264,10 +277,8 @@ package qemu-$cpu
|
|
interpreter $qemu
|
|
interpreter $qemu
|
|
magic $magic
|
|
magic $magic
|
|
mask $mask
|
|
mask $mask
|
|
|
|
+credential $CREDENTIAL
|
|
EOF
|
|
EOF
|
|
- if [ "$FLAGS" = "OC" ] ; then
|
|
|
|
- echo "credentials yes" >> "$EXPORTDIR/qemu-$cpu"
|
|
|
|
- fi
|
|
|
|
}
|
|
}
|
|
|
|
|
|
qemu_set_binfmts() {
|
|
qemu_set_binfmts() {
|
|
@@ -291,6 +302,7 @@ qemu_set_binfmts() {
|
|
qemu="$QEMU_PATH/qemu-i386"
|
|
qemu="$QEMU_PATH/qemu-i386"
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
+ qemu="$qemu$QEMU_SUFFIX"
|
|
if [ "$host_family" != "$family" ] ; then
|
|
if [ "$host_family" != "$family" ] ; then
|
|
$BINFMT_SET
|
|
$BINFMT_SET
|
|
fi
|
|
fi
|
|
@@ -304,9 +316,11 @@ SYSTEMDDIR="/etc/binfmt.d"
|
|
DEBIANDIR="/usr/share/binfmts"
|
|
DEBIANDIR="/usr/share/binfmts"
|
|
|
|
|
|
QEMU_PATH=/usr/local/bin
|
|
QEMU_PATH=/usr/local/bin
|
|
-FLAGS=""
|
|
|
|
|
|
+CREDENTIAL=no
|
|
|
|
+PERSISTENT=no
|
|
|
|
+QEMU_SUFFIX=""
|
|
|
|
|
|
-options=$(getopt -o ds:Q:e:hc: -l debian,systemd:,qemu-path:,exportdir:,help,credential: -- "$@")
|
|
|
|
|
|
+options=$(getopt -o ds:Q:S:e:hc:p: -l debian,systemd:,qemu-path:,qemu-suffix:,exportdir:,help,credential:,persistent: -- "$@")
|
|
eval set -- "$options"
|
|
eval set -- "$options"
|
|
|
|
|
|
while true ; do
|
|
while true ; do
|
|
@@ -342,6 +356,10 @@ while true ; do
|
|
shift
|
|
shift
|
|
QEMU_PATH="$1"
|
|
QEMU_PATH="$1"
|
|
;;
|
|
;;
|
|
|
|
+ -F|--qemu-suffix)
|
|
|
|
+ shift
|
|
|
|
+ QEMU_SUFFIX="$1"
|
|
|
|
+ ;;
|
|
-e|--exportdir)
|
|
-e|--exportdir)
|
|
shift
|
|
shift
|
|
EXPORTDIR="$1"
|
|
EXPORTDIR="$1"
|
|
@@ -352,11 +370,11 @@ while true ; do
|
|
;;
|
|
;;
|
|
-c|--credential)
|
|
-c|--credential)
|
|
shift
|
|
shift
|
|
- if [ "$1" = "yes" ] ; then
|
|
|
|
- FLAGS="OC"
|
|
|
|
- else
|
|
|
|
- FLAGS=""
|
|
|
|
- fi
|
|
|
|
|
|
+ CREDENTIAL="$1"
|
|
|
|
+ ;;
|
|
|
|
+ -p|--persistent)
|
|
|
|
+ shift
|
|
|
|
+ PERSISTENT="$1"
|
|
;;
|
|
;;
|
|
*)
|
|
*)
|
|
break
|
|
break
|