manuels Advocate
![Advocate Advocate](/images/ranks/rank-G-1-advocate.gif)
![](images/avatars/106271246545d319130201e.gif)
Joined: 22 Nov 2003 Posts: 2146 Location: Europe
|
Posted: Sun Aug 19, 2007 4:44 pm Post subject: [Script] Categories-Exclude-Tool |
|
|
Moin zusammen,
mit war ein bisschen langweilig, also hab ich ein Script gebastelt, mit dem man recht komfortabel Categories vom Rsync ausnehmen kann.
Ich weiss, dass es sowas schon gibt, aber ich hatte Laune dazu und wollte es ncurses basiert.
Kommentare und Bugreports herzlich willkommen.
Bitte schön:
Code: | #!/bin/bash
rsync_excludes="/etc/portage/rsync_excludes"
rsync_excludes_output="/tmp/rsync_excludes-new"
check_eix() {
eix --help 2>&1 > /dev/null
if [ $? -eq 127 ];
then
echo "eix not found."
echo "Please install app-portage/eix."
exit
fi
}
show_dialog() {
categories=( `cat /usr/portage/profiles/categories` )
items=""
all_counter=0
for i in $(seq 0 $((${#categories[@]} - 1)))
do
dialog --infobox "Analysing categories... ($i/$((${#categories[@]})))" 3 40
# get installed packages in category
installed_packages=`eix -I -n -c -C ${categories[$i]} | grep "Found" | grep "matches." | tr -d -c [:digit:]`
all_packages[$i]=`eix -n -c -C ${categories[$i]} | grep "Found" | grep "matches." | tr -d -c [:digit:]`
if [ -z $installed_packages ]
then
installed_packages=`eix -I -n -c -C ${categories[$i]} | grep -v "No matches found." | wc -l`
if [ -z $installed_packages ]
then
installed_packages="0"
fi
fi
if [ -z $all_packages[$i] ]
then
all_packages[$i]=`eix -n -c -C ${categories[$i]} | grep -v "No matches found." | wc -l`
if [ -z ${all_packages[$i]} ]
then
all_packages[$i]="0"
fi
fi
# add to items
grep ${categories[$i]} $rsync_excludes 2>&1 > /dev/null
if [ 0 -eq $? ];
then
items="${items} ${categories[$i]} '$installed_packages of ${all_packages[$i]} installed' on";
else
items="${items} ${categories[$i]} '$installed_packages of ${all_packages[$i]} installed' off";
fi
all_counter=$[$all_counter+${all_packages[$i]}]
done
bash -c "dialog \
--checklist 'Select categories to exclude' 25 50 19 $items" 2> $rsync_excludes_output
if [ 0 -ne $? ]
then
echo "exiting as desired"
exit
fi
unselected_categories=(`cat $rsync_excludes_output | tr -d '"' | awk 'BEGIN{ FS="parc" } { print $1 "\n"}'`)
echo > $rsync_excludes_output
exclude_counter=0
for i in $(seq 0 $((${#unselected_categories[@]} - 1)))
do
for j in $(seq 0 $((${#categories[@]} - 1)))
do
if [ "${unselected_categories[$i]}" = "${categories[$j]}" ]
then
exclude_counter=$[$exclude_counter+${all_packages[$i]}]
fi
done
echo ${unselected_categories[$i]}/* >> $rsync_excludes_output
done
echo "$exclude_counter of $all_counter packages excluded."
}
main() {
check_eix
show_dialog
echo "Categories to exclude written to ${rsync_excludes_output}"
echo "Please check file, move it to ${rsync_excludes} and add RSYNC_EXCLUDEFROM=/etc/portage/rsync_excludes to /etc/make.conf"
echo
echo "Thank you for unburding the Gentoo Linux rsync servers!"
}
main
|
Update:
- Categories mit nur einem installieren Paket werden nun richtig erkannt
- Anzeige wieviele "excluded" wurden
- Abbrechbar _________________ Build your own live cd with catalyst 2.0! |
|