1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
#!/bin/bash
#dash is fine, too, but not general /bin/sh (ulimit)
set -e
if [ "$1" = install -o "$1" = upgrade ]; then
# Writing to /usr/lib is nasty but some folks mount everything noexec.
FILE=`mktemp /usr/lib/&NAME&-support.XXXXXXXXXX`
trap "rm -f '$FILE'" EXIT
perl <<'END' |gzip -cdf >"$FILE"
binmode STDOUT;
print unpack "u*", <<'end';
&UUENCODED&
END
chmod u+x "$FILE"
# "exec >;command" instead of "command >" looks strange but regular
# redirections don't fully work within qemu-user.
ret=0;(ulimit -c 0; exec >/dev/null 2>&1; "$FILE") || ret=$?
rm -f "$FILE"
trap - EXIT
if [ $ret -ne 0 -a -n "$IGNORE_ISA" ]; then
cat >&2 <<END
This machine doesn't support &NAME&, but override (IGNORE_ISA) is enabled.
Continuing...
END
ret=0
fi
if [ $ret -eq 126 ]; then
cat >&2 <<END
Couldn't execute test binary for &NAME&, you either do foreign multi-arch
without qemu or do something strange. Assuming you know what you're doing.
Continuing...
END
ret=0
fi
if [ $ret -ne 0 ]; then
# Fail noisily, first via debconf (if installed).
if [ -e /usr/share/debconf/confmodule ]; then
. /usr/share/debconf/confmodule
db_version 2.0
db_fset &NAME&-support/fail seen false ||:
db_reset &NAME&-support/fail ||:
db_input critical &NAME&-support/fail ||:
db_go ||:
db_stop ||:
fi
cat >&2 <<END
This machine doesn't support &NAME&, sorry.
Aborting.
END
exit 2
fi
fi
#DEBHELPER#
exit 0
|