Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Script] Categories-Exclude-Tool
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German)
View previous topic :: View next topic  
Author Message
manuels
Advocate
Advocate


Joined: 22 Nov 2003
Posts: 2146
Location: Europe

PostPosted: Sun Aug 19, 2007 4:44 pm    Post subject: [Script] Categories-Exclude-Tool Reply with quote

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!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum