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"
19 for mirror
in $sf_mirrors; do
20 echo "Checking SourceForge mirror \`$mirror'..."
21 fetch
"http://prdownloads.sourceforge.net/$origin" "${file}?use_mirror=${mirror}" "$destination" \
23 full_path
=`awk '/<META[ \t\n]+HTTP-EQUIV.+/ { match($4, /=.+"/); print substr($4, RSTART+1, RLENGTH-2) }' "$destination/${file}?use_mirror=${mirror}"` && \
24 rm "$destination/${file}?use_mirror=${mirror}" && \
25 test "x$full_path" != "x" && \
26 fetch
"`dirname $full_path`" "$file" "$destination" && \
33 local origin
="$1" file="$2" destination
="$3"
37 if echo $origin |
grep ":" >/dev
/null
; then
38 protocol
=`echo $origin | cut -d':' -f1`
43 trap 'rm -f "$destination/$file".tmp; exit' SIGINT SIGKILL SIGTERM
47 if ! wget
-c "$origin/$file" -O "$destination/$file".tmp
; then
50 mv "$destination/$file".tmp
"$destination/$file"
52 rm -f "$destination/$file".tmp
55 ! fetch_sf
"${origin:${#protocol}+3}" "$file" "$destination" && ret
=false
58 if test "$origin" = "$destination"; then
59 ! test -f "$origin/$file" && ret
=false
61 if ! cp "$origin/$file" "$destination/$file".tmp
; then
64 mv "$destination/$file".tmp
"$destination/$file"
69 echo "Unknown protocol type \`$protocol'"
73 trap SIGINT SIGKILL SIGTERM
80 local origins
="$1" file="$2" destination
="$3"
81 for origin
in $origins; do
82 echo "Trying $origin/$file..."
83 fetch
"$origin" "$file" "$destination" && return 0
91 local origins
="$1" file="$2" suffixes
="$3" destination
="$4" foundvar
="$5"
94 foundvar
=${foundvar:-__dummy__}
98 test -e "$destination" -a ! -d "$destination" && \
99 echo "\`$destination' is not a diretory." && return 1
101 if ! test -e "$destination"; then
102 echo "\`$destination' does not exist. Making it."
103 ! mkdir
-p "$destination" && return 1
106 if test "x$suffixes" != "x"; then
107 for sfx
in $suffixes; do
108 fetch_multiple
"$destination" "$file".
$sfx "$destination" && \
109 export $foundvar="$file".
$sfx && return 0
112 for sfx
in $suffixes; do
113 fetch_multiple
"$origins" "$file".
$sfx "$destination" && \
114 export $foundvar="$file".
$sfx && return 0
117 fetch_multiple
"$destination $origins" "$file" "$destination" && \
118 export $foundvar="$file" && return 0
133 local location
="$1" archive
="$2";
138 echo "Unpacking \`$archive'..."
143 if ! tar xfj
"$archive"; then ret
=false
; fi
146 if ! tar xfz
"$archive"; then ret
=false
; fi
149 echo "Unknown archive format for \`$archive'."
161 local location
="$1" archive
="$2";
163 if ! test -f ${location}/.
${archive}.unpacked
; then
164 if unpack
"$location" "$archive"; then
165 echo yes > ${location}/.
${archive}.unpacked
175 local location
="$1" patch_spec
="$2";
179 local abs_location
="$PWD"
181 local patch=`echo "$patch_spec": | cut -d: -f1`
182 local subdir
=`echo "$patch_spec": | cut -d: -f2`
183 local patch_opt
=`echo "$patch_spec": | cut -d: -f3`
189 if ! patch $patch_opt < $abs_location/$patch; then
200 local location
="$1" patch="$2";
202 local patchname
=`echo $patch | cut -d: -f1`
204 if test "x$patchname" != "x"; then
205 if ! test -f ${location}/.
${patchname}.applied
; then
206 if do_patch
"$location" "$patch"; then
207 echo yes > ${location}/.
${patchname}.applied
217 while test "x$1" != "x"; do
218 if test "x${1:0:1}" == "x-" -a "x${2:0:1}" == "x-"; then
223 -ao) archive_origins
="$2";;
225 -as) archive_suffixes
="$2";;
226 -d) destination
="$2";;
227 -po) patches_origins
="$2";;
229 *) echo "Unknown option \`$1'."; usage
"$0";;
236 test -z "$archive" && usage
"$0"
238 archive_origins
=${archive_origins:-.}
239 destination
=${destination:-.}
240 patches_origins
=${patches_origins:-.}
242 fetch_cached
"$archive_origins" "$archive" "$archive_suffixes" "$destination" archive2
243 test -z "$archive2" && error
"Error while fetching the archive \`$archive'."
246 for patch in $patches; do
247 patch=`echo $patch | cut -d: -f1`
248 if test "x$patch" != "x"; then
249 if ! fetch_cached
"$patches_origins" "$patch" "" "$destination"; then
250 error
"Error while fetching the patch \`$patch'."
255 if ! unpack_cached
"$destination" "$archive"; then
256 error
"Error while unpacking \`$archive'."
259 for patch in $patches; do
260 if ! patch_cached
"$destination" "$patch"; then
261 error
"Error while applying the patch \`$patch'."