Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
overlay -- the solution to foreign ebuild terrors
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
Sastraxi
Apprentice
Apprentice


Joined: 25 Feb 2003
Posts: 258

PostPosted: Tue Apr 13, 2004 2:26 am    Post subject: overlay -- the solution to foreign ebuild terrors Reply with quote

I took the chance while I was learning python a couple of weekends back to write this little script that will help you install ebuilds from wherever. Put it into /sbin and chmod +x.

Hopefully this will help :) Notification of bugs very much appreciated!! :lol:

Code:
#!/usr/bin/python
#by Cameron Gorrie <sastraxi@gmx.net>

import os, sys
import string, portage

def doUnpack(path):
   """Unpacks path into your portdir_overlay"""

   destdir = portage.settings["PORTDIR_OVERLAY"]

   ext = path.split('.')[-1]
   if ext == 'bz2':
      unpackcmd = 'tar -j'
   elif ext == 'tbz2':
      unpackcmd = 'tar -j'
   elif ext == 'gz':
      unpackcmd = 'tar -z'
   elif ext == 'tgz':
      unpackcmd = 'tar -z'
   elif ext == 'tar':
      unpackcmd = 'tar -'
   f = os.popen(unpackcmd + 'tf ' + path)

   outlines = f.readlines()
   pkgnames = list()
   basenames = list()

   for a in outlines:
      a = a.replace('\n', '')
      a = a.replace('./', '')     
      if a.split('.')[-1] == 'ebuild':
         ebpath = a.split('/')
         pkgnames += [ebpath[-1][0:ebpath[-1].rfind('-')]]
         thisbase = ebpath[-1][0:ebpath[-1].rfind('-')]
         if basenames.count(thisbase) == 0:
            if len(ebpath) == 1:
               appendpath = str(raw_input('category for ' + pkgnames[-1] + '? ')) + '/' + thisbase   
            elif len(ebpath) == 2:
               appendpath = str(raw_input('category? '))
            elif len(ebpath) == 3:
               appendpath = ''     
         basenames += [thisbase]

   if sys.argv.count('-v') > 0:
      print "Extracting:"
      for a in outlines:
         a = a.replace('\n', '')
         a = a.replace('./', '')
         print appendpath + '/' + a

   if sys.argv.count('-o') > 0:
      unpackcmd += ' --overwrite -'

   finalpath = destdir + '/' + appendpath
   os.system('mkdir -p ' + finalpath)
   os.system(unpackcmd + 'xpf ' + path + ' --directory=' + finalpath)

   print portage.green("***") + " " + str(len(pkgnames)) + " package(s) installed into " + destdir + ".\n"
   for a in pkgnames:
      print "   - " + a

def webEbuild(uri):
   """This gets an ebuild from the 'net and installs
      it into your portdir_overlay"""
   os.system('pushd /usr/portage/distfiles')
   os.system('wget ' + uri)
   a = uri.split('/')[-1:]
   doUnpack('/usr/portage/distfiles/' + str(a))
   os.system('popd');

def localEbuild(path):
   """This gets an ebuild from a local path and installs
      it into your portdir_overlay"""
   doUnpack(path)

print ''
if len(sys.argv) == 1:
   print " "+portage.yellow("***")+" overlay: you must specify an archive."
   print "     USAGE: overlay [OPTIONS] [FILE]"
   print "     -f: FILE is a URI"
   print "     -o: overwrite files"
   print "     -v: verbose mode"
elif sys.argv.count('-f') > 0:
   webEbuild(sys.argv[-1])
else:
   doUnpack(sys.argv[-1])
print ''


Last edited by Sastraxi on Thu Apr 15, 2004 2:22 am; edited 1 time in total
Back to top
View user's profile Send private message
joem
Retired Dev
Retired Dev


Joined: 20 Dec 2002
Posts: 508
Location: Bloomington, In

PostPosted: Tue Apr 13, 2004 3:20 am    Post subject: Reply with quote

This doesn't have much to do with the script(which is a nice idea), but the prefered way to get ebuilds from breakmygentoo would be to use the gensyc script from gentoolkit-dev. Looks like you are off to a good start with the scripting, keep it up.
Back to top
View user's profile Send private message
Sastraxi
Apprentice
Apprentice


Joined: 25 Feb 2003
Posts: 258

PostPosted: Tue Apr 13, 2004 3:57 am    Post subject: Reply with quote

I've read about that gensync but to my knowledge it only works with their gnome ebuild... or maybe the name bmg-gnome-current is just misleading?

Anyway, thanks for your compliments.
Back to top
View user's profile Send private message
nbrown
Tux's lil' helper
Tux's lil' helper


Joined: 26 Oct 2002
Posts: 140
Location: Somewhere in the NE

PostPosted: Wed Apr 14, 2004 4:46 am    Post subject: Reply with quote

It works with the bmg-main as well, look in the /etc/gensyc/ directory of all the targets you can define.

-nbrown
Back to top
View user's profile Send private message
Sastraxi
Apprentice
Apprentice


Joined: 25 Feb 2003
Posts: 258

PostPosted: Thu Apr 15, 2004 2:22 am    Post subject: Reply with quote

Awesome :lol:
I should probably change the "advertisment" of this thread to suit general ebuilds that you may download off the 'net :)
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