Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
merge.sh - merge packages using dialog
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
Zucca
Apprentice
Apprentice


Joined: 14 Jun 2007
Posts: 201
Location: Helsinki, Finland

PostPosted: Tue Jan 06, 2009 10:00 pm    Post subject: merge.sh - merge packages using dialog Reply with quote

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:
Code:
./merge.sh proxy

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. ;)
_________________
Threading support for your bash scripts.


Last edited by Zucca on Sat May 16, 2009 10:41 am; edited 1 time in total
Back to top
View user's profile Send private message
Bones McCracker
Veteran
Veteran


Joined: 14 Mar 2006
Posts: 1553
Location: U.S.A.

PostPosted: Sun Jan 11, 2009 5:43 am    Post subject: Reply with quote

Nice work. Thanks.
Back to top
View user's profile Send private message
imake
n00b
n00b


Joined: 08 Jan 2009
Posts: 7

PostPosted: Tue Jan 13, 2009 5:22 pm    Post subject: Re: merge.sh - merge packages using dialog Reply with quote

Thanks!This is very useful
Back to top
View user's profile Send private message
Zucca
Apprentice
Apprentice


Joined: 14 Jun 2007
Posts: 201
Location: Helsinki, Finland

PostPosted: Sat May 16, 2009 10:42 am    Post subject: Reply with quote

UPDATE: Now works with the new emerge command.
Also I'm planning to simplify this script alot...
_________________
Threading support for your bash scripts.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks 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