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
|
#! /bin/sh
if test $1 = "prefix"; then
prefix=$2
shift
shift
fi
if test -w "$1" -a ! "$1" = ""; then
MAGIC="$1"
elif test -w ${prefix}/usr/share/magic; then
MAGIC="${prefix}/usr/share/magic"
elif test -w ${prefix}/usr/local/share/magic; then
MAGIC="${prefix}/usr/local/share/magic"
elif test -w ${prefix}/etc/magic; then
MAGIC="${prefix}/etc/magic"
else
echo "Cannot find magic file to patch."
exit
fi
if grep "^[^#].*belong" $MAGIC 2>/dev/null >/dev/null; then
LONG=belong
SHORT=beshort
else
LONG=long
SHORT=short
fi
if grep "\\\\b" $MAGIC 2>/dev/null >/dev/null; then
BS="\\b"
else
BS=""
fi
if grep DACT $MAGIC 2>/dev/null >/dev/null; then
exit
else
echo "
#------------------------------------------------------------------------------
# dact: file(1) magic for DACT compressed files
#
0 $LONG 0x444354C3 DACT compressed data
>4 byte >-1 (version %i.
>5 byte >-1 $BS%i.
>6 byte >-1 $BS%i)
>7 $LONG >0 $BS, original size: %i bytes
>15 $LONG >30 $BS, block size: %i bytes
" >> $MAGIC
fi
|