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.

87 lines
1.8 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/showdeps.sh
  6. # Copyright (C) 2008 The OpenSDE Project
  7. # Copyright (C) 2004 - 2006 The T2 SDE Project
  8. #
  9. # More information can be found in the files COPYING and README.
  10. #
  11. # This program is free software; you can redistribute it and/or modify
  12. # it under the terms of the GNU General Public License as published by
  13. # the Free Software Foundation; version 2 of the License. A copy of the
  14. # GNU General Public License can be found in the file COPYING.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. root=
  17. usage() {
  18. cat <<EOT
  19. usage: $0 [-root <root>] [<pkg>]+
  20. EOT
  21. }
  22. getdeps() {
  23. if [ -f package/*/$1/$1.cache ]; then
  24. grep -e "^\[DEP\]" package/*/$1/$1.cache | cut -d' ' -f2- | tr '\n' ' '
  25. else
  26. echo "unknown"
  27. fi
  28. }
  29. getprio() {
  30. local prio=
  31. if [ -f package/*/$1/$1.desc ]; then
  32. prio=`sed -n -e "s,^\[P\] . .* \(.*\),\1,p" package/*/$1/$1.desc`
  33. fi
  34. [ -n "$prio" ] && echo "$prio" || echo "---.---"
  35. }
  36. pkginstalled() {
  37. [ -f $root/var/adm/packages/$1 ]
  38. }
  39. digdeps() {
  40. local deep="$1" pkg="$2" prefix="$3"
  41. local cache="$4" banner= dep=
  42. [ $deep -eq 0 ] && return 0
  43. (( deep-- ))
  44. banner="$pkg($( getprio $pkg ))"
  45. if pkginstalled $pkg; then
  46. banner="$banner+"
  47. else
  48. banner="$banner-"
  49. fi
  50. echo -e "$prefix$banner"
  51. for dep in $( getdeps $pkg ); do
  52. if [ "$dep" == "unknown" ]; then
  53. echo -e "$prefix$banner\tNODEPS"
  54. elif [ -z "$(echo "$cache" | grep ":$dep:" )" ]; then
  55. digdeps $deep $dep "$prefix$banner\t" "$cache$pkg:"
  56. fi
  57. done
  58. }
  59. while [ $# -ne 0 ]; do
  60. case "$1" in
  61. -root) root=$2
  62. shift ;;
  63. -*) echo "ERROR: Option $1 is not recognized."
  64. usage; exit 1 ;;
  65. *)
  66. break;
  67. esac
  68. shift
  69. done
  70. for pkg; do
  71. if [ -f package/*/$pkg/$pkg.desc ]; then
  72. digdeps 2 $pkg '' ':'
  73. else
  74. echo "ERROR: '$pkg' not found!" 1>&2
  75. fi
  76. done