xenogenesi::blog
memento
3d adt android apache2 app apt aria2 build bullet cflags chromium codeigniter debian demoscene dependencies dpkg driver emulator freeglut gcc gfx git glut htaccess javascript json kernel linux make metalink minimal mysql opengl php python raspbian realtime rpi specs template toolchain update-alternatives video wifi wordpress

using aria2 with apt-get

source: Make apt-get MUCH faster using aria2!
see also: apt-metalink

sudo apt-get install aria2

apt-get -y --print-uris -qq upgrade|python2.6 apt2metalink.py > tmp.meta4

sudo aria2c -d /var/cache/apt/archives/ -M tmp.meta4 --file-allocation=none

apt2metalink.py:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# reference: http://ubuntuforums.org/showthread.php?t=1493421
import sys
import re

if __name__ == "__main__":
    entries = []
    while True:
        line = sys.stdin.readline()
        if not line: break
        uri, name, size, chksum = line.split()
        uri = re.sub(r"^'|'$", "", uri)
        hashfunc, hashvalue = chksum.split(':')
        hashfunc = hashfunc.lower()
        if hashfunc == 'sha256':
            hashfunc = 'sha-256'
        entries.append((uri, name, size, hashfunc, hashvalue))

    print """<?xml version="1.0" encoding="UTF-8"?>
    <metalink xmlns="urn:ietf:params:xml:ns:metalink">"""

    for e in entries:
        print """<file name="{name}">
    <size>{size}</size>
    <hash type="{hashfunc}">{hashvalue}</hash>
    <url priority="1">{uri}</url>
    </file>""".format(uri=e[0],name=e[1], size=e[2], hashfunc=e[3], hashvalue=e[4])
    print """</metalink>"""

one shell script:

#!/bin/sh -e
apt-get -y --print-uris -qq upgrade|awk '
    BEGIN {
      print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
      print "<metalink xmlns=\"urn:ietf:params:xml:ns:metalink\">"
    }
    { gsub(/\x27/,"",$1);
      split($4, chksum, /:/)
      printf "<file name=\"%s\">",$2
      printf "<size>%d</size>", $3
      printf "<hash type=\"%s\">%s</hash>", chksum[1], chksum[2]
      printf "<url priority=\"1\">%s</url>", $1
      print "</file>"
    }
    END {
      print "</metalink>"
    }'|aria2c -M- --file-allocation=none -d /var/cache/apt/archives/