~ubuntu-branches/ubuntu/trusty/vips/trusty

« back to all changes in this revision

Viewing changes to tools/vips-7.36

  • Committer: Package Import Robot
  • Author(s): Jay Berkenbilt
  • Date: 2014-03-29 12:29:29 UTC
  • mfrom: (1.1.21) (30.1.16 sid)
  • Revision ID: package-import@ubuntu.com-20140329122929-fvxnaann32ex0gzk
Tags: 7.38.5-2
Enable dh-autoreconf. (Closes: #742872)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/bash
2
 
#
3
 
# Start script for VIPS
4
 
 
5
 
# need extended regexps, hence we insist on bash above
6
 
shopt -s extglob 
7
 
# set -x
8
 
 
9
 
# name we were invoked as
10
 
bname=`basename $0`
11
 
 
12
 
# check args
13
 
if [[ $# < 1 ]]; then
14
 
        echo "usage: $bname [command ...]"
15
 
        echo "examples:"
16
 
        echo "    $bname man im_invert"
17
 
        echo "    $bname vips im_invert /pics/tmp/fred.jpg /pics/tmp/fred2.tif"
18
 
        exit 1
19
 
fi
20
 
 
21
 
# prepend a path component to an environment variable
22
 
# be careful to avoid trailing : characters if the var is not defined, they
23
 
# can cause security problems
24
 
function prepend_var () {
25
 
        # we have to use eval to do double indirection, I think
26
 
        eval value="\$$1"
27
 
        if [ "x$value" = x ]; then
28
 
                export $1=$2
29
 
        else 
30
 
                export $1=$2:$value
31
 
        fi
32
 
}
33
 
 
34
 
# try to extract the prefix from a path to an executable
35
 
# eg. "/home/john/vips/bin/fred" -> "/home/john/vips"
36
 
function find_prefix () {
37
 
        # try to canonicalise the path
38
 
        ep_canon=$1
39
 
 
40
 
        # relative path? prefix with pwd
41
 
        if [ ${ep_canon:0:1} != "/" ]; then
42
 
                ep_canon=`pwd`/$ep_canon
43
 
        fi
44
 
 
45
 
        # replace any "/./" with "/"
46
 
        ep_canon=${ep_canon//\/.\//\/}
47
 
 
48
 
        # any "xxx/../" can go 
49
 
        ep_canon=${ep_canon//+([^\/])\/..\//}
50
 
 
51
 
        # trailing "xxx/.." can go 
52
 
        ep_canon=${ep_canon/%+([^\/])\/../}
53
 
 
54
 
        # remove trailing "/bin/xxx" to get the prefix
55
 
        ep_prefix=${ep_canon/%\/bin\/+([^\/])/}
56
 
 
57
 
        # was there anything to remove in that final step? if not, the path 
58
 
        # must be wrong
59
 
        if [ x$ep_prefix == x$ep_canon ]; then
60
 
                return 1
61
 
        fi
62
 
 
63
 
        echo $ep_prefix;
64
 
 
65
 
        return 0
66
 
}
67
 
 
68
 
# try to guess the install prefix from $0
69
 
function guess_prefix () {
70
 
        # $0 is a file? must be us
71
 
        if [ -f $0 ]; then
72
 
                find_prefix $0
73
 
                return 
74
 
        fi
75
 
 
76
 
        # nope, extract program name from $0 and try looking along the
77
 
        # searchpath for it
78
 
        name=`basename $0`
79
 
 
80
 
        fred=$PATH
81
 
        while [ x$fred != x"" ]; do
82
 
                path=${fred/:*/}/$name
83
 
                fred=${fred/*([^:])?(:)/}
84
 
 
85
 
                if [ -f $path ]; then
86
 
                        find_prefix $path
87
 
                        return 
88
 
                fi
89
 
        done
90
 
 
91
 
        # not found on path either ... give up!
92
 
        return 1
93
 
}
94
 
 
95
 
prefix=`guess_prefix`;
96
 
 
97
 
if [ $? != 0 ]; then
98
 
        echo "unable to find $0 from the file name, or from your PATH"
99
 
        echo "either run directly, or add the install bin area to "
100
 
        echo "your PATH"
101
 
        exit 1
102
 
fi
103
 
 
104
 
export VIPSHOME=$prefix
105
 
 
106
 
# add VIPSHOME to man pages
107
 
prepend_var MANPATH $VIPSHOME/man
108
 
 
109
 
# add the VIPS lib area to the library path
110
 
case `uname` in
111
 
HPUX)
112
 
        libvar=SHLIB_PATH 
113
 
        ;;
114
 
 
115
 
Darwin)
116
 
        libvar=DYLD_LIBRARY_PATH
117
 
        ;;
118
 
 
119
 
*)
120
 
        libvar=LD_LIBRARY_PATH
121
 
        ;;
122
 
esac
123
 
prepend_var $libvar $VIPSHOME/lib
124
 
 
125
 
# add VIPS bin area to path
126
 
prepend_var PATH $VIPSHOME/bin
127
 
 
128
 
# run, passing in args we were passed
129
 
exec $*