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.

75 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/findorphans.sh
  6. # Copyright (C) 2008 The OpenSDE Project
  7. # Copyright (C) 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. config=default
  17. root=
  18. folders=
  19. usage() {
  20. echo "usage: $0 [-cfg <config>|-root <root>|-system]"
  21. }
  22. while [ $# -gt 0 ]; do
  23. case "$1" in
  24. -cfg) config="$2"
  25. root= ; shift ;;
  26. -root) root="$2"; shift ;;
  27. -system) root=/ ;;
  28. -just) shift; folders="$@"; break ;;
  29. -help) usage; exit 0 ;;
  30. *) echo "ERROR: unknown argument '$1'"
  31. usage; exit 1 ;;
  32. esac
  33. shift
  34. done
  35. if [ -z "$root" ]; then
  36. if [ ! -f config/$config/config ]; then
  37. echo "ERROR: '$config' is not a valid config"
  38. exit 2
  39. else
  40. root="build/`grep ' SDECFG_ID=' \
  41. config/$config/config | cut -d\' -f2`"
  42. fi
  43. fi
  44. if [ ! -d "$root/var/adm/flists" ]; then
  45. echo "ERROR: '$root' is not a valid OpenSDE box/sandbox root"
  46. exit 3
  47. fi
  48. flists=$( cd "$root"; echo var/adm/flists/* )
  49. realroot=$( cd "$root"; pwd )
  50. findroot=
  51. for f in $folders; do
  52. findroot="$findroot $realroot/${f#/}"
  53. done
  54. [ "$findroot" ] || findroot="$realroot"
  55. pushd "$realroot" > /dev/null
  56. find $findroot -mindepth 1 \
  57. \( -path "$realroot/TOOLCHAIN" -o \
  58. -path "$realroot/proc" -o \
  59. -path "$realroot/tmp" -o \
  60. -path '*/.svn' \) -prune \
  61. -o -print | sed -e "s,^$realroot/,," |
  62. while read file; do
  63. if ! grep -q -l "^[^ ]*: ${file}\$" $flists; then
  64. echo "$file"
  65. fi
  66. done
  67. popd > /dev/null