You are not logged in.

#1 2006-08-20 22:07:58

wrythe
Member
From: Seattle, WA
Registered: 2006-08-15
Posts: 80

Another pacman colored output script. [revised]

Hi. My name is Justin and I'm an Archoholic.

I'm aware of the colored output scripts already out there for pacman. They're nice, but I want more. In these forums I keep seeing Gentoo and emerge get tossed around, and I'd hate to do it myself, but during my short-lived experience with Gentoo it didn't take much to take a liking to emerge. Not necessarily it's power with package management, but it's a package manager that at least gives you more information than the package name and description when doing a search (if you want it to). What I've been mainly looking for in pacman's searches is package version information. It's extremely helpful (to me, at least) for not only the package version to be displayed (which it is) but also the installed version if the package is installed. Colored output, of course, is just an added bonus. smile

This has given me an excuse to dust off my scripting skills (as crude as they may be). There's probably an easier way of doing this than I have, but bash scripting isn't my strength as a programmer. Any feedback is appreciated. I've only testing this on one system, so I don't know how slow it may be on others. I'm calling the script "pak" for now, just because I'm not very creative. wink I tried to keep the color scheme as close to Arch's as possible (white, blue, and cyan) and it only displays "current" and "extra" at the moment. I haven't explored any other repositories yet, so I didn't incorporate them. Scope it out if you get a chance and let me know what you think.

And, sorry in advance for the length of the code pasted in here. I have no idea how to do it in a scrollable box. If someone cares to enlighten me then I'll be happy to edit it smile

usage is

pak -s [search-string] (shorter output)
pak -l [search-string] (lengthier output)

EDIT: Code removed and linked below.


psearch - manipulate and refine pacman searches

Offline

#2 2006-08-21 19:43:26

Chman
Member
Registered: 2006-01-31
Posts: 169
Website

Re: Another pacman colored output script. [revised]

./pak: line 59: syntax error near unexpected token `elif'
./pak: line 59: `         elif [ ${line:0:7} = "current" ]; then'

Although I'm not a bash expert, I think some code is missing there :

   exec<packagesFile>> $extraFileTemp
         elif [ ${line:0:7} = "current" ]; then
            echo $line >> $currentFileTemp
         fi
      done
   exec<pos> $extraFile 

Offline

#3 2006-08-22 02:02:06

wrythe
Member
From: Seattle, WA
Registered: 2006-08-15
Posts: 80

Re: Another pacman colored output script. [revised]

Chman wrote:
./pak: line 59: syntax error near unexpected token `elif'
./pak: line 59: `         elif [ ${line:0:7} = "current" ]; then'

Lame sad I'm embarassed. As crude as my bash skills are, it works on my machine. This is how it looks on my machine.


psearch - manipulate and refine pacman searches

Offline

#4 2006-08-22 05:40:58

Purch
Member
From: Finland
Registered: 2006-02-23
Posts: 229

Re: Another pacman colored output script. [revised]

yeah, same error here too. Well I hope you get script fixed wink

Offline

#5 2006-08-22 05:53:30

wrythe
Member
From: Seattle, WA
Registered: 2006-08-15
Posts: 80

Re: Another pacman colored output script. [revised]

Purch wrote:

yeah, same error here too. Well I hope you get script fixed wink

Arrgh.. Do you mind if I ask which repositories you're using?


psearch - manipulate and refine pacman searches

Offline

#6 2006-08-22 06:39:17

Purch
Member
From: Finland
Registered: 2006-02-23
Posts: 229

Re: Another pacman colored output script. [revised]

Current, extra, community, xfce-svn, shadowhand, but I dont think that is the problem.

just to point out in this...

exec<packagesFile>> $extraFileTemp 
         elif [ ${line:0:7} = "current" ]; then 
            echo $line >> $currentFileTemp 
         fi 
      done 
exec<pos> $extraFile

should be $packagesFile
why elif
why done

but any way those did not fix the error totally. What about the read line stuff like for localVersion and localFile?

Offline

#7 2006-08-22 07:20:40

patson
Member
Registered: 2006-08-22
Posts: 26

Re: Another pacman colored output script. [revised]

