Chris Lamb

Careful what you wish for...

Via #241343:

* Package name    : apt-gentoo
  Version         : 0.0.1
* URL             : http://www-jcsu.jesus.cam.ac.uk/~mma29/apt-gentoo/
* License         : GPL version 2 or above
  Description     : enhanced package installation

 apt-gentoo enhances the Debian package installation experience to make
 it fully competitive with newly-popular source-based distributions.

 As packages are installed, apt-gentoo automatically downloads their
 build logs from the buildd network. The logs are then slowly scrolled
 past on the user's terminal to simulate building the software on the
 local machine.

 [..]

So, something like:

#!/usr/bin/env python
#
# Insert into /etc/apt/conf.d/50apt-gentoo:
#
# DPkg {
#         Pre-Install-Pkgs { "/path/to/apt-gentoo || true"; };
# };

import time
import random
import urllib
import urllib2
import urlparse
import fileinput

from lxml import etree
from debian import debfile

for filename in fileinput.input():
    pkg_data = debfile.DebFile(filename.strip()).debcontrol()

    url = "https://buildd.debian.org/status/logs.php?%s" % urllib.urlencode({
        'pkg': pkg_data['Package'],
        'ver': pkg_data['Version'],
        'arch': pkg_data['Architecture'],
    })

    html = etree.parse(urllib2.urlopen(url), etree.HTMLParser())
    link = html.xpath("//table[@class='data logs']//td[3]/a")

    try:
        fetch_url = urlparse.urljoin(
            'https://buildd.debian.org/status/',
            link[0].get('href'),
        )
    except IndexError:
        continue

    html = etree.parse(urllib2.urlopen(fetch_url), etree.HTMLParser())

    try:
        log = html.xpath('//pre')[0].text.split('\n')
    except IndexError:
        continue

    for line in log:
        print line
        time.sleep(random.random() * 0.09)

Package/source and example installation transcript.


Chris Lamb is a freelance software developer and the current Debian Project Leader. You can read other posts by me, see software I have written or read more about me. You can also follow me @lolamby.


Tags: GNU/Linux Hacks

Planets: ALUG UWCS WUGLUG Debian

Friday 12th August 2011


Seven comments

Comments are closed.