File: patch-magic-file

package info (click to toggle)
dact 0.8.42-6
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,444 kB
  • sloc: ansic: 5,923; sh: 2,748; makefile: 116
file content (51 lines) | stat: -rwxr-xr-x 1,034 bytes parent folder | download | duplicates (6)
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