Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
To have a fast look at ebuilds
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Unsupported Software
View previous topic :: View next topic  
Author Message
kKDu
Apprentice
Apprentice


Joined: 18 Aug 2003
Posts: 187

PostPosted: Fri Oct 03, 2003 3:05 pm    Post subject: To have a fast look at ebuilds Reply with quote

[NOTE]: The same result of these script you can get now with esearch.
Code:
esearch -e sylpheed-claws
[ U] sylpheed-claws (0.9.7):  Bleeding edge version of Sylpheed
 Portage [1] sylpheed-claws-0.9.5-r1
 Portage [2] sylpheed-claws-0.9.7
 Portage [3] sylpheed-claws-0.9.8
 Overlay [4] sylpheed-claws-0.9.5-r2
 
Show Ebuild:

Only the lookout is little different.
[/NOTE]

Often I would like to have a fast look in a ebuild. So I have created a short script, called ecat, that is doing this.

Now I must only write
Code:
ecat sylpheed-claws
in any directory and I see a list in which I can choose the sylpheed-claws-ebuild I want to see.

Code:
evim sylpheed-claws
The last stable version is:
  [ U] sylpheed-claws (0.9.7): Bleeding edge version of Sylpheed
 
Choose a ebuild...:
[ 1 ]   sylpheed-claws-0.9.5-r1
[ 2 ]   sylpheed-claws-0.9.7
[ 3 ]   sylpheed-claws-0.9.8
[ 4 O]   sylpheed-claws-0.9.5-r2
...by entering a number:


Here is the script:
NOTE: You must have emerged esearch
Code:
#!/bin/bash

# here you can put an editor of your choice, if you
# don't want to use the global $EDITOR
LOCAL_EDITOR="" 

if [ "$LOCAL_EDITOR" ]; then
  ECAT="$LOCAL_EDITOR"
elif [ "$EDITOR" ]; then
  ECAT="$EDITOR"
else
  ECAT="cat"
fi

PORTDIR="/usr/portage"
#Looks for ${PORTDIR} and ${PORTDIR_OVERLAY}
source /etc/make.conf

#Set up colors
NO="\x1b[0;0m"
BR="\x1b[0;01m"
CY="\x1b[36;01m"
GR="\x1b[32;01m"

#Use ${PORTDIR} if it exists
if [ -d ${PORTDIR}"/"`esearch -n ^$1\$ | awk 'NR==4 { print $2 }'` ]; then
  edir=${PORTDIR}"/"`esearch -n ^$1\$ | awk 'NR==4 { print $2 }'`
fi
#Use ${PORTDIR_OVERLAY} if it exists, too.
if [ -d ${PORTDIR_OVERLAY}"/"`esearch -n ^$1\$ | awk 'NR==4 { print $2 }'` ]; then
  edir_overlay=${PORTDIR_OVERLAY}"/"`esearch -n ^$1\$ | awk 'NR==4 { print $2 }'`
fi

echo -e $GR"The last stable version is:"$NO
echo "  "`esearch -c ^$1\$`
echo " "
echo -e $GR"Choose a ebuild...:"$NO
#List the ebuilds. Ebuilds, that are in ${PORTDIR_OVERLAY} are listen at
#the end with a O next to their number
declare -a ebuild
for i in `ls $edir | awk '/ebuild$/ { print }'`;do
  z=$[$z+1]
  echo -e "["$CY $z $NO"]  "$BR $i $NO | sed 's/\.ebuild//g'
  ebuild[$z]=$i
done
for i in `ls $edir_overlay | awk '/ebuild$/ { print }'`; do
  z=$[$z+1]
  echo -e "["$CY $z" O"$NO"]  "$BR $i $NO | sed 's/\.ebuild//g'
  ebuild[$z]=$i
done
echo -ne $GR"...by entering a number: "$NO
read number
if [ $number ]; then
  echo " "
  echo "   * * * "$ECAT" "${ebuild[$number]}" * * *"
  echo " "
  if [ -e $edir/${ebuild[$number]} ]; then
    $ECAT $edir/${ebuild[$number]} #| less
  else
    $ECAT $edir_overlay/${ebuild[$number]} #| less
  fi
fi




Changelog
2003-10-03 if you press enter instead of a number, you are leaving the script
2003-10-21 change the editor choosing dialog
2004-01-21 now overlay works correct and I have change the EDITOR dialog again


Last edited by kKDu on Wed Jan 21, 2004 7:42 pm; edited 10 times in total
Back to top
View user's profile Send private message
Pythonhead
Developer
Developer


Joined: 16 Dec 2002
Posts: 1801
Location: Redondo Beach, Republic of Calif.

