Improved lib/sde-package/patch-copyright.sh to remove trailing spaces from the copyri...
[opensde-nopast.git] / bin / sde-list-download
blob97f407557cc9d57596a41762043d40bb0896649c
1 #!/bin/sh
2 # --- SDE-COPYRIGHT-NOTE-BEGIN ---
3 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
4 #
5 # Filename: bin/sde-list-download
6 # Copyright (C) 2007 - 2008 The OpenSDE Project
7 #
8 # More information can be found in the files COPYING and README.
9 #
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 ---
16 [ -n "$SDEROOT" ] ||
17 export SDEROOT=$( cd "${0%/*}/.."; pwd -P )
19 . $SDEROOT/lib/libsde.in
21 list_usage() {
22 local progname=${0##*/}
23 cat <<EOT
24 Usage: $progname [--cfg <config>] [-erkl] [ITEMS...]
25 EOT
28 shortopts='c:erpkl'
29 longopts='cfg:,extenders,repositories,package,checksum,location'
30 options=$( getopt -o "$shortopts" -l "$longopts" -- "$@" )
31 if [ $? -ne 0 ]; then
32 list_usage
33 exit -1
36 # load new arguments list
37 eval set -- "$options"
39 config=
40 extenders=
41 repositories=
43 want_package=
44 want_checksum=
45 want_location=
47 while [ $# -gt 0 ]; do
48 case "$1" in
49 --) shift; break ;;
51 -c|--cfg) shift; config="$1" ;;
53 -e|--extenders)
54 extenders=yes ;;
55 -r|--repositories)
56 repositories=yes ;;
58 -p|--package) want_package=yes ;;
59 -k|--checksum) want_checksum=yes ;;
60 -l|--location) want_location=yes ;;
61 esac
62 shift
63 done
65 # TODO: target/$target/download.txt
67 $SDEROOT/bin/sde-list-pkg ${config:+-c $config} ${extenders:+-e} ${repositories:+-r} -- "$@" | while read descfile; do
68 pkg=$( echo "$descfile" | cut -d/ -f3 )
69 grep '^\[D\]' $SDEROOT/$descfile | while read x cksum gzfile location; do
70 output=
72 # package name
73 [ -z "$want_package" ] || output="$pkg"
75 # checksum
76 [ -z "$want_checksum" ] || output="${output:+$output\t}$cksum"
78 # destination file
80 if [ "$location" != "${location#-}" ]; then
81 mirror=local
82 location="${location#-}"
83 else
84 mirror=mirror
87 bz2file=$( echo "$gzfile" | sed -e 's,\.gpg$,,' -e 's,\.\(t\?\)\(gz\|Z\)$,.\1bz2,' -e 's,\.tar$,.tar.bz2,' )
88 output="${output:+$output\t}download/$mirror/${bz2file:0:1}/$bz2file"
90 # source location
91 if [ -n "$want_location" ]; then
92 if [ "$location" != "${location#!}" ]; then
93 # keep untouched
94 source="${location#!}"
95 elif [ "$location" = "${location% *}" -a "$location" != "${location%/}" ]; then
96 # no spaces, and trailing '/', append gzfile
97 source="${location}${gzfile}"
98 else
99 source="$location"
101 output="$output\t$source"
104 echo -e "$output"
105 done
106 done