-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·157 lines (132 loc) · 3.6 KB
/
install.sh
File metadata and controls
executable file
·157 lines (132 loc) · 3.6 KB
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/bin/sh
###
### Install package for SFML 2.1 on OS X
###
### Author: Marco Antognini <antognini.marco@gmail.com>
### Date: 26/07/2013
###
### This script install the following:
###
### cmake/ into /usr/local/share/SFML/cmake/
### doc/ into /usr/local/share/SFML/doc/
### examples/ into /usr/local/share/SFML/examples/
### extlibs/ into /Library/Frameworks/
### Frameworks/ into /Library/Frameworks/
### include/ into /usr/local/include/
### lib/ into /usr/local/lib/
### license.txt into /usr/local/share/SFML/
### readme.txt into /usr/local/share/SFML/
### templates/ into /Library/Developer/Xcode/Templates/
###
### It will NOT remove any previous versions.
### Hence, if you have the frameworks of SFML 2.0 installed
### you will keep this runtime (the two verions will be merged).
###
### USAGE
###
### $0 [package]
###
### Package is optional. It represent the path to a package.
### If not present, package is assumed to be $(dirname "$0")
###
### When installing frameworks the script will ask you for
### your password.
###
##
## HELPER FUNCTIONS
##
## Echoes to stderr, and die
error () # $* message to display
{
echo "$@" 1>&2
exit 2
}
## Check that the number of parameters is correct
param_check () # $1 should be $# on call site,
# $2 the number of required params,
# $3 an id for the error message
{
if [ $# -ne 3 ]
then
error "Internal error in param_error: the number of parameters is incorrect"
fi
if [ $1 -ne $2 ]
then
error "Internal error in $3: the number of parameters is incorrect"
fi
}
## Check that the number of parameters is enough
param_check_ge () # $1 should be $# on call site,
# $2 the minimal number of parames,
# $3 an id for the error message
{
param_check $# 3 "param_check_ge"
if [ $1 -lt $2 ]
then
error "Internal error in $3: the number of parameters is not enough"
fi
}
## Assert $1 is true, or die
assert () # $1: boolean, $2: an error message
{
param_check $# 2 "assert"
if [ $1 -ne 0 ]
then
error "$2"
fi
}
## Create directory, or die
# === mkdir -p $1
create_dir () # $1: path
{
param_check $# 1 "create_dir"
mkdir -p "$1"
assert $? "Couldn't create $1"
}
## Destroy directory, or die
# === rm -fr $1
destroy () # $1: path
{
param_check $# 1 "destroy"
rm -fr "$1"
assert $? "Couldn't destroy $1"
}
## Copy files/directories, recursively, or die
install () # $1...N: src, $N+1: dest
{
param_check_ge $# 2 "install"
ditto "$@"
assert $? "Couldn't install $1"
}
## [with root access] Copy files/directories, recursively, or die
sudo_install () # $1...N: src, $N+1: dest
{
param_check_ge $# 2 "install"
sudo ditto "$@"
assert $? "Couldn't install $1"
}
##
## MAIN FUNCTION
##
if [ -n "$1" ]
then
package="$1"
else
package=$(dirname "$0")
fi
echo "INSTALLING PACKAGE $package"
cd "$package"
assert $? "Couldn't go to the package directory $package"
echo "Installing Frameworks [with root access]"
sudo_install "extlibs/" "Frameworks/" "/Library/Frameworks"
echo "Installing dylibs"
install "lib/" "/usr/local/lib/"
install "include/" "/usr/local/include/"
echo "Installing misc"
create_dir "/usr/local/share/SFML/"
install "cmake" "/usr/local/share/SFML/cmake/"
install "doc" "/usr/local/share/SFML/doc/"
install "examples" "/usr/local/share/SFML/examples/"
install "license.txt" "readme.txt" "/usr/local/share/SFML/"
install "templates/" "/Library/Developer/Xcode/Templates/"
echo "Installation DONE"