jackal
2004-05-05, 05:58 PM CDT
After finding that the -C flag to yum was not working as expected, which should make it use the cache and not download all the headers from the repos, I made this little bash script. This will search the cache of headers that you currently have downloaded on your machine, with almost no latency.
It is very trivial, but since I'm sure some users don't know how to write bash scripts at all, I thought I would post it here:
To use the script, create a plain text file with you favorite text editor (vim, emacs, gedit, etc) with the following code and save it as /usr/bin/yum-search. Then, as root, make it executable with "chmod 755 /usr/bin/yum-search" (without the double quotes).
#!/bin/bash
if [ $# -gt 0 ]; then
find /var/cache/yum/ | grep -v packages | sed "s|^/var/cache/yum/||g" | grep -i $1
else
echo -e "Useage: yum-search <pkgname>\n"
fi
The output looks as follows:
[john@diablo john]$ yum-search
Useage: yum-search <pkgname>
[john@diablo john]$ yum-search mplayer
livna-stable/headers/mplayer-mencoder-0-0.92-0.lvn.1.1.91.i386.hdr
livna-stable/headers/mplayer-gui-0-0.92-0.lvn.1.1.91.i386.hdr
livna-stable/headers/mplayer-skins-0-1.2-0.lvn.1.1.90.noarch.hdr
livna-stable/headers/mplayerplug-in-0-2.11-0.lvn.2.1.90.i386.hdr
freshrpms/headers/mplayer-skins-0-1.3-3.fr.noarch.hdr
freshrpms/headers/mplayer-0-1.0-0.9.20040415.1.fc1.fr.i386.hdr
freshrpms/headers/mplayer-fonts-0-1.1-2.fr.noarch.hdr
[john@diablo john]$
EDIT - edited to get rid of the redundant "packages" display
It is very trivial, but since I'm sure some users don't know how to write bash scripts at all, I thought I would post it here:
To use the script, create a plain text file with you favorite text editor (vim, emacs, gedit, etc) with the following code and save it as /usr/bin/yum-search. Then, as root, make it executable with "chmod 755 /usr/bin/yum-search" (without the double quotes).
#!/bin/bash
if [ $# -gt 0 ]; then
find /var/cache/yum/ | grep -v packages | sed "s|^/var/cache/yum/||g" | grep -i $1
else
echo -e "Useage: yum-search <pkgname>\n"
fi
The output looks as follows:
[john@diablo john]$ yum-search
Useage: yum-search <pkgname>
[john@diablo john]$ yum-search mplayer
livna-stable/headers/mplayer-mencoder-0-0.92-0.lvn.1.1.91.i386.hdr
livna-stable/headers/mplayer-gui-0-0.92-0.lvn.1.1.91.i386.hdr
livna-stable/headers/mplayer-skins-0-1.2-0.lvn.1.1.90.noarch.hdr
livna-stable/headers/mplayerplug-in-0-2.11-0.lvn.2.1.90.i386.hdr
freshrpms/headers/mplayer-skins-0-1.3-3.fr.noarch.hdr
freshrpms/headers/mplayer-0-1.0-0.9.20040415.1.fc1.fr.i386.hdr
freshrpms/headers/mplayer-fonts-0-1.1-2.fr.noarch.hdr
[john@diablo john]$
EDIT - edited to get rid of the redundant "packages" display