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.

90 lines
1.9 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-pkg
  6. # Copyright (C) 2007 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. #Description: generate lists needed by other commands
  16. set -e
  17. [ -n "$SDEROOT" ] ||
  18. export SDEROOT=$( cd "${0%/*}/.."; pwd -P )
  19. . $SDEROOT/lib/libsde.in
  20. list_usage() {
  21. local progname=${0##*/}
  22. cat <<EOT
  23. Usage: $progname [--arch <arch>]
  24. $progname [--cfg <config>]
  25. EOT
  26. }
  27. list_arch() {
  28. local repo= arch="$1"
  29. local files=
  30. if [ ! -s $SDEROOT/architecture/$arch/archtest.out ]; then
  31. echo_error "wrong architecture ($arch) specified, aborting."
  32. list_usage
  33. return 1
  34. fi
  35. # the .awk file needs complete $SDEROOT relative .desc locations
  36. cd $SDEROOT
  37. # NOTE: protection again command line overflow
  38. for repo in package/*; do
  39. files=$( ls -1d $repo/*/*.desc 2> /dev/null )
  40. if [ -n "$files" ]; then
  41. gawk -f ./lib/sde-package/package-list.awk -v "arch=$arch" $files
  42. fi
  43. done | sort -k 3
  44. }
  45. list_desc() {
  46. echo_abort 1 "Not yet implemented"
  47. }
  48. arch=
  49. config=
  50. mode=
  51. shortopts=a:c:
  52. longopts=arch:,cfg:
  53. options=$( getopt -o "$shortopts" -l "$longopts" -- "$@" )
  54. if [ $? -ne 0 ]; then
  55. list_usage
  56. exit -1
  57. fi
  58. # load new arguments list
  59. eval set -- "$options"
  60. # arguments
  61. while [ $# -gt 0 ]; do
  62. case "$1" in
  63. -a|--arch) mode=arch
  64. arch="$2"; shift ;;
  65. -c|--cfg) mode=desc
  66. config="$2"; shift ;;
  67. --) shift; break ;;
  68. *) echo_abort 1 "Unknown argument '$1', aborting."
  69. esac
  70. shift
  71. done
  72. case "$mode" in
  73. arch) list_arch "$arch" ;;
  74. desc) list_desc "$config" ;;
  75. *) list_usage ;;
  76. esac