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.

108 lines
2.6 KiB

  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 - 2012 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 ---
  15. [ -n "$SDEROOT" ] ||
  16. export SDEROOT=$( cd "${0%/*}/.."; pwd -P )
  17. . $SDEROOT/lib/libsde.in
  18. list_usage() {
  19. local progname=${0##*/}
  20. cat <<EOT
  21. Usage: $progname [--cfg <config>] [-erkl] [ITEMS...]
  22. EOT
  23. }
  24. shortopts='c:erpkl'
  25. longopts='cfg:,extenders,repositories,package,checksum,location'
  26. options=$( getopt -o "$shortopts" -l "$longopts" -- "$@" )
  27. if [ $? -ne 0 ]; then
  28. list_usage
  29. exit -1
  30. fi
  31. # load new arguments list
  32. eval set -- "$options"
  33. config=
  34. extenders=
  35. repositories=
  36. want_package=
  37. want_checksum=
  38. want_location=
  39. while [ $# -gt 0 ]; do
  40. case "$1" in
  41. --) shift; break ;;
  42. -c|--cfg) shift; config="$1" ;;
  43. -e|--extenders)
  44. extenders=yes ;;
  45. -r|--repositories)
  46. repositories=yes ;;
  47. -p|--package) want_package=yes ;;
  48. -k|--checksum) want_checksum=yes ;;
  49. -l|--location) want_location=yes ;;
  50. esac
  51. shift
  52. done
  53. # TODO: target/$target/download.txt
  54. $SDEROOT/bin/sde-list-pkg ${config:+-c $config} ${extenders:+-e} ${repositories:+-r} -- "$@" | while read descfile; do
  55. pkg=$( echo "$descfile" | cut -d/ -f3 )
  56. grep '^\[D\]' $SDEROOT/$descfile | while read x cksum gzfile location; do
  57. output=
  58. # package name
  59. [ -z "$want_package" ] || output="$pkg"
  60. # checksum
  61. [ -z "$want_checksum" ] || output="${output:+$output\t}$cksum"
  62. # destination file
  63. if [ "$location" != "${location#-}" ]; then
  64. mirror=local
  65. location="${location#-}"
  66. else
  67. mirror=mirror
  68. fi
  69. bz2file=$( echo "$gzfile" | sed -e 's,\.gpg$,,' -e 's,\.\(t\?\)\(gz\|xz\|Z\)$,.\1bz2,' -e 's,\.tar$,.tar.bz2,' )
  70. x=$(echo "$bz2file" | cut -c1)
  71. x="download/$mirror/$x/$bz2file"
  72. output="${output:+$output\t}$x"
  73. # source location
  74. if [ -n "$want_location" ]; then
  75. if [ "$location" != "${location#!}" ]; then
  76. # keep untouched
  77. source="${location#!}"
  78. elif [ "$location" = "${location% *}" -a "$location" != "${location%/}" ]; then
  79. # no spaces, and trailing '/', append gzfile
  80. source="${location}${gzfile}"
  81. else
  82. source="$location"
  83. fi
  84. output="$output\t$source"
  85. fi
  86. $ECHO_E "$output"
  87. done
  88. done