PostPosted: Fri Oct 03, 2003 3:39 pm    Post subject: Reply with quote

Very handy.

It would be nice if you could have it also check the overlay directory.
You could grab those values pretty easily with:

Code:
source /etc/make.conf


Then reference ${PORTDIR} and ${PORTDIR_OVERLAY}
Back to top
View user's profile Send private message
kKDu
Apprentice
Apprentice


Joined: 18 Aug 2003
Posts: 187

PostPosted: Fri Oct 03, 2003 4:08 pm    Post subject: Reply with quote

Nice trick.

I have added it :D

:oops: But not enough, now only /usr/portage, ${PORTDIR} or {PORTDIR_OVERLAY} are avaiable. But if you have some ebuilds in /usr/portage for mozilla and some in ${PORTDIR_OVERLAY}, only ebuilds in /usr/portage will be avaiable.

I'm going to change this
Back to top
View user's profile Send private message
kKDu
Apprentice
Apprentice


Joined: 18 Aug 2003
Posts: 187

PostPosted: Fri Oct 03, 2003 5:54 pm    Post subject: Reply with quote

Now it works for me with all, ${PORTDIR} and ${PORTDIR_OVERLAY} ebuilds. Ebuilds from ${PORTDIR_OVERLAY} are identified with a O next to their number:
Code:
root #ecat freevo
The last stable version is:
  [MN] freevo (1.3.4): Digital video jukebox (PVR, DVR). [ N] freevo (1.3.1): Freevo
 
Choose a ebuild...:
[ 1 ]   freevo-1.3.4
[ 2 O]   freevo-1.3.1
[ 3 O]   freevo-1.3.2_pre2-r2
[ 4 O]   freevo-1.3.2_pre3
[ 5 O]   freevo-1.3.2_pre4
...by entering a number:


Have fun with it :twisted:
Back to top
View user's profile Send private message
kKDu
Apprentice
Apprentice


Joined: 18 Aug 2003
Posts: 187

PostPosted: Sat Oct 04, 2003 5:14 pm    Post subject: Reply with quote

Important change (see change-log)
Back to top
View user's profile Send private message
saskatchewan46
n00b
n00b


Joined: 08 Jul 2003
Posts: 57
Location: Saskatchewan

PostPosted: Sat Oct 18, 2003 4:24 am    Post subject: Reply with quote

This is very useful and fast script. I edited it slightly and renamed it "enano" as I nano the ebuild rather than cat. Thanks muchly for this...
Back to top
View user's profile Send private message
BitJam
Advocate
Advocate


Joined: 12 Aug 2003
Posts: 2506
Location: Silver City, NM

PostPosted: Sat Oct 18, 2003 4:40 am    Post subject: Reply with quote

Kudos kKDu for a great script. It deserves a place in gentoolkit.
Back to top
View user's profile Send private message
haceye
Apprentice
Apprentice


Joined: 22 May 2003
Posts: 187
Location: Stuttgart, Germany

PostPosted: Mon Oct 20, 2003 3:26 pm    Post subject: Reply with quote

Hi,

I have talked to kKDu and he allowed me to add a similar function to directly into esearch.

You can use it like this:
Code:

$ emerge ">=esearch-0.5" # You need the current version
$ esearch -e gentoolkit
[ U] gentoolkit (0.1.33):  Collection of unofficial administration scripts for Gentoo
 Portage [1] gentoolkit-0.1.32
 Portage [2] gentoolkit-0.1.33
 Portage [3] gentoolkit-0.1.32-r1

Show Ebuild: 2
# ...


David
_________________
faster 'emerge -s'? emerge esearch
Back to top
View user's profile Send private message
BitJam
Advocate
Advocate


Joined: 12 Aug 2003
Posts: 2506
Location: Silver City, NM

PostPosted: Mon Oct 20, 2003 4:13 pm    Post subject: Reply with quote

haceye wrote:
I have talked to kKDu and he allowed me to add a similar function to directly into esearch.


It works great! I have one suggestion. After I am done looking at an ebuild I would prefer to be taken back to the list of ebuilds instead of exiting. Maybe the choice of zero could be used to exit.
Back to top
View user's profile Send private message
kKDu
Apprentice
Apprentice


Joined: 18 Aug 2003
Posts: 187

PostPosted: Mon Oct 20, 2003 5:11 pm    Post subject: Reply with quote

Oh yes, it works :D

The only thing, I'm missing is a sort list of output:
Code:
 esearch -e mozilla
