2 # --- SDE-COPYRIGHT-NOTE-BEGIN ---
3 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
5 # Filename: bin/sde-download-git
6 # Copyright (C) 2007 The OpenSDE Project
8 # More information can be found in the files COPYING and README.
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; version 2 of the License. A copy of the
13 # GNU General Public License can be found in the file COPYING.
14 # --- SDE-COPYRIGHT-NOTE-END ---
17 export SDEROOT
=$
( cd "${0%/*}/.."; pwd -P )
19 .
$SDEROOT/lib
/libsde.
in
22 local progname
=${0##*/}
24 Usage: $progname [-vq] <target> <source> <tag>
29 longopts
='quiet,verbose'
30 options
=$
( getopt
-o "$shortopts" -l "$longopts" -- "$@" )
37 # load new arguments list
38 eval set -- "$options"
44 while [ $# -gt 0 ]; do
56 # now take the real arguments
58 echo_error
"Not enough arguments given."
68 if [ -e "$target.lock" ]; then
69 echo_warning
"$target: File locked"
73 echo "$$" > "$target.lock"
74 prefix
=${source##*/}; prefix=${prefix%.git}-${tag}
76 [ $verbose -le 1 ] || echo_info
"git-archive --format=tar --prefix=$prefix/ --remote='$source' '$tag'"
78 # download in background
80 git-archive
--format=tar --prefix=$prefix/ --remote="$source" "$tag" |
bzip2 > $target
81 echo $?
> $target.errno
84 # and wait until it ends
85 while fuser
$target &> /dev
/null
; do
86 echo -ne "$( nice du -sh "$target" 2> /dev/null | cut -f1 ) downloaded from archive so far...\r"
90 errno
=$
( cat $target.errno
2> /dev
/null
)
91 if [ "$errno" != "0" -o ! -s "$target" ]; then
93 echo_error
"Download failed (errno:${errno:-undefined})"
94 elif [ $verbose -gt 0 ]; then
95 echo_info
"$( du -sh "$target" 2> /dev/null | cut -f1 ) downloaded from archive."
98 rm -f "$target.errno" "$target.lock"