The New Cult of Dead Cow

June 7, 2006






Instalar sin Red

Filed under: Programacion, Linux

A pedido de mi primo, quien ultimamente no tiene internet para poder jugar con su ubuntu, me puse a hacer un pequeño script en python para obtener las URIs de los paquetes necesarios para instalar cualquier software.

#!/usr/bin/python

import sys
import getopt
import re
import commands

def main():
    try:
        opts, args = getopt.getopt(sys.argv[1:], “h” , [”help”])
    except getopt.error, msg:
        print msg
        print “For help usr –help”
        sys.exit(2)
        
    # La orden geturls indica que todos los nombres isguientes son
    # paquetes, el resultado es una lista con la URL de todos los
    # deb necesarios para instalar los paquetes
    if args[0] == “geturls” :
        for pkg in args[1:]:
            [a,out] = commands.getstatusoutput(’apt-get –print-uris -y  install ‘ + pkg)
            getURL(out)
    
def getURL(buffer):
    results = []
    buffer = buffer.split(’\n’)
    for line in buffer:
        url = re.search(”‘([A-Za-z0-9\-\./\:_]*)’”,line)
        if url == None : continue
        print url.group(1)

if __name__ == “__main__”:
    main() 
   


Supongo, y es casi seguro, que tiene fallas. Si alguien sugiere alguna mejora o encuentra algun error, se lo agradecere.
Pero igual de momento sirve para lo que fue creado

[necudeco@kelthuzad naptitude]$ naptitude geturls tuxpaint
http://pe.archive.ubuntu.com/ubuntu/pool/main/t/tuxpaint-stamps/tuxpaint-stamps-default_2005.11.25-1ubuntu2_all.deb
http://pe.archive.ubuntu.com/ubuntu/pool/main/t/tuxpaint/tuxpaint-data_0.9.15b-1ubuntu4_all.deb
http://pe.archive.ubuntu.com/ubuntu/pool/main/t/tuxpaint/tuxpaint_0.9.15b-1ubuntu4_i386.deb

3 Comments »

The URI to TrackBack this entry is: http://necudeco.blogsome.com/2006/06/07/instalar-sin-red/trackback/

  1. Como instalar sin red

    Alguna vez has tenido que instalar paquetes en una PCDebian que no tenia conexion a internet? O en tu casa la conexion es desastrozamente lenta ?

    Pues, usando este script podes obtener la lista de paquetes que debes bajar, irte a una cabina publica …

    Trackback by meneame.net — June 7, 2006 @ 1:23 am

  2. Debian (y por tanto ubuntu) ya tiene una herramienta para hacer precisamente esto. Se llama apt-zip.

    Saludos

    Comment by pnongrata — June 9, 2006 @ 8:44 am

  3. Juaz me entere tarde .. pero no importa :D !! Al menos me entretuve haciendola.

    Comment by NeCuDeCo — June 9, 2006 @ 11:24 am

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>























Get free blog up and running in minutes with Blogsome
Theme designed by B A Khan