Fixed references to misc/archive/ in lib/misc
[opensde-nopast.git] / lib / misc / catedit.sh
blob7dd7c574994b5fa40f690f0b2badc9925c665ba6
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.
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 ---
17 # WARNING: Create backup copies of your files before you use this tool
18 # for editing the categories of your packages !!!
20 # Usage: sh lib/misc/catedit.sh package/base/*/*.desc
21 # or: sh lib/misc/catedit.sh -a
24 set -e
26 item=''
27 tmp=$( mktemp )
29 if [ $(dialog --version 2>&1| grep -c "0.9") -eq 0 ]; then
30 echo "dialog's version at least 0.9 needed"
31 exit 1
34 if [ "$1" = "-a" -o "$1" = "--all" ]
35 then files="$(find package/ -name *.desc | sort -t '/' -k 4)"
36 else files="$@"
39 until
40 pkglst=$(grep '^\[C\]' $files | sed -e 's,^[^:]*/,,;' \
41 -e 's,\.[^ ]* , ",;' -e 's,$,",;' | sed -e 's, "$,",' \
42 | tr '\n' ' ' )
44 eval dialog --backtitle \"ROCK Linux package category editor\" \
45 ${item:+--default-item} $item --cancel-label \
46 Quit --menu \"Choose the package you want to edit\" \
47 42 120 35 $pkglst 2> $tmp
49 item="$( cat $tmp )"
50 cat $tmp
51 [ -z "$item" ]
53 for file in $files; do
54 [[ $file = */$item.desc ]] && break
55 done
57 (for category in $(awk '/^[^# ]/ {print $1}' < etc/categories ); do
58 echo -n $category $category
59 if [ -n "$(grep "^\[C\].*$category" $file )" ]
60 then echo -e " on "
61 else echo -e " off "
63 done ) > $tmp
65 dialog --cancel-label Back --backtitle " categories for $item " \
66 --checklist "$(grep '^\[I\]' $file | sed 's/\[I\] //' )" \
67 42 80 35 $(cat $tmp) 2> $tmp
68 value=$( cat $tmp | sed -e 's/"//g' -e 's/ $//' )
70 if [ "$value" ] ; then
71 cat $file | sed "s,^\[C\] .*,\[C\] $value,g" > $tmp
72 cat $tmp > $file
73 #grep -v '^\[C\]' "$file" > $tmp
74 #echo -e '\n'"[C] $value" >> $tmp
75 #./scripts/Create-DescPatch $item | patch -p1
77 done
79 rm -f $tmp