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.

79 lines
2.2 KiB

  1. #!/bin/bash
  2. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. #
  5. # Filename: lib/misc/catedit.sh
  6. # Copyright (C) 2006 - 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. #
  17. # WARNING: Create backup copies of your files before you use this tool
  18. # for editing the categories of your packages !!!
  19. #
  20. # Usage: sh lib/misc/catedit.sh package/base/*/*.desc
  21. # or: sh lib/misc/catedit.sh -a
  22. #
  23. set -e
  24. item=''
  25. tmp=$( mktemp )
  26. if [ $(dialog --version 2>&1| grep -c "0.9") -eq 0 ]; then
  27. echo "dialog's version at least 0.9 needed"
  28. exit 1
  29. fi
  30. if [ "$1" = "-a" -o "$1" = "--all" ]
  31. then files="$(find package/ -name *.desc | sort -t '/' -k 4)"
  32. else files="$@"
  33. fi
  34. until
  35. pkglst=$(grep '^\[C\]' $files | sed -e 's,^[^:]*/,,;' \
  36. -e 's,\.[^ ]* , ",;' -e 's,$,",;' | sed -e 's, "$,",' \
  37. | tr '\n' ' ' )
  38. eval dialog --backtitle \"ROCK Linux package category editor\" \
  39. ${item:+--default-item} $item --cancel-label \
  40. Quit --menu \"Choose the package you want to edit\" \
  41. 42 120 35 $pkglst 2> $tmp
  42. item="$( cat $tmp )"
  43. cat $tmp
  44. [ -z "$item" ]
  45. do
  46. for file in $files; do
  47. [[ $file = */$item.desc ]] && break
  48. done
  49. (for category in $(awk '/^[^# ]/ {print $1}' < etc/categories ); do
  50. echo -n $category $category
  51. if [ -n "$(grep "^\[C\].*$category" $file )" ]
  52. then echo -e " on "
  53. else echo -e " off "
  54. fi
  55. done ) > $tmp
  56. dialog --cancel-label Back --backtitle " categories for $item " \
  57. --checklist "$(grep '^\[I\]' $file | sed 's/\[I\] //' )" \
  58. 42 80 35 $(cat $tmp) 2> $tmp
  59. value=$( cat $tmp | sed -e 's/"//g' -e 's/ $//' )
  60. if [ "$value" ] ; then
  61. cat $file | sed "s,^\[C\] .*,\[C\] $value,g" > $tmp
  62. cat $tmp > $file
  63. #grep -v '^\[C\]' "$file" > $tmp
  64. #echo -e '\n'"[C] $value" >> $tmp
  65. #./scripts/Create-DescPatch $item | patch -p1
  66. fi
  67. done
  68. rm -f $tmp