-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfigure-giflib
More file actions
executable file
·262 lines (226 loc) · 4.54 KB
/
configure-giflib
File metadata and controls
executable file
·262 lines (226 loc) · 4.54 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
#!/bin/sh -eu
# configure-giflib: download and configure giflib
# Copyright (C) 2018 "Michael G. Morey" <mgmorey@gmail.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
GIFLIB_ARCHIVE_DIR="$HOME/Downloads/GIFLIB"
GIFLIB_ARCHIVE_SUFFIX=.tar.gz
GIFLIB_OPT_PREFIX=/opt/%s
GIFLIB_PROJECT_NAME=giflib
GIFLIB_PROJECT_VERSION=5.2.1
abort() {
printf "$@" >&2
exit 1
}
abort_invalid_prefix() {
usage_error '%s: invalid prefix -- %s\n' "$script" "$*"
}
abort_invalid_version() {
usage_error '%s: invalid version -- %s\n' "$script" "$*"
}
abort_not_supported() {
abort '%s: %s: %s not supported\n' "$script" "$PRETTY_NAME" "$*"
}
assert() {
"$@" || abort '%s: Assertion failed: %s\n' "$script" "$*"
}
configure_giflib() {
umask 0022
mkdir -p "$(dirname "$src_dir")"
extract_files
cd "$src_dir"
if [ "$build" = true ]; then
make_build PREFIX="$(get_prefix)"
fi
if [ "$check" = true ]; then
make_check PREFIX="$(get_prefix)" check
fi
}
configure_paths() {
basename=$GIFLIB_PROJECT_NAME-$version
filename=$basename$GIFLIB_ARCHIVE_SUFFIX
pathname="$GIFLIB_ARCHIVE_DIR/$filename"
src_dir="$HOME/Documents/src/GIFLIB/$basename"
}
get_configure_options() (
if [ -n "${prefix-}" ]; then
options="${options:+$options }--prefix=$(get_prefix)"
fi
if [ -n "${options:-}" ]; then
printf '%s\n' "$options"
fi
)
get_dependencies() {
get-packages $GIFLIB_PROJECT_NAME-build
}
get_prefix() {
printf "$prefix" "$GIFLIB_PROJECT_NAME-$version"
}
install_giflib() {
if [ "$install" != true ]; then
return 0
elif [ "$ID" != windows -a "$(id -u)" -gt 0 ]; then
return 0
fi
umask 0022
cd "$src_dir"
install_prefix=$(get_prefix)
make_install PREFIX="$install_prefix" install
install_project_link "$install_prefix"
}
parse_arguments() {
build=true
check=false
force=false
install=false
prefix=$GIFLIB_OPT_PREFIX
version=$GIFLIB_PROJECT_VERSION
while getopts bcfinp:v:h opt; do
case $opt in
(b)
build=true
;;
(c)
check=true
;;
(f)
force=true
;;
(i)
install=true
;;
(n)
build=false
;;
(p)
case $OPTARG in
($HOME/.local|$LOCAL_PREFIX|$GIFLIB_OPT_PREFIX)
prefix=$OPTARG
;;
(*)
abort_invalid_prefix $OPTARG
;;
esac
;;
(v)
case $OPTARG in
(5.[0-9].[0-9]|5.[1-9][0-9].[0-9])
version=$OPTARG
;;
(*)
abort_invalid_version $OPTARG
;;
esac
;;
(h)
usage
exit 0
;;
(\?)
exit 2
;;
esac
done
shift $(($OPTIND - 1))
if [ $# -gt 0 ]; then
usage_error '%s: Too many arguments\n' "$script"
fi
}
usage() {
cat <<EOF >&2
Usage: $script [-b] [-c] [-f] [-i] [-n] [-p PREFIX] [-v VERSION]
$script -h
EOF
}
usage_error() {
if [ $# -gt 0 ]; then
printf "$@" >&2
fi
printf '%s\n' '' >&2
usage
exit 2
}
validate_platform() {
case "$ID" in
(centos)
case "$VERSION_ID" in
(7)
return
;;
(8)
return
;;
(*)
abort_not_supported Release
;;
esac
;;
(debian|raspbian)
return
;;
(opensuse-*)
return
;;
(rhel|ol)
case "$VERSION_ID" in
(7.*)
return
;;
(8.*)
return
;;
(*)
abort_not_supported Release
;;
esac
;;
(freebsd)
return
;;
(illumos)
return
;;
(solaris)
return
;;
(windows)
return
;;
(*)
abort_not_supported "Operating system"
;;
esac
}
script=$(basename "$0")
case "$0" in
(*/*)
script_dir=$(cd "$(dirname "$0")" && pwd)
;;
(*)
script_dir=
;;
esac
script_prefix=${script_dir:+$script_dir/}
. "${script_prefix}common-functions.sh"
. "${script_prefix}config-functions.sh"
set_user_profile "$script_dir"
eval $(get-os-release -x)
validate_platform
configure_platform
parse_arguments "$@"
configure_paths
install_dependencies
if [ "$(id -u)" -eq 0 ]; then
run_unpriv /bin/sh -c "$0 $*"
else
configure_giflib
fi
install_giflib