Suggestion: post the script as a file on a server somewhere, the forum may damage both formatting and line breaks (which can lead to pretty amazing errors.. believe me, I know).

Offline

#8 2006-08-22 14:03:45

elasticdog
Member
From: Washington, USA
Registered: 2005-05-02
Posts: 995
Website

Re: Another pacman colored output script. [revised]

patson wrote:

Suggestion: post the script as a file on a server somewhere, the forum may damage both formatting and line breaks (which can lead to pretty amazing errors.. believe me, I know).

http://bash.pastebin.com/ would be a great option.

Offline

#9 2006-08-22 15:31:46

wrythe
Member
From: Seattle, WA
Registered: 2006-08-15
Posts: 80

Re: Another pacman colored output script. [revised]

elasticdog wrote:
patson wrote:

Suggestion: post the script as a file on a server somewhere, the forum may damage both formatting and line breaks (which can lead to pretty amazing errors.. believe me, I know).

http://bash.pastebin.com/ would be a great option.

Good idea. I have it up here: http://bash.pastebin.com/773280


psearch - manipulate and refine pacman searches

Offline

#10 2006-08-22 20:00:49

Chman
Member
Registered: 2006-01-31
Posts: 169
Website

Re: Another pacman colored output script. [revised]

Works well now.

Very nice script, I really like the output, but it's only working with current/community/extra repositories. What about testing/unstable/custom's ?

Offline

#11 2006-08-23 00:49:52

wrythe
Member
From: Seattle, WA
Registered: 2006-08-15
Posts: 80

Re: Another pacman colored output script. [revised]

Chman wrote:

Works well now.

Very nice script, I really like the output, but it's only working with current/community/extra repositories. What about testing/unstable/custom's ?

Nice! Glad it's working. I've since modified it to get the community repo in there, but nothing else. I'm actually working on a revision that will pull the user's repositories out of the pacman.conf file, but it's giving me some troubles. We'll see if I can get the kinks worked out.. then no further modification will have to be done for added repositories.


psearch - manipulate and refine pacman searches

Offline

#12 2006-08-23 18:11:20

wrythe
Member
From: Seattle, WA
Registered: 2006-08-15
Posts: 80

Re: Another pacman colored output script. [revised]

Chman wrote:

What about testing/unstable/custom's ?

OK. Revision can be found here. No repositories are named explicitly in the scripts--they're all pulled from pacman.conf... so, it should display all of your repositories. I'm still working on ways to display only a specified repository or to omit a string since some of this searches can be absolutely huge.


psearch - manipulate and refine pacman searches

Offline

#13 2006-08-23 21:20:53

Pierluigi
Member
Registered: 2004-04-10
Posts: 90
Website

Re: Another pacman colored output script. [revised]

i think you should add something like this:

