View previous topic :: View next topic |
Author |
Message |
Zucca Moderator
Joined: 14 Jun 2007 Posts: 3345 Location: Rasi, Finland
|
Posted: Tue Jan 06, 2009 10:00 pm Post subject: merge.sh - merge packages using dialog |
|
|
Here's a neat & dirty bash script that uses eix to search and emerge to install packages. By default it searches non-installed packages.
You need to emerge 'eix' first if you don't have it already intalled.
I tested this with eix 0.15.2 (i686-pc-linux-gnu).
Here's the source: Code: | #!/bin/bash
# merge.sh - merge packages easily
# Version 0.0.2b
EIXOUTPUT=`eix -c --not -I '' $@ | grep '^\[.\] ' | sed -e 's/^.\{4\}//' -e "s/\"/'/g"`
# On above line I had to replace every " with '. I tried to escape but didn't work.
if [ `wc -c <<< "$EIXOUTPUT"` -gt 4 ]
then
MERGELIST=`mktemp -t "merge_list_XXXXX"`
while read LINE
do
echo -n "${LINE%% *} "
echo -ne "\"${LINE#* }\" "
echo "off"
done <<< "$EIXOUTPUT" | xargs dialog --title 'Dialog merge' --single-quoted --checklist "Found `wc -l <<< "$EIXOUTPUT"` matches." 0 0 0 2> "$MERGELIST" || ( clear && echo "You aborted or your search matched too many packages." && exit 1 ) || exit 1
clear
sed -i "s/'//g" $MERGELIST
emerge -vaD `cat $MERGELIST`
rm "$MERGELIST"
else
echo "Your search made no results."
exit 1
fi |
And this is how you use it: ./merge.sh [eix search options]
Examples: Code: | ./merge.sh -C 'games-action' |
Next one lists same category but only with stable packages:
Code: | ./merge.sh --stable+ -C 'games-action' |
Search for proxy software:
Search for proxy from descs:
Code: | ./merge.sh -S proxy |
Note: if you change eix's behaviour from compact (specifying verbose or normal output) this script will fail. Also note that dialog has it's limit's displaying many results. I could do a workaround for this (Like showing maxium of 500 results per dialog. After 'OK' next 500 results are shown... and so on.)... We'll see if I (or someone else?!?) will improve this more some day...
Anyway: have fun. Be sure to check unmerge.sh too. _________________ ..: Zucca :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote: | I am NaN! I am a man! |
Last edited by Zucca on Sat May 16, 2009 10:41 am; edited 1 time in total |
|
Back to top |
|
|
Bones McCracker Veteran
Joined: 14 Mar 2006 Posts: 1611 Location: U.S.A.
|
Posted: Sun Jan 11, 2009 5:43 am Post subject: |
|
|
Nice work. Thanks. |
|
Back to top |
|
|
imake n00b
Joined: 08 Jan 2009 Posts: 7
|
Posted: Tue Jan 13, 2009 5:22 pm Post subject: Re: merge.sh - merge packages using dialog |
|
|
Thanks!This is very useful |
|
Back to top |
|
|
Zucca Moderator
Joined: 14 Jun 2007 Posts: 3345 Location: Rasi, Finland
|
Posted: Sat May 16, 2009 10:42 am Post subject: |
|
|
UPDATE: Now works with the new emerge command.
Also I'm planning to simplify this script alot... _________________ ..: Zucca :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote: | I am NaN! I am a man! |
|
|
Back to top |
|
|
|