/
build.sh
executable file
·57 lines (50 loc) · 1.7 KB
/
build.sh
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
#!/bin/sh
file_version="5.11"
build_file=0
if [ ! -f bin/file -o ! -f lib/libmagic.so ]
then
echo "file(1) is not installed"
build_file=1
else
installed_file_version=`bin/file -v | grep -Eo "[0-9]\.[0-9]+"`
echo "file(1) $installed_file_version is installed, expecting $file_version"
if [ "$installed_file_version" != "$file_version" ]
then
make purge
build_file=1
fi
fi
if [ ! -d src/file-$file_version ]
then
cd arc
tar -xf file-$file_version.tar.gz
mkdir ../src
mv file-$file_version ../src
cd ..
fi
if [ $build_file -eq 1 ]
then
cd src/file-$file_version
./configure
make
cd ../../
cp src/file-$file_version/magic/magic.mgc share
cp src/file-5.11/src/.libs/file bin/file
cp src/file-5.11/src/.libs/libmagic.so lib/libmagic.so
echo "--[DEBUG]--"
echo "Version information:"
# print the version info for debug purposes
LD_LIBRARY_PATH=lib bin/file --magic-file share/magic.mgc -v
echo
# execute simple lookups to test the installation
echo "Testing the installation:"
LD_LIBRARY_PATH=lib bin/file --magic-file share/magic.mgc --mime-type --brief tests/data/foo
LD_LIBRARY_PATH=lib bin/file --magic-file share/magic.mgc --mime-type --brief tests/data/foo.pdf
LD_LIBRARY_PATH=lib bin/file --magic-file share/magic.mgc --mime-type --brief tests/data/foo.txt
LD_LIBRARY_PATH=lib bin/file --magic-file share/magic.mgc --mime-type --brief tests/data/foo.txt.bz2
LD_LIBRARY_PATH=lib bin/file --magic-file share/magic.mgc --mime-type --brief tests/data/foo.txt.gz
LD_LIBRARY_PATH=lib bin/file --magic-file share/magic.mgc --mime-type --brief tests/data/foo.txt.tar
LD_LIBRARY_PATH=lib bin/file --magic-file share/magic.mgc --mime-type --brief tests/data/foo.txt.zip
echo "--[DEBUG]--"
fi
exit 0