Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Update slotted packages
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

Joined: 02 Jun 2002
Posts: 1978
Location: Rennes, France

PostPosted: Wed Jul 23, 2003 1:08 am    Post subject: Update slotted packages Reply with quote

If you have some slotted packages in multiple versions installed (for instance, I had gimp-1.2.3-r2 in slot 1.2 and gimp-1.3.16 in slot 1.4), then "emerge -u world" only updates the one of the greater version (gimp-1.3.16), and ignores the one in the old slot. I've written a small script which helps updating this forgot versions.

First, you to save need this python script somewhere (/root/bin/ for me):
#!/usr/bin/env python2.2

import sys,os,portage,string

def get_slot(pkg):
        #<cat/pkg-ver> expected
                return portage.db["/"]["porttree"].dbapi.aux_get(pkg,["SLOT"])
        except KeyError:

def best_in_same_slot(pkg):
   #<cat/pkg-ver> expected
   #list the available pkgs
   #we first try to get the slot of the package as installed
   if os.access("/var/db/pkg/"+pkg+"/SLOT",os.R_OK):
   #if we've failed, we try in the portage tree
   if not len(pkgslot):
           #keep only pkgs >= to pkg
           okaylist=filter((lambda p: portage.pkgcmp(psplit[1:],portage.catpkgsplit(p)[1:]) <= 0),fulllist)
      #if no match, we quit
      if not len(okaylist):
         return ""
      #if there are some matching package,
      #we keep the slot of the first one
      okaylist.sort(lambda p1,p2: portage.pkgcmp(portage.catpkgsplit(p1)[1:],portage.catpkgsplit(p2)[1:]))
   #no we have a slot, lets keep only matching pkgs
   okaylist=filter((lambda p: get_slot(p) == pkgslot),fulllist)
   #if no match, we quit
   if not len(okaylist):
      return ""
   #return the best matching pkg

def main():
   if not (len(sys.argv) == 2):
      #print "ERROR: exactly 1 arg is needed"
   if len(bestversion):
      print bestversion


You can test it like this:
# cd /root/bin
# ./ media-gfx/gimp-1.3.16
# ./ media-gfx/gimp-1.2.3-r2

Then, you can use the following bash script to find packages in multiple slots which have availables updates (it's called /root/bin/ for me):


for dbp in $( find /var/db/pkg/ -mindepth 2 -maxdepth 2 -type d \
      | sed s:"-[0-9].*":: | uniq -d )
   for dbpv in ${dbp}-*
      pv="`echo ${dbpv} | sed s:/var/db/pkg/::`"
      bestpv="`${BESTPKG_SCRIPT} ${pv}`"
      [ -z ${bestpv} ] || [ ${bestpv} == ${pv} ] || echo "=${bestpv}"
done | sort -u

It will output a list of multiple-versions-installed packages which have updates in their slots:

You can now easily feed emerge with this output to update what portage has missed:
# emerge -pv $( ./ )

And that's it.
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