check_00index.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #!/bin/bash
  2. # SPDX-License-Identifier: GPL-2.0
  3. cd Documentation/
  4. # Check entries that should be removed
  5. obsolete=""
  6. for i in $(tail -n +12 00-INDEX |grep -E '^[a-zA-Z0-9]+'); do
  7. if [ ! -e $i ]; then
  8. obsolete="$obsolete $i"
  9. fi
  10. done
  11. # Check directory entries that should be added
  12. search=""
  13. dir=""
  14. for i in $(find . -maxdepth 1 -type d); do
  15. if [ "$i" != "." ]; then
  16. new=$(echo $i|perl -ne 's,./(.*),$1/,; print $_')
  17. search="$search $new"
  18. fi
  19. done
  20. for i in $search; do
  21. if [ "$(grep -P "^$i" 00-INDEX)" == "" ]; then
  22. dir="$dir $i"
  23. fi
  24. done
  25. # Check file entries that should be added
  26. search=""
  27. file=""
  28. for i in $(find . -maxdepth 1 -type f); do
  29. if [ "$i" != "./.gitignore" ]; then
  30. new=$(echo $i|perl -ne 's,./(.*),$1,; print $_')
  31. search="$search $new"
  32. fi
  33. done
  34. for i in $search; do
  35. if [ "$(grep -P "^$i\$" 00-INDEX)" == "" ]; then
  36. file="$file $i"
  37. fi
  38. done
  39. # Output its findings
  40. echo -e "Documentation/00-INDEX check results:\n"
  41. if [ "$obsolete" != "" ]; then
  42. echo -e "- Should remove those entries:\n\t$obsolete\n"
  43. else
  44. echo -e "- No obsolete entries\n"
  45. fi
  46. if [ "$dir" != "" ]; then
  47. echo -e "- Should document those directories:\n\t$dir\n"
  48. else
  49. echo -e "- No new directories to add\n"
  50. fi
  51. if [ "$file" != "" ]; then
  52. echo -e "- Should document those files:\n\t$file"
  53. else
  54. echo "- No new files to add"
  55. fi