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.

86 lines
1.8 KiB

  1. #!/bin/sh
  2. # --- T2-COPYRIGHT-NOTE-BEGIN ---
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. #
  5. # T2 SDE: misc/archive/showdeps.sh
  6. # Copyright (C) 2004 - 2006 The T2 SDE 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. # --- T2-COPYRIGHT-NOTE-END ---
  15. root=
  16. usage() {
  17. cat <<EOT
  18. usage: $0 [-root <root>] [<pkg>]+
  19. EOT
  20. }
  21. getdeps() {
  22. if [ -f package/*/$1/$1.cache ]; then
  23. grep -e "^\[DEP\]" package/*/$1/$1.cache | cut -d' ' -f2- | tr '\n' ' '
  24. else
  25. echo "unknown"
  26. fi
  27. }
  28. getprio() {
  29. local prio=
  30. if [ -f package/*/$1/$1.desc ]; then
  31. prio=`sed -n -e "s,^\[P\] . .* \(.*\),\1,p" package/*/$1/$1.desc`
  32. fi
  33. [ -n "$prio" ] && echo "$prio" || echo "---.---"
  34. }
  35. pkginstalled() {
  36. [ -f $root/var/adm/packages/$1 ]
  37. }
  38. digdeps() {
  39. local deep="$1" pkg="$2" prefix="$3"
  40. local cache="$4" banner= dep=
  41. [ $deep -eq 0 ] && return 0
  42. (( deep-- ))
  43. banner="$pkg($( getprio $pkg ))"
  44. if pkginstalled $pkg; then
  45. banner="$banner+"
  46. else
  47. banner="$banner-"
  48. fi
  49. echo -e "$prefix$banner"
  50. for dep in $( getdeps $pkg ); do
  51. if [ "$dep" == "unknown" ]; then
  52. echo -e "$prefix$banner\tNODEPS"
  53. elif [ -z "$(echo "$cache" | grep ":$dep:" )" ]; then
  54. digdeps $deep $dep "$prefix$banner\t" "$cache$pkg:"
  55. fi
  56. done
  57. }
  58. while [ $# -ne 0 ]; do
  59. case "$1" in
  60. -root) root=$2
  61. shift ;;
  62. -*) echo "ERROR: Option $1 is not recognized."
  63. usage; exit 1 ;;
  64. *)
  65. break;
  66. esac
  67. shift
  68. done
  69. for pkg; do
  70. if [ -f package/*/$pkg/$pkg.desc ]; then
  71. digdeps 2 $pkg '' ':'
  72. else
  73. echo "ERROR: '$pkg' not found!" 1>&2
  74. fi
  75. done