3 # Copyright © 2004, The AROS Development Team. All rights reserved.
9 error
"Usage: $1 -a archive [-as archive_suffixes] [-ao archive_origins...] [-d destination] [-po patches_origins...] [-p patch[:subdir][:patch options]...]"
12 sf_mirrors
="aleron voxel heanet avh umn unc puzzle mesh"
16 local origin
="$1" file="$2" destination
="$3"
20 echo "Downloading from SourceForge... Try n. $i."
21 fetch
"http://downloads.sourceforge.net/$origin" "${file}" "$destination" && break;
27 local origin
="$1" file="$2" destination
="$3"
31 if echo $origin |
grep ":" >/dev
/null
; then
32 protocol
=`echo $origin | cut -d':' -f1`
37 trap 'rm -f "$destination/$file".tmp; exit' SIGINT SIGKILL SIGTERM
41 if ! wget
-t 5 -T 5 -c "$origin/$file" -O "$destination/$file".tmp
; then
44 mv "$destination/$file".tmp
"$destination/$file"
46 rm -f "$destination/$file".tmp
49 ! fetch_sf
"${origin:${#protocol}+3}" "$file" "$destination" && ret
=false
52 if test "$origin" = "$destination"; then
53 ! test -f "$origin/$file" && ret
=false
55 if ! cp "$origin/$file" "$destination/$file".tmp
; then
58 mv "$destination/$file".tmp
"$destination/$file"
63 echo "Unknown protocol type \`$protocol'"
67 trap SIGINT SIGKILL SIGTERM
74 local origins
="$1" file="$2" destination
="$3"
75 for origin
in $origins; do
76 echo "Trying $origin/$file..."
77 fetch
"$origin" "$file" "$destination" && return 0
85 local origins
="$1" file="$2" suffixes
="$3" destination
="$4" foundvar
="$5"
88 foundvar
=${foundvar:-__dummy__}
92 test -e "$destination" -a ! -d "$destination" && \
93 echo "\`$destination' is not a diretory." && return 1
95 if ! test -e "$destination"; then
96 echo "\`$destination' does not exist. Making it."
97 ! mkdir
-p "$destination" && return 1
100 if test "x$suffixes" != "x"; then
101 for sfx
in $suffixes; do
102 fetch_multiple
"$destination" "$file".
$sfx "$destination" && \
103 export $foundvar="$file".
$sfx && return 0
106 for sfx
in $suffixes; do
107 fetch_multiple
"$origins" "$file".
$sfx "$destination" && \
108 export $foundvar="$file".
$sfx && return 0
111 fetch_multiple
"$destination $origins" "$file" "$destination" && \
112 export $foundvar="$file" && return 0
127 local location
="$1" archive
="$2";
132 echo "Unpacking \`$archive'..."
137 if ! tar xfj
"$archive"; then ret
=false
; fi
140 if ! tar xfz
"$archive"; then ret
=false
; fi
143 echo "Unknown archive format for \`$archive'."
155 local location
="$1" archive
="$2";
157 if ! test -f ${location}/.
${archive}.unpacked
; then
158 if unpack
"$location" "$archive"; then
159 echo yes > ${location}/.
${archive}.unpacked
169 local location
="$1" patch_spec
="$2";
173 local abs_location
="$PWD"
175 local patch=`echo "$patch_spec": | cut -d: -f1`
176 local subdir
=`echo "$patch_spec": | cut -d: -f2`
177 local patch_opt
=`echo "$patch_spec": | cut -d: -f3`
183 if ! patch $patch_opt < $abs_location/$patch; then
194 local location
="$1" patch="$2";
196 local patchname
=`echo $patch | cut -d: -f1`
198 if test "x$patchname" != "x"; then
199 if ! test -f ${location}/.
${patchname}.applied
; then
200 if do_patch
"$location" "$patch"; then
201 echo yes > ${location}/.
${patchname}.applied
211 while test "x$1" != "x"; do
212 if test "x${1:0:1}" == "x-" -a "x${2:0:1}" == "x-"; then
217 -ao) archive_origins
="$2";;
219 -as) archive_suffixes
="$2";;
220 -d) destination
="$2";;
221 -po) patches_origins
="$2";;
223 *) echo "Unknown option \`$1'."; usage
"$0";;
230 test -z "$archive" && usage
"$0"
232 archive_origins
=${archive_origins:-.}
233 destination
=${destination:-.}
234 patches_origins
=${patches_origins:-.}
236 fetch_cached
"$archive_origins" "$archive" "$archive_suffixes" "$destination" archive2
237 test -z "$archive2" && error
"Error while fetching the archive \`$archive'."
240 for patch in $patches; do
241 patch=`echo $patch | cut -d: -f1`
242 if test "x$patch" != "x"; then
243 if ! fetch_cached
"$patches_origins" "$patch" "" "$destination"; then
244 error
"Error while fetching the patch \`$patch'."
249 if ! unpack_cached
"$destination" "$archive"; then
250 error
"Error while unpacking \`$archive'."
253 for patch in $patches; do
254 if ! patch_cached
"$destination" "$patch"; then
255 error
"Error while applying the patch \`$patch'."