On Thu, May 8, 2008 at 6:47 PM, Allan McRae <mcrae_allan@hotmail.com> wrote:
R. Dale Thomas wrote:
[snip]
Well, I made the following changes to speed it up by 40%:
39c39 < pacman -Sl > $pkglist ---
pacman -Sl | grep "^$1" > $pkglist 42c42 < match=$(grep -m1 " $pkg " $pkglist | grep "^$1")
match=$(grep -m1 " $pkg " $pkglist)
The problem with those changes is if a package is in [testing] and [core] you only want to match it to the first repo in your pacman.conf (i.e. [testing] in this case). Your change would match it in both repos.
Allan
I used wc to shorten the output; the package list is the same in both cases, except my version also shows and matches version numbers. dmcgee@dublin /tmp $ time ./repopkg.orig testing | wc -l 28 real 0m13.195s user 0m9.166s sys 0m3.343s dmcgee@dublin /tmp $ time ./repopkg testing | wc -l 28 real 0m6.445s user 0m4.523s sys 0m1.203s The magic: pkglist=$(mktemp) pacman -Sl $1 > $pkglist pacman -Q | while read pkg; do ret=0 grep -q "$pkg" $pkglist || ret=$? if [ $ret -eq 0 ]; then echo $pkg fi done rm $pkglist And sample output: $ ./repopkg testing bzip2 1.0.5-2 exiv2 0.16-2 inputproto 1.4.3-1 kernel26 2.6.25-1 kismet 2007_10_R1-1 kqemu 1.3.0pre11-19 libldap 2.3.40-1 libtool 2.2.2-1 libx11 1.1.4-1 libxkbfile 1.0.5-1 libxv 1.0.4-1 licenses 2.4-1 links 2.1pre35-1 mesa 7.0.3rc3-1 nasm 2.01-1 ntfs-3g 1.2412-1 nvidia-96xx 96.43.05-3 openssh 5.0p1-1 patch 2.5.9-1 pinentry 0.7.3-2 postgresql 8.3.0-1 postgresql-libs 8.3.0-1 printproto 1.0.4-1 qt 4.3.4-1 sudo 1.6.9p15-1 xf86-video-nv 2.1.8-1 xorg-server 1.4.0.90-10 xproto 7.0.12-1 -Dan