...
[ U] mozilla (1.4-r3):  The Mozilla Web Browser
 Portage [7] mozilla-1.5
 Portage [8] mozilla-1.4-r3
 Portage [9] mozilla-1.0.1-r3
 Portage [10] mozilla-1.1-r1
 Portage [11] mozilla-1.4-r4
 Portage [12] mozilla-1.3-r2
 Portage [13] mozilla-1.2.1-r5

like this :wink:
Code:
ecat mozilla
The last stable version is:
  [ U] mozilla (1.4-r3): The Mozilla Web Browser
 
Choose a ebuild...:
[ 1 ]   mozilla-1.0.1-r3
[ 2 ]   mozilla-1.1-r1
[ 3 ]   mozilla-1.2.1-r5
[ 4 ]   mozilla-1.3-r2
[ 5 ]   mozilla-1.4-r3
[ 6 ]   mozilla-1.4-r4
[ 7 ]   mozilla-1.5
...by entering a number:
Back to top
View user's profile Send private message
haceye
Apprentice
Apprentice


Joined: 22 May 2003
Posts: 187
Location: Stuttgart, Germany

PostPosted: Mon Oct 20, 2003 8:22 pm    Post subject: Reply with quote

Hi kKDu (I hope I spelled it right ;-)),

I noticed this error, too. It occurs because listdir() doesn't sort it's output. Here's a little patch to fix this.
Will be part of esearch-0.5.1, of course.

Code:

54c54,56
<         for file in listdir(path):
---
>         list = listdir(path)
>         list.sort()
>         for file in list:


David
_________________
faster 'emerge -s'? emerge esearch
Back to top
View user's profile Send private message
meowsqueak
Veteran
Veteran


Joined: 26 Aug 2003
Posts: 1549
Location: New Zealand

PostPosted: Mon Oct 20, 2003 10:43 pm    Post subject: Reply with quote

Why not have a variable defined at the top that you can easily change to support nano, vi, etc. Then you don't have to worry about searching and replacing through the script.
Back to top
View user's profile Send private message
BitJam
Advocate
Advocate


Joined: 12 Aug 2003
Posts: 2506
Location: Silver City, NM

PostPosted: Wed Oct 29, 2003 4:16 pm    Post subject: Reply with quote

meowsqueak wrote:
Why not have a variable defined at the top that you can easily change to support nano, vi, etc. Then you don't have to worry about searching and replacing through the script.


The $PAGER variable might be a good choice. This should already be set to the pager of choice for most people and can be overrriden via:
Code:
PAGER=wacky_pager ecat ebuild
Back to top
View user's profile Send private message
meowsqueak
Veteran
Veteran


Joined: 26 Aug 2003
Posts: 1549
Location: New Zealand

PostPosted: Wed Oct 29, 2003 7:29 pm    Post subject: Reply with quote

No, do not use $PAGER throughout the script - that would not improve anything. Instead, use an internal variable everywhere in the script, and at the start, set this variable to $PAGER. Some people use this script with nano or vi, which is usually not in $PAGER, and may be in $EDITOR. Having to replace all instances of PAGER with EDITOR defeats the purpose of my original idea, but if there's a single line that you can change to, e.g. 'local PROG=$EDITOR' then it becomes easier to change. This is something that should be considered in ALL scripts - hardcoded program locations are bad too.

Define everything at the start, then use those internal variables throughout the script. That's part of what makes a script well-written.
Back to top
View user's profile Send private message
Genone
Retired Dev
Retired Dev


Joined: 14 Mar 2003
Posts: 9501
Location: beyond the rim

PostPosted: Sun Nov 16, 2003 5:39 am    Post subject: Reply with quote

We also have now ewhich in gentoolkit which will give you the ebuild filename portage would use for a given package name.
Back to top
View user's profile Send private message
kKDu
Apprentice
Apprentice


Joined: 18 Aug 2003
Posts: 187

PostPosted: Wed Jan 21, 2004 7:48 pm    Post subject: Reply with quote

For all that have had problems with the overlay-directory and the sort of the ebuilds, this is now fixed.

NOTE: you don't need this script, if you are happy with esearch -e, which does the same.
Back to top
View user's profile Send private message
razamatan
Apprentice
Apprentice


Joined: 28 Feb 2003
Posts: 160

PostPosted: Thu Jan 22, 2004 3:39 am    Post subject: Reply with quote

Genone wrote:
We also have now ewhich in gentoolkit which will give you the ebuild filename portage would use for a given package name.


thanks for the heads up...

Code:
vi `ewhich [pkgname]`


lovely.
_________________
a razamatan doth speaketh,
"Never attribute to malice, that which can be adequately explained by stupidity"
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Unsupported Software 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