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.

89 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: lib/misc/hunter.sh
  6. # Copyright (C) 2006 - 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 ---
  15. function usage() {
  16. echo "Usage: $0 [-cfg <config:-default>] [-<stage>] [-dot|-tsort] [packages...]"
  17. exit $1
  18. }
  19. stage=
  20. config=default
  21. mode=tsort
  22. while [ $# -gt 0 ]; do
  23. case "$1" in
  24. -[0-9]) stage=${1:1:1}; ;;
  25. -cfg) config="$2"; shift; ;;
  26. -dot) mode=dot ;;
  27. -tsort) mode=tsort ;;
  28. -*) usage 1 ;;
  29. *) break ;;
  30. esac
  31. shift
  32. done
  33. if [ ! -r "config/$config/packages" ]; then
  34. usage 2
  35. fi
  36. if [ -n "$stage" ]; then
  37. sed -n -e "s,^X [^ ]*$stage[^ ]* [^ ]* [^ ]* \([^ ]*\) .*,\1,p" "config/$config/packages"
  38. exit 0
  39. elif [ $# -eq 0 ]; then
  40. exit 0
  41. fi
  42. if [ $# -eq 1 ]; then
  43. pattern="$1"
  44. else
  45. pattern="$@"
  46. pattern="(${pattern// /|})"
  47. fi
  48. rm -f hunter.$mode
  49. case "$mode" in
  50. tsort) ;;
  51. dot) echo "digraph G {" ;;
  52. esac >> hunter.$mode
  53. for pkg; do
  54. cachefile=$( ls -1 package/*/$pkg/$pkg.cache 2> /dev/null )
  55. if [ -z "$cachefile" ]; then
  56. echo "No Information for '$pkg' found." 1>&2
  57. case "$mode" in
  58. tsort) echo "$pkg $pkg" ;;
  59. dot) echo " $pkg ;" ;;
  60. esac >> hunter.$mode
  61. else
  62. case "$mode" in
  63. tsort) echo "$pkg $pkg" ;;
  64. dot) echo " $pkg ;" ;;
  65. esac >> hunter.$mode
  66. for dep in `grep -E " $pattern\$" "$cachefile" | cut -d' ' -f2`; do
  67. case "$mode" in
  68. tsort) echo "$dep $pkg" ;;
  69. dot) echo " $dep -> $pkg;" ;;
  70. esac >> hunter.$mode
  71. done
  72. fi
  73. done
  74. case "$mode" in
  75. tsort) ;;
  76. dot) echo "}" ;;
  77. esac >> hunter.$mode