if [ $# != 2 ]; then
        echo "Error. Use pak -h for help."
        exit 0
fi


to check if the user is passing a wrong number of params. (simply calling ./pak without any options returns some not-so-userfriendly errors)

Offline

#14 2006-08-25 04:11:11

wrythe
Member
From: Seattle, WA
Registered: 2006-08-15
Posts: 80

Re: Another pacman colored output script. [revised]

OK. I've done a lot of work to this thing and I'd like you guys to try it out.. and try to break it.. so I can get all the bugs worked out. smile I've fixed a lot of the bugs, added some options, and it runs a lot faster now (there was a for loop in the original that hung up the search process if the package was installed).

It now searches all repositories listed in pacman.conf, has the ability to search a single repository, and can omit a string if you want it to--which is nice if you get a lot of results. I'm not a KDE user, but if I were then I a search for the string "KDE" would be a lot nicer being able to omit all of the international language packages. Check out "pak -h" for the details.

Download the script here and, again, any feedback is thoroughly appreciated.


psearch - manipulate and refine pacman searches

Offline

#15 2006-08-25 09:11:17

Pierluigi
Member
Registered: 2004-04-10
Posts: 90
Website

Re: Another pacman colored output script. [revised]

All i get is this:

[pigi@laptop ~]$ ./pak.htm -s wine
 > Searching...
 > 2 matches found for key term [ wine ]

[pigi@laptop ~]$ ./pak.htm -l wine
 > Searching...
 > 2 matches found for key term [ wine ]

pacman.conf :

[options]
LogFile     = /var/log/pacman.log
NoUpgrade   = etc/passwd etc/group etc/shadow
NoUpgrade   = etc/fstab etc/raidtab etc/ld.so.conf
NoUpgrade   = etc/rc.conf etc/rc.local
NoUpgrade   = etc/modprobe.conf etc/modules.conf
NoUpgrade   = etc/lilo.conf boot/grub/menu.lst
HoldPkg     = pacman glibc
IgnorePkg   = kernel26 ieee80211 mesa ipw2200 nvidia
ILoveCandy

[testing]
Server = ftp://mi.mirror.garr.it/mirrors/archlinux/testing/os/i686
Server = ftp://ftp.archlinux.org/testing/os/i686

[current]
Server = ftp://mi.mirror.garr.it/mirrors/archlinux/current/os/i686
Server = ftp://ftp.archlinux.org/current/os/i686

[extra]
Server = ftp://mi.mirror.garr.it/mirrors/archlinux/extra/os/i686
Server = ftp://ftp.archlinux.org/extra/os/i686

[community]
Server = ftp://mi.mirror.garr.it/mirrors/archlinux/community/os/i686
Server = ftp://ftp.archlinux.org/community/os/i686

[unstable]
Server = ftp://mi.mirror.garr.it/mirrors/archlinux/unstable/os/i686
Server = ftp://ftp.archlinux.org/unstable/os/i686

Include = /etc/pacman.d/unofficial

Offline

#16 2006-08-25 14:16:16

wrythe
Member
From: Seattle, WA
Registered: 2006-08-15
Posts: 80

Re: Another pacman colored output script. [revised]

Pierluigi wrote:

All i get is this:

[pigi@laptop ~]$ ./pak.htm -s wine
 > Searching...
 > 2 matches found for key term [ wine ]

OK, sorry. I'm still somewhat new to Arch. I was under the impression that, from everything that I've read up to this point, that repositories in one's pacman.conf were denoted with "Include = blah." I take it that that's not the case? Guess I'll start working on a re-write. smile

Sorry. This was supposed to be a neat, small script.. but it's turned into a monster, and a cluster!$@%

EDIT: Fixed.. I think. Changed a few lines of code. Try downloading and trying again now. smile


psearch - manipulate and refine pacman searches

Offline

#17 2006-08-25 16:44:59

IsSuE
Member
Registered: 2006-04-29
Posts: 309

Re: Another pacman colored output script. [revised]

edith: should learn to read...

Offline

#18 2006-08-25 17:46:34

Pierluigi
Member
Registered: 2004-04-10
Posts: 90
Website

Re: Another pacman colored output script. [revised]

sorry for reporting bad news, anyway:

[pigi@laptop ~]$ ./pak -s wine
 > Searching...  grep: dma147: No such file or directory
grep: extra: No such file or directory
grep: fubar: No such file or directory
grep: janitux: No such file or directory
grep: lost+found: No such file or directory
grep: marfis: No such file or directory
grep: pharfox: No such file or directory
grep: shadowhand: No such file or directory
grep: testing: No such file or directory
grep: unstable: No such file or directory
grep: vegai: No such file or directory
grep: xfce-svn/: No such file or directory
sed: -e expression #1, char 9: unterminated `s' command
grep: janitux: No such file or directory
grep: venox: No such file or directory
grep: xfce-svn: No such file or directory
grep: danimoth/: No such file or directory
sed: -e expression #1, char 15: unterminated `s' command
grep: lost+found/: No such file or directory
sed: -e expression #1, char 9: unterminated `s' command
grep: dma147: No such file or directory
grep: marfis/: No such file or directory
sed: -e expression #1, char 7: unterminated `s' command
grep: pharfox/: No such file or directory
sed: -e expression #1, char 7: unterminated `s' command
grep: shadowhand/: No such file or directory
sed: -e expression #1, char 7: unterminated `s' command
grep: dma147: No such file or directory
grep: testing/: No such file or directory
sed: -e expression #1, char 12: unterminated `s' command
grep: unstable/: No such file or directory
sed: -e expression #1, char 10: unterminated `s' command
grep: vegai/: No such file or directory
sed: -e expression #1, char 9: unterminated `s' command
-grep: marfis/: No such file or directory
sed: -e expression #1, char 9: unterminated `s' command

It seems that your scripts can't detect very well repos.

Give a look here: http://bbs.archlinux.org/viewtopic.php?t=23124

Using "pacman-info -cr" my repos are detected, so maybe you can steal a bit of code from there.

Offline

#19 2006-08-25 21:29:39

wrythe
Member
From: Seattle, WA
Registered: 2006-08-15
Posts: 80

Re: Another pacman colored output script. [revised]

Pierluigi wrote:

sorry for reporting bad news, anyway:

Damnit. Well, this script is working under the assumption that each repository has it's own directory under the repository's name in /var/lib/pacman. If that's not the case on your system, then that would explain the errors. If yours are all in there then there is a deeper problem. I will work on it some more a little later tonight and see if it can't be remedied. smile Thanks for all of your input.


psearch - manipulate and refine pacman searches

Offline

#20 2006-08-26 04:52:46

wrythe
Member
From: Seattle, WA
Registered: 2006-08-15
Posts: 80

Re: Another pacman colored output script. [revised]

Pierluigi wrote:

Give a look here: http://bbs.archlinux.org/viewtopic.php?t=23124

Using "pacman-info -cr" my repos are detected, so maybe you can steal a bit of code from there.

Pierluigi,

Try this and see if it works. Change line 37 of the script from this...

ls -1UF /var/lib/pacman | sed 's/local///g' | sed 's////g' | egrep '[^[ ]' > $reps

...to this:

pacman -Sl |awk '{ print $1 }'| uniq -c | awk '{ print $2 }' > $reps

See if that works. Thanks for your testing and feedback, by the way. smile


psearch - manipulate and refine pacman searches

Offline

#21 2006-08-26 05:32:13

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,899
Website

Re: Another pacman colored output script. [revised]

that works here but script seems slow

you thought about rewriting in Python?

Post in user contrib. ... add a link to your script in your sig

Start building a website for it ;-)

