dist.src/install.sh

changeset 50
d26da280c934
parent 27
e6e7e63b8b5e
child 111
cb128bae1161
equal deleted inserted replaced
49:68cc8e282a26 50:d26da280c934
1 #!/bin/sh
2
3 PREFIX=/usr/local
4
5 # help text
6 printhelp()
7 {
8 echo "Usage: $0 [PREFIX=<path>]"
9 echo
10 echo "Default PREFIX: /usr/local"
11 }
12
13 # error function
14 exit_on_error()
15 {
16 echo "$1"
17 exit 1
18 }
19
20 #
21 # parse arguments
22 #
23 for arg in "$@"
24 do
25 case "$arg" in
26 "PREFIX="*) PREFIX=${arg#PREFIX=} ;;
27 "--help"*) printhelp; exit 1 ;;
28 "-"*) echo "unknown option: $arg"; exit 1 ;;
29 esac
30 done
31
32 #
33 # create install dir
34 #
35 echo "mkdir -p $PREFIX/lib/uwproj $PREFIX/bin"
36 mkdir -p "$PREFIX/lib/uwproj" "$PREFIX/bin" \
37 || exit_on_error "Creating install directory failed."
38
39 #
40 # install the JAR file
41 #
42 echo "cp ../target/uwproj-${project.version}-jar-with-dependencies.jar $PREFIX/lib/uwproj/uwproj-${project.version}.jar"
43 cp "../target/uwproj-${project.version}-jar-with-dependencies.jar" "$PREFIX/lib/uwproj/uwproj-${project.version}.jar" \
44 || exit_on_error "Installing JAR file failed."
45
46 #
47 # create a run script in the bin dir
48 #
49 echo "cp bin/uwproj $PREFIX/bin"
50 sed "s:%%PREFIX%%:$PREFIX:g" "bin/uwproj" > "$PREFIX/bin/uwproj" \
51 || exit_on_error "Creating run script failed."
52
53 echo "chmod 0555 $PREFIX/bin/uwproj"
54 chmod 0755 "$PREFIX/bin/uwproj" \
55 || exit_on_error "Changing permissions for run script failed."
56
57 echo
58 echo "uwproj has been successfully installed."

mercurial