OpenSDE Framework (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

178 lines
3.7 KiB

#!/bin/sh
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: bin/sde-download2
# Copyright (C) 2007 The OpenSDE Project
#
# More information can be found in the files COPYING and README.
#
# 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; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- SDE-COPYRIGHT-NOTE-END ---
#Description: Download sources
[ -n "$SDEROOT" ] ||
export SDEROOT=$( cd "${0%/*}/.."; pwd -P )
. $SDEROOT/lib/libsde.in
download_usage() {
local progname=${0##*/}
cat <<EOT >&2
Usage: $progname [DISCRIMINATOR] [OPTIONS] [ITEMS...]
Accepted discriminators:
* config (cfg)
* package (pkg) - default
* repository (repo)
For more information read \`sde help download\`.
EOT
}
# detect discriminator
discriminator=package
if [ $# -gt 0 ]; then
case "$1" in
-*) ;;
config|cfg)
discriminator=config; shift ;;
package|pkg)
discriminator=package; shift ;;
repository|repo)
discriminator=repository; shift ;;
*)
echo_error "$1: invalid discriminator"
download_usage
exit -1 ;;
esac
fi
shortopts='dqvc:m:e'
longopts='dry-run,quiet,verbose,cfg,timeout:,cfg,check:,mirror:,mode:,extenders'
options=$( getopt -o "$shortopts" -l "$longopts" -- "$@" )
if [ $? -ne 0 ]; then
download_usage
exit -1
fi
# load new arguments list
eval set -- "$options"
dryrun=
verbose=1
timeout=normal
check=always
mirror=
mode=hardlink
extenders=
config=
while [ $# -gt 0 ]; do
case "$1" in
--) shift; break ;;
-d|--dry-run)
dryrun=yes ;;
-e|--extenders)
extenders=yes ;;
-v|--verbose)
let verbose++ ;;
-q|--quiet)
let verbose-- ;;
--timeout)
shift
case "$1" in
normal|long|no)
timeout="$1" ;;
*)
echo_abort 1 "$1: invalid timeout value: [normal*|long|no]"
;;
esac ;;
--check)
shift
case "$1" in
always|download|never)
check="$1" ;;
*)
echo_abort 1 "$1: invalid ckeck value: [always*|download|never]"
;;
esac ;;
--mirror)
shift
case "$1" in
none|auto|http://*|https://*|ftp://*|file://*)
mirror="$1" ;;
*)
echo_abort 1 "$1: invalid mirror value"
;;
esac ;;
-m|--mode)
shift
case "$1" in
hardlink|copy|move)
mode="$1" ;;
*)
echo_abort 1 "$1: invalid altdir mode [hardlink*|copy|move]"
;;
esac ;;
-c|--cfg)
shift
config=${1:-default}
;;
esac
shift
done
# constants to pass to sde-download-get
downloadgetopt=
if [ $verbose -gt 2 ]; then
downloadgetopt='-v'
elif [ $verbose -lt 0 ]; then
downloadgetopt='-q'
fi
if [ -n "$dryrun" ]; then
downloadgetopt="$downloadgetopt --dry-run"
fi
case "$discriminator" in
package)
$SDEROOT/bin/sde-list-download ${config:+--cfg $config} ${extenders:+--extenders} -pkl -- "$@"
;;
repository)
$SDEROOT/bin/sde-list-download ${config:+--cfg $config} ${extenders:+--extenders} -rpkl -- "$@"
;;
config)
[ -z "$config" ] || set -- "$config" "$@"
[ $# -gt 0 ] || set -- default
for config; do
$SDEROOT/bin/sde-list-download --cfg "$config" -pkl
done
;;
esac | while read pkg cksum file location; do
# temporal download location
tmpfile="$SDEROOT/tmp/down.$( echo $file | tr '/' '-' )"
# debug output
[ $verbose -le 1 ] || echo_info "pkg:$pkg file:$file ($cksum) source:$location"
if [ -s "$SDEROOT/$file" ]; then
:
elif [ -e "$tmpfile.lock" ]; then
echo_warning "$file: skipping."
else
"$SDEROOT"/bin/sde-download-get $downloadgetopt -- "$tmpfile" "$location"
if [ $? -ne 0 ]; then
echo_warning "$file: failed to download"
fi
fi
done