maybe add search AUR


Mr Green

Offline

#22 2006-08-26 14:08:44

wrythe
Member
From: Seattle, WA
Registered: 2006-08-15
Posts: 80

Re: Another pacman colored output script. [revised]

Mr Green wrote:

that works here but script seems slow

The most recent is much faster than it was, but, yeah, still kinda slow. :?

you thought about rewriting in Python?

Yeah, then I remembered.. I don't know Python. Maybe this would be a good opportunity to learn. Any suggestions where to start?


psearch - manipulate and refine pacman searches

Offline

#23 2006-08-26 14:16:50

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,899
Website

Re: Another pacman colored output script. [revised]

use what I use in a term type

Dusty --convert bash python

Python is not that hard to learn ... I would like to help too

let me see.....


Mr Green

Offline

#24 2006-08-26 17:14:31

Pierluigi
Member
Registered: 2004-04-10
Posts: 90
Website

Re: Another pacman colored output script. [revised]

wrythe wrote:

Try this and see if it works. Change line 37 of the script from this...

ls -1UF /var/lib/pacman | sed 's/local///g' | sed 's////g' | egrep '[^[ ]' > $reps

...to this:

pacman -Sl |awk '{ print $1 }'| uniq -c | awk '{ print $2 }' > $reps

See if that works. Thanks for your testing and feedback, by the way. smile

yes, now it works

indeed a nice and useful script, thank you  8)

Offline

#25 2006-08-26 17:23:39

wrythe
Member
From: Seattle, WA
Registered: 2006-08-15
Posts: 80

Re: Another pacman colored output script. [revised]

Pierluigi wrote:

yes, now it works

indeed a nice and useful script, thank you  8)

Awesome.. glad it's working. Thanks again for your input. I think the script a bit more solid now because of it.


psearch - manipulate and refine pacman searches

Offline

Board footer

Powered by FluxBB