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

raw Debian package con tar e ar

apt-fast

Makefile:

all: deb

deb:
    mkdir -p tmp/usr/bin tmp/DEBIAN tmp/etc tmp/usr/share/man/man5 tmp/usr/share/man/man8
    find tmp -type d | xargs chmod 755
    cp apt-fast.conf tmp/etc/
    cp man/apt-fast.8 tmp/usr/share/man/man8/
    cp man/apt-fast.conf.5 tmp/usr/share/man/man5/
    cp apt-fast tmp/usr/bin/
    tar c --owner root --group root -v -z -f tmp/data.tar.gz -C tmp ./etc ./usr
    cd tmp && find usr/ etc/ -type f | xargs md5sum >DEBIAN/md5sums
    awk '/^#Package:/{i++}i {print substr($$0,2); }' Makefile >tmp/DEBIAN/control
    tar c --owner root --group root -v -z -f tmp/control.tar.gz -C tmp/DEBIAN ./control ./md5sums
    echo 2.0 >tmp/debian-binary
    ar rcv apt-fast_1.8-1.deb tmp/debian-binary tmp/control.tar.gz tmp/data.tar.gz

.phony: clean
clean:
    -rm -fr tmp

#Package: apt-fast
#Version: 1.8
#Section: net
#Priority: optional
#Architecture: all
#Essential: no
#Installed-size: 100
#Maintainer: Name <mail here>
#Source: https://github.com/ilikenwf/apt-fast
#Depends: aria2
#Description: apt-get wrapper with aria2 as backend downloader
# apt-fast is a shellscript wrapper for apt-get and aptitude
# can drastically improve apt download times
# by downloading packages in parallel
# with multiple connections per package.

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/