forked from libvips/libvips
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vips-8.13
executable file
·129 lines (102 loc) · 2.52 KB
/
vips-8.13
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/bash
#
# Start script for VIPS
# need extended regexps, hence we insist on bash above
shopt -s extglob
# set -x
# name we were invoked as
bname=`basename $0`
# check args
if [[ $# < 1 ]]; then
echo "usage: $bname [command ...]"
echo "examples:"
echo " $bname man vipsthumbnail"
echo " $bname vips invert /pics/tmp/fred.jpg /pics/tmp/fred2.tif"
exit 1
fi
# prepend a path component to an environment variable
# be careful to avoid trailing : characters if the var is not defined, they
# can cause security problems
function prepend_var () {
# we have to use eval to do double indirection, I think
eval value="\$$1"
if [ "x$value" = x ]; then
export $1=$2
else
export $1=$2:$value
fi
}
# try to extract the prefix from a path to an executable
# eg. "/home/john/vips/bin/fred" -> "/home/john/vips"
function find_prefix () {
# try to canonicalise the path
ep_canon=$1
# relative path? prefix with pwd
if [ ${ep_canon:0:1} != "/" ]; then
ep_canon=`pwd`/$ep_canon
fi
# replace any "/./" with "/"
ep_canon=${ep_canon//\/.\//\/}
# any "xxx/../" can go
ep_canon=${ep_canon//+([^\/])\/..\//}
# trailing "xxx/.." can go
ep_canon=${ep_canon/%+([^\/])\/../}
# remove trailing "/bin/xxx" to get the prefix
ep_prefix=${ep_canon/%\/bin\/+([^\/])/}
# was there anything to remove in that final step? if not, the path
# must be wrong
if [ x$ep_prefix == x$ep_canon ]; then
return 1
fi
echo $ep_prefix;
return 0
}
# try to guess the install prefix from $0
function guess_prefix () {
# $0 is a file? must be us
if [ -f $0 ]; then
find_prefix $0
return
fi
# nope, extract program name from $0 and try looking along the
# searchpath for it
name=`basename $0`
fred=$PATH
while [ x$fred != x"" ]; do
path=${fred/:*/}/$name
fred=${fred/*([^:])?(:)/}
if [ -f $path ]; then
find_prefix $path
return
fi
done
# not found on path either ... give up!
return 1
}
prefix=`guess_prefix`;
if [ $? != 0 ]; then
echo "unable to find $0 from the file name, or from your PATH"
echo "either run directly, or add the install bin area to "
echo "your PATH"
exit 1
fi
export VIPSHOME=$prefix
# add VIPSHOME to various paths
prepend_var MANPATH $VIPSHOME/share/man
case `uname` in
HPUX)
libvar=SHLIB_PATH
;;
Darwin)
libvar=DYLD_LIBRARY_PATH
;;
*)
libvar=LD_LIBRARY_PATH
;;
esac
prepend_var $libvar $VIPSHOME/lib
prepend_var PATH $VIPSHOME/bin
prepend_var PKG_CONFIG_PATH $VIPSHOME/lib/pkgconfig
prepend_var GI_TYPELIB_PATH $VIPSHOME/lib/girepository-1.0
# run, passing in args we were passed
exec $*