]> piware.de Git - bin.git/commitdiff
initial checkin
authormartin@piware.de <>
Mon, 4 Sep 2006 07:26:19 +0000 (09:26 +0200)
committermartin@piware.de <>
Mon, 4 Sep 2006 07:26:19 +0000 (09:26 +0200)
21 files changed:
amberfiles [new file with mode: 0755]
burnmusiccd [new file with mode: 0755]
bzrcc [new file with mode: 0755]
bzrdc [new file with mode: 0755]
checkrdepends [new file with mode: 0755]
cleanpg [new file with mode: 0755]
dsrc-new-patch [new file with mode: 0755]
dvdmrip [new file with mode: 0755]
dvdrip [new file with mode: 0755]
mirror-orphans [new file with mode: 0755]
pdfselect [new file with mode: 0755]
requestsponsor [new file with mode: 0755]
requestsync [new file with mode: 0755]
rmtex [new file with mode: 0755]
svndc [new file with mode: 0755]
syncpackage [new file with mode: 0755]
trechnung [new file with mode: 0755]
ubuntu-mirror [new file with mode: 0755]
update-chroots [new file with mode: 0755]
uup [new file with mode: 0755]
vcard2gnokii [new file with mode: 0755]

diff --git a/amberfiles b/amberfiles
new file mode 100755 (executable)
index 0000000..82ebd87
--- /dev/null
@@ -0,0 +1,49 @@
+#!/usr/bin/python
+
+import sys, os, os.path, md5
+
+mirror = "http://security.ubuntu.com/ubuntu/"
+
+if len(sys.argv) < 2:
+    print "Usage:", sys.argv[0], "<directory> [<version>]"
+    sys.exit(1)
+
+# arch -> name -> (size,md5)
+files = {}
+
+if len(sys.argv) > 2:
+    version = sys.argv[2]
+else:
+    version = None
+
+for f in os.listdir(sys.argv[1]):
+    if version and f.find(version) < 0:
+        continue
+
+    path=os.path.join(sys.argv[1], f)
+    if os.path.isfile(path):
+        m = md5.new()
+        m.update(open(path, "r").read())
+        data = (os.path.getsize(path), m.hexdigest())
+
+        if f.find("i386.deb") > 0:
+            files.setdefault("i386 architecture (x86 compatible Intel/AMD)", {})[path] = data
+        elif f.find("powerpc.deb") > 0:
+            files.setdefault("powerpc architecture (Apple Macintosh G3/G4/G5)", {})[path] = data
+        elif f.find("amd64.deb") > 0:
+            files.setdefault("amd64 architecture (Athlon64, Opteron, EM64T Xeon)", {})[path] = data
+        elif f.find("all.deb") > 0:
+            files.setdefault("Architecture independent packages:", {})[path] = data
+        elif (f.find("tar.gz") > 0) or (f.find("diff.gz") > 0) or (f.find(".dsc") > 0):
+            files.setdefault("Source archives:", {})[path] = data
+        else:
+            print >> sys.stderr, "Ignoring unknown file", path
+
+for arch, filemap in files.iteritems():
+    print " ", arch
+    print
+    for name, (size, md5) in files[arch].iteritems():
+        print "   ", mirror + name
+        print "      Size/MD5: ", size, md5
+
+    print
diff --git a/burnmusiccd b/burnmusiccd
new file mode 100755 (executable)
index 0000000..dc3d3f7
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+DEVICE=/dev/cdroms/cdrom1
+SPEED=4
+CDREC="cdrecord dev=$DEVICE fs=8m speed=$SPEED -v -nofix -pad -audio -"
+
+for i in *.mp3 *.ogg; do
+    if test "`file "$i" | grep -i vorbis`"; then
+       oggdec -R 1 -o - "$i" | $CDREC
+    else
+       mpg123 --cdr - "$i" | $CDREC
+    fi
+done
+
+cdrecord dev=$DEVICE speed=$SPEED -v -fix
diff --git a/bzrcc b/bzrcc
new file mode 100755 (executable)
index 0000000..42b80a2
--- /dev/null
+++ b/bzrcc
@@ -0,0 +1,30 @@
+#!/bin/bash -e
+LOG=`bzr diff ChangeLog| sed -rne '/^\+([[:blank:]]|\-){1,}/{s/^\+[[:blank:]]*//; p}'`
+
+[ -n "$LOG" ] || {
+    echo 'no ChangeLog change'
+    exit 1
+}
+
+echo -- Log --
+echo "$LOG"
+echo ---------
+
+while read -p "Ok to commit? (Y/n) " -n 1 WHAT; do
+       case "$WHAT" in
+       y|Y|"")
+               break
+               echo "YES"
+               ;;
+       n|N)
+               echo
+               echo "Aborting."
+               exit 0
+               ;;
+       *)
+               echo " -- unknown response."
+               ;;
+       esac
+done
+
+bzr commit -m "$LOG" "$@"
diff --git a/bzrdc b/bzrdc
new file mode 100755 (executable)
index 0000000..7c189a1
--- /dev/null
+++ b/bzrdc
@@ -0,0 +1,30 @@
+#!/bin/bash -e
+LOG=`bzr diff debian/changelog| sed -rne '/^\+[[:blank:]]{2,}/{s/^\+  //; p}'`
+
+[ -n "$LOG" ] || {
+    echo 'no debian/changelog change'
+    exit 1
+}
+
+echo -- Log --
+echo "$LOG"
+echo ---------
+
+while read -p "Ok to commit? (Y/n) " -n 1 WHAT; do
+       case "$WHAT" in
+       y|Y|"")
+               break
+               echo "YES"
+               ;;
+       n|N)
+               echo
+               echo "Aborting."
+               exit 0
+               ;;
+       *)
+               echo " -- unknown response."
+               ;;
+       esac
+done
+
+bzr commit -m "$LOG" "$@"
diff --git a/checkrdepends b/checkrdepends
new file mode 100755 (executable)
index 0000000..4f5afe8
--- /dev/null
@@ -0,0 +1,63 @@
+#!/bin/sh -e
+
+BINARYONLY=false
+if [ "$1" = "-b" ]; then
+    BINARYONLY=:
+    shift
+fi
+
+pkg="$1"
+rel="$2"
+
+[ -n "$pkg" -a -n "$rel" ] || {
+    echo "Usage: $0 {-b <binary package>|<source package>} <release>"
+    exit 1
+}
+
+T=`mktemp -d`
+trap "rm -rf $T" 0 1 2 3 4 5 6 7 8 10 11 12 13 15
+
+for pocket in '' -updates -security -backports; do
+    # get source/package lists
+    for comp in main restricted universe multiverse; do
+        wget -q -O - http://archive.ubuntu.com/ubuntu/dists/$rel$pocket/$comp/source/Sources.gz | gunzip > "$T/$rel${pocket}_${comp}_Sources"
+    done
+
+    # get lists of debs
+    if $BINARYONLY; then
+        debs="$pkg"
+    else
+        debs=`grep-dctrl -sBinary -n -X -P $pkg $T/*_Sources`|| {
+            echo Unknown source package $pkg
+            exit 1
+        }
+        debs=`echo "$debs" | sed 's/,//g'`
+    fi
+
+    for comp in main restricted universe multiverse; do
+        for deb in $debs; do
+            # build dependencies
+            if d=`grep-dctrl -e -n -sPackage -FBuild-Depends "(,| |^)$(echo "$deb" | sed 's/+/\\\\+/g')(,| |$|\()" $T/$rel${pocket}_${comp}_Sources`; then
+                echo "-- $rel$pocket/$comp build deps on $deb:"
+                echo "$d"
+            fi
+
+            # binary dependencies
+            for arch in amd64 i386 powerpc; do
+                if d=`wget -q -O - http://archive.ubuntu.com/ubuntu/dists/$rel$pocket/$comp/binary-$arch/Packages.gz | gunzip \
+                    | grep-dctrl -e -n -sPackage -FDepends "(,| |^)$(echo "$deb" | sed 's/+/\\\\+/g')(,| |$|\()"`; then  
+                    echo "-- $rel$pocket/$comp $arch deps on $deb:"
+                    echo "$d"
+                fi
+            done
+            for arch in hppa ia64 sparc; do
+                if d=`wget -q -O - http://ports.ubuntu.com/ubuntu-ports/dists/$rel$pocket/$comp/binary-$arch/Packages.gz | gunzip \
+                    | grep-dctrl -e -n -sPackage -FDepends "(,| |^)$(echo "$deb" | sed 's/+/\\\\+/g')(,| |$|\()"`; then  
+                    echo "-- $rel$pocket/$comp $arch deps on $deb:"
+                    echo "$d"
+                fi
+            done
+        done
+    done
+done
+
diff --git a/cleanpg b/cleanpg
new file mode 100755 (executable)
index 0000000..7257136
--- /dev/null
+++ b/cleanpg
@@ -0,0 +1,6 @@
+#!/bin/sh
+sudo /etc/init.d/postgresql-7.4 stop
+sudo /etc/init.d/postgresql-8.0 stop
+sudo /etc/init.d/postgresql-8.1 stop
+sudo killall pg_autovacuum postmaster
+sudo rm -rf /etc/postgresql /var/lib/postgresql/ /var/log/postgresql/ /tmp/postgresql-testsuite/ /var/run/postgresql/*
diff --git a/dsrc-new-patch b/dsrc-new-patch
new file mode 100755 (executable)
index 0000000..8b26f68
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/sh -e
+
+[ -n "$1" ]
+[ -e debian/rules ]
+[ -d debian/patches ]
+[ ! -e debian/patches/$1 ]
+
+CWD=`pwd`
+D=`mktemp -d`
+trap "rm -rf $D" 0 1 2 3 4 5 6 7 8 10 11 12 13 14 15
+
+debclean
+cp -r . $D/orig
+cd $D/orig
+debian/rules setup || debian/rules patch || debian/rules apply-patches || debian/rules apply-dpatches || debian/rules unpack || debian/rules patch-stamp
+[ -z "`find -name '*.rej'`" ] || {
+    echo 'there are rejections from the current patches, aborting' >&2
+    exit 1
+}
+find -name '*.orig' | xargs rm || true
+cd ..
+cp -a orig new
+cd new
+echo 'make your modifications in this shell and exit it successfully'
+bash
+find -name '*.orig' | xargs rm || true
+cd ..
+diff -Nurp orig new > "$CWD/debian/patches/$1"
diff --git a/dvdmrip b/dvdmrip
new file mode 100755 (executable)
index 0000000..c802947
--- /dev/null
+++ b/dvdmrip
@@ -0,0 +1,9 @@
+#!/bin/bash -e
+
+track=1
+
+while [ -n "$1" ]; do
+    nice dvdrip $track "$1.avi"
+    ((track=track+1))
+    shift
+done
diff --git a/dvdrip b/dvdrip
new file mode 100755 (executable)
index 0000000..07bab42
--- /dev/null
+++ b/dvdrip
@@ -0,0 +1,8 @@
+#!/bin/sh -e
+
+[ -n "$1" -a -n "$2" ] || {
+    echo "Usage: $0 <title no> <output file>" >&2
+    exit 1
+}
+
+exec mencoder dvd://$1 -alang en -vf scale -zoom -xy 540 -o "$2" -srate 44100 -oac lavc -ovc lavc -lavcopts vcodec=mpeg4:mbd=1:vbitrate=950:abitrate=112 -af lavcresample=44100,volnorm
diff --git a/mirror-orphans b/mirror-orphans
new file mode 100755 (executable)
index 0000000..a44ba89
--- /dev/null
@@ -0,0 +1,83 @@
+#!/usr/bin/python
+
+import os, os.path, gzip, sys
+
+mirrordir = '/mirror'
+
+def get_package_versions_file(f, map):
+    currpkg = None
+    currversion = None
+
+    for line in gzip.open(f):
+        line = line.strip()
+        if not line:
+            if (not currpkg) or (not currversion):
+                print >> sys.stderr, "Error: end of package record without all data available"
+                sys.exit(1)
+            map.setdefault(currpkg, []).append(currversion)
+            currpkg = None
+            currversion = None
+            continue
+
+        attr = line.split(":", 1)
+
+        if len(attr) < 2:
+            continue
+
+        if attr[0] == "Package":
+            if currpkg:
+                print >> sys.stderr, "Error: read two Packages: lines in a row"
+                sys.exit(1)
+            currpkg = attr[1].strip()
+
+        if attr[0] == "Version":
+            if currversion:
+                print >> sys.stderr, "Error: read two Version: lines in a row"
+                sys.exit(1)
+            currversion = attr[1].strip()
+            # remove epochs
+            colpos = currversion.find(':')
+            if colpos >= 0:
+                currversion = currversion[colpos+1:]
+
+def get_package_versions_tree(rootdir):
+    """Generate a archive map from a Debian-style package archive directory.
+
+    rootdir: path to archive root path
+    return: mapping: sourcepackage -> [versions]
+    """
+
+    map = {}
+
+    for release in os.listdir(rootdir + "/dists"):
+        for comp in os.listdir(rootdir + "/dists/" + release):
+            compdir = rootdir + "/dists/" + release + "/" + comp
+            if not os.path.isdir(compdir):
+                continue
+            get_package_versions_file(compdir + "/source/Sources.gz", map)
+            for arch in os.listdir(compdir):
+                if arch.startswith('binary-'):
+                    get_package_versions_file(compdir + '/' + arch + '/Packages.gz', map)
+
+    return map
+
+known_versions = get_package_versions_tree(mirrordir)
+
+for path, dirs, files in os.walk(os.path.join(mirrordir, 'pool')):
+    for f in files:
+        (pkg, version) = (f.split('_'))[0:2]
+        if f.endswith('.deb'):
+            pass
+        elif f.endswith('.dsc'):
+            version = version[:-4]
+        elif f.endswith('.diff.gz'):
+            version = version[:-8]
+        elif f.endswith('.tar.gz'):
+            continue
+        else:
+            print os.path.join(path, f)
+            continue
+
+        if not version in known_versions.get(pkg, ()):
+            print os.path.join(path, f)
+
diff --git a/pdfselect b/pdfselect
new file mode 100755 (executable)
index 0000000..4d8c8d1
--- /dev/null
+++ b/pdfselect
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+[ "$1" -a "$2" -a "$3" ] || {
+    echo "Usage: pdfselect <range> inputfile outputfile"
+    exit 0
+}
+
+texexec --pdfselect --selection="$1" --output=pdftex "$2" && mv texexec.pdf "$3"
+rm -f texexec.*
diff --git a/requestsponsor b/requestsponsor
new file mode 100755 (executable)
index 0000000..e19cbe1
--- /dev/null
@@ -0,0 +1,82 @@
+#!/usr/bin/python
+
+import os, sys, subprocess, smtplib, re
+
+#
+# entry point
+#
+
+if len(sys.argv) > 2 or len(sys.argv) == 1 and sys.stdin.isatty():
+    print '''Usage: requestsponsor [<debdiff>]
+
+File a sponsoring request bug with the given debdiff. If a debdiff is not
+specified as command line argument, it reads stdin.'''
+    sys.exit (1)
+
+if len(sys.argv) == 1:
+    # read stdin
+    diff = sys.stdin.read()
+else:
+    diff = open(sys.argv[1]).read()
+
+# parse diff for source package name
+changelog_header_re = re.compile('^\+([\w.-]+) \([\w.:+-]+\) ([\w-]+); urgency')
+in_changelog = False
+package = None
+release = None
+for l in diff.splitlines():
+    if l.startswith('+++ '):
+       in_changelog = l.endswith('/debian/changelog')
+    if in_changelog:
+       m = changelog_header_re.match(l)
+       if m:
+           package = m.group(1)
+           release = m.group(2)
+           break
+
+assert package
+assert release
+
+# strip pocket from  release
+release = release.split('-')[0]
+
+# determine team (main/universe)
+if subprocess.call('apt-cache madison %s | \
+    egrep -q "%s/(main|restricted).*Sources"' % (package, release), shell=True) == 0:
+    team = 'ubuntu-main-sponsors'
+else:
+    team = 'ubuntu-universe-sponsors'
+
+print 'Filing bug against package', package, 'to team', team
+
+# generate bug report
+mailbody = ''' affects distros/ubuntu/%s
+ subscribe %s
+
+%s
+''' % (package, team, diff)
+
+# sign it
+sign_command = 'gpg'
+if os.access('/usr/bin/gnome-gpg', os.X_OK):
+    sign_command = 'gnome-gpg'
+
+gpg = subprocess.Popen([sign_command, '--clearsign'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+signed_mailbody = gpg.communicate(mailbody)[0]
+assert gpg.returncode == 0
+
+# generate email
+myemailaddr = os.getenv('DEBEMAIL')
+assert myemailaddr
+to = 'new@bugs.launchpad.net'
+
+mail = '''From: %s
+To: %s
+Subject: Please sponsor %s upload
+
+%s''' % (myemailaddr, to, package, signed_mailbody)
+
+s = smtplib.SMTP()
+s.connect()
+s.sendmail(myemailaddr, to, mail)
+s.close()
diff --git a/requestsync b/requestsync
new file mode 100755 (executable)
index 0000000..2c48f3b
--- /dev/null
@@ -0,0 +1,100 @@
+#!/usr/bin/python
+
+import os, os.path, sys, urllib, subprocess, smtplib
+
+changelog = 1
+
+def cur_version_component(sourcepkg, release):
+    madison = subprocess.Popen(['apt-cache', 'madison', sourcepkg], stdout=subprocess.PIPE)
+    out = madison.communicate()[0]
+    assert (madison.returncode == 0)
+
+    for l in out.splitlines():
+       (pkg, version, aptsrc) = l.split('|')
+       if aptsrc.endswith('Sources') and aptsrc.find(release) > 0:
+           component = ''
+           for w in aptsrc.split():
+               if w.startswith(release):
+                   component = w.split('/')[1]
+           assert component != ''
+           return (version.strip(), component)
+
+    raise Exception('apt-cache madison does not contain %s/%s' % (sourcepkg, release))
+
+def debian_changelog(sourcepkg, version):
+    '''Return the Debian changelog from the latest up to the given version
+    (exclusive).'''
+
+    ch = ''
+    for l in urllib.urlopen('http://changelogs.debian.net/' + sourcepkg):
+       if l.startswith(sourcepkg) and l.find(version + ')') > 0:
+           break
+       ch += l
+
+    return ch
+
+#
+# entry point
+#
+
+if len(sys.argv) != 3:
+    print 'Usage: requestsync <source package> <target release>'
+    sys.exit (1)
+
+(srcpkg, release) = sys.argv[1:]
+(cur_ver, component) = cur_version_component(srcpkg, release)
+
+
+# generate bug report
+report = ''
+
+report += ''' affects distros/ubuntu/%s
+ status confirmed
+ subscribe ubuntu-archive
+
+''' % srcpkg
+
+report += 'Please sync %s (%s) from Debian unstable.\n' % (srcpkg, component)
+
+base_ver = cur_ver
+uidx = base_ver.find('ubuntu')
+if uidx > 0:
+    base_ver = base_ver[:uidx]
+    report += '\nOverriding Ubuntu changes is ok.\n'
+
+if changelog:
+    uidx = base_ver.find('build')
+    if uidx > 0:
+       base_ver = base_ver[:uidx]
+
+    report += '\nChangelog since current %s version %s:\n\n' % (release, cur_ver)
+    report += debian_changelog(srcpkg, base_ver) + '\n'
+
+# sign it
+sign_command = 'gpg'
+if os.access('/usr/bin/gnome-gpg', os.X_OK):
+    sign_command = 'gnome-gpg'
+
+gpg = subprocess.Popen([sign_command, '--clearsign'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+signed_report = gpg.communicate(report)[0]
+assert gpg.returncode == 0
+
+# generate email
+myemailaddr = os.getenv('DEBEMAIL')
+assert myemailaddr
+to = 'new@bugs.launchpad.net'
+
+mail = '''From: %s
+To: %s
+Subject: Please sync %s (%s) from unstable
+
+%s''' % (myemailaddr, to, srcpkg, component, signed_report)
+
+print mail
+print 'Press enter to file this bug, Control-C to abort'
+sys.stdin.readline()
+
+s = smtplib.SMTP()
+s.connect()
+s.sendmail(myemailaddr, to, mail)
+s.close()
diff --git a/rmtex b/rmtex
new file mode 100755 (executable)
index 0000000..173eaed
--- /dev/null
+++ b/rmtex
@@ -0,0 +1,4 @@
+#!/bin/bash
+find  . \( -name '*.aux' -o -name '*.dvi' -o -name '*.log' -o -name '*.toc' -o -name '*~' -o -name '*.xyc' -o -name '*.lof' -o -name '*.lot' -o -name '*.out' -o -name '*.bbl' -o -name '*.blg' -o -name '*.nav' -o -name '*.snm' \) -exec rm '{}' ';'
+for i in `find . -name '*.pdf'`; do [ -f ${i%.pdf}.tex ] && rm $i; done
+for i in `find . -name '*.ps'`; do [ -f  ${i%.ps}.tex ] && rm $i; done
diff --git a/svndc b/svndc
new file mode 100755 (executable)
index 0000000..a529fa8
--- /dev/null
+++ b/svndc
@@ -0,0 +1,30 @@
+#!/bin/bash -e
+LOG=`svn diff debian/changelog| sed -rne '/^\+[[:blank:]]{2,}/{s/^\+  //; p}'`
+
+[ -n "$LOG" ] || {
+    echo 'no debian/changelog change'
+    exit 1
+}
+
+echo -- Log --
+echo "$LOG"
+echo ---------
+
+while read -p "Ok to commit? (Y/n) " -n 1 WHAT; do
+       case "$WHAT" in
+       y|Y|"")
+               break
+               echo "YES"
+               ;;
+       n|N)
+               echo
+               echo "Aborting."
+               exit 0
+               ;;
+       *)
+               echo " -- unknown response."
+               ;;
+       esac
+done
+
+svn commit -m "$LOG" "$@"
diff --git a/syncpackage b/syncpackage
new file mode 100755 (executable)
index 0000000..4f645e3
--- /dev/null
@@ -0,0 +1,101 @@
+#!/usr/bin/python
+
+import os, os.path, sys, urllib, subprocess, shutil
+
+def retrieve_file(url):
+    '''Download file (by URL)  to the current directory.
+
+    If the file is already present, this function does nothing.'''
+
+    fname = os.path.basename(url)
+    if not os.path.exists(fname):
+       print 'downloading', url
+       urllib.urlretrieve(url, fname)
+
+def cur_version(sourcepkg, release):
+    madison = subprocess.Popen(['apt-cache', 'madison', sourcepkg], stdout=subprocess.PIPE)
+    out = madison.communicate()[0]
+    assert (madison.returncode == 0)
+
+    for l in out.splitlines():
+       (pkg, version, aptsrc) = l.split('|')
+       if aptsrc.endswith('Sources') and aptsrc.find(release) > 0:
+           return version.strip()
+
+    raise Exception('apt-cache madison does not contain %s/%s' % (sourcepkg, release))
+
+def dsc_getfiles(dsc):
+    '''Return list of files in a .dsc file (excluding the .dsc file itself).'''
+
+    f = open(dsc)
+    files = []
+
+    # skip until 'Files:'
+    for l in f:
+       if l.strip() == 'Files:':
+           break
+
+    for l in f:
+       if l.strip() == '':
+           break
+       fname = l.split()[2]
+       if not fname.endswith('.dsc'):
+           files.append(fname)
+
+    f.close()
+    return files
+
+#
+# entry point
+#
+
+if len(sys.argv) != 3:
+    print 'Usage: syncpackage <.dsc URL or path> <target release>'
+    sys.exit (1)
+
+(dscurl, release) = sys.argv[1:]
+dscname = os.path.basename(dscurl)
+basepath = os.path.dirname(dscurl)
+(srcpkg, new_ver) = dscname.split('_')
+new_ver = new_ver[:-4] # strip off '.dsc'
+
+cur_ver = cur_version(srcpkg, release)
+
+retrieve_file(dscurl)
+files = dsc_getfiles(dscname)
+
+# do we need the orig.tar.gz?
+need_orig = True
+if cur_ver.find('-') > 0 and new_ver.find('-') > 0 and \
+    cur_ver.split('-')[0] == new_ver.split('-')[0]:
+    need_orig = False
+    #files = [f for f in files if not f.endswith('orig.tar.gz')]
+
+print 'Source %s: current version %s, new version %s' % (srcpkg, cur_ver, new_ver)
+print 'needs orig.tar.gz', need_orig
+print 'Files:', files
+for f in files:
+    retrieve_file(os.path.join(basepath, f))
+
+uidx = cur_ver.find('ubuntu')
+if uidx > 0:
+    cur_ver = cur_ver[:uidx]
+    print 'WARNING! Overwriting modified Ubuntu version, setting current version to', cur_ver
+
+uidx = cur_ver.find('build')
+if uidx > 0:
+    cur_ver = cur_ver[:uidx]
+
+orig_arg = ''
+if need_orig:
+    orig_arg = '-sa'
+
+# extract package, build Source
+assert subprocess.call(['dpkg-source', '-x', dscname]) == 0
+os.chdir(srcpkg + '-' + new_ver.split('-')[0])
+assert subprocess.call("dpkg-genchanges -q -S %s -v%s -e\"$(getent passwd $(id -u)|cut -f5 -d:|cut -f1 -d,) <$DEBEMAIL>\" | \
+       sed 's/^Distribution:.*$/Distribution: %s/; 1 i\Origin: debian/unstable' > ../%s_%s_source.changes" % 
+       (orig_arg, cur_ver, release, srcpkg, new_ver), shell=True) == 0
+os.chdir('..')
+shutil.rmtree(srcpkg + '-' + new_ver.split('-')[0], True)
+assert subprocess.call("debsign %s_%s_source.changes" % (srcpkg, new_ver), shell=True) == 0
diff --git a/trechnung b/trechnung
new file mode 100755 (executable)
index 0000000..bd120e9
--- /dev/null
+++ b/trechnung
@@ -0,0 +1,121 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+import os, re, subprocess, sys
+
+def search_substr(f, str):
+    for l in f:
+        if l.find(str) >= 0:
+            return l
+
+    return None
+
+def get_price(str):
+    money_re = re.compile('^-?\d+,\d\d$')
+    fields = str.split()
+    fields.reverse()
+    for f in fields:
+        if money_re.match(f):
+            return float(f.replace(',', '.'))
+
+def next_price(f, str):
+    p = search_substr(f, str)
+    if p:
+        price = get_price(p)
+        print 'next_price(%s) -> line "%s" -> %.2f' % (str, p.strip(), price)
+        return price
+    return None
+
+def print_price(p):
+    ks = p.keys()
+    ks.sort()
+    for k in ks:
+        print '%-30s: %10.2f €' % (k, p[k])
+
+if len(sys.argv) != 2:
+    print 'Usage:', sys.argv[0], '<PDF file>'
+    sys.exit(-1)
+
+pdfpath = sys.argv[1]
+txtpath = pdfpath[:-3] + 'txt'
+
+# create text file
+assert subprocess.call(['pdftotext', '-enc', 'UTF-8', '-layout', '-nopgbrk', pdfpath]) == 0
+
+try:
+    f = open(txtpath)
+finally:
+    os.unlink(txtpath) # so that we don't forget later
+
+price = {}
+  
+common = next_price(f, 'Monatliche Beträge')
+#other = next_price(f, 'Sonstige Leistungen des Konzerns')
+#if other:
+#    common = common + other
+bill_vat = next_price(f, 'Umsatzsteuer 16 %')
+bill_gross = next_price(f, 'Rechnungsbetrag')
+
+bill_item_re = re.compile('^\s*\d+\.\s*.*16')
+
+# Telekom
+assert search_substr(f, 'Summe Monatliche Beträge')
+assert search_substr(f, ':::::::::::::')
+for l in f:
+    if l.find('::::::::::::') >= 0:
+        break
+
+    if bill_item_re.match(l):
+        assert cur_number
+        p = get_price(l)
+        price[cur_number] = price.setdefault(cur_number, 0) + p
+        print 'adding %.2f to %s for "%s"' % (p, cur_number, l.strip())
+    if l.find('Summe Verbindungen für oben angegebene Rufnummer') >= 0:
+        cur_number = None
+    if l.find('Rufnummer (') >= 0:
+        cur_number = l.strip()
+        print l.strip(), ' -> switching to', cur_number
+
+# other companies
+if search_substr(f, 'Beträge anderer Anbieter'):
+    for l in f:
+        if l.find('Summe Beträge anderer Anbieter') >= 0:
+            break
+        if bill_item_re.match(l):
+            assert cur_number
+            p = get_price(l)
+            print 'adding %.2f to %s for "%s"' % (p, cur_number, l.strip())
+            price[cur_number] = price.setdefault(cur_number, 0) + p
+        if l.find('Rufnummer (') >= 0:
+            cur_number = l.strip()
+            print l.strip(), ' -> switching to', cur_number
+
+print '----------------------------------------'
+print 'Summen:'
+print_price(price)
+print 'Allgemeine Gebühren: %.2f' % common
+
+common = common / len(price)
+sum = 0
+for k, v in price.iteritems():
+    price[k] = v + common
+    sum = sum + price[k]
+
+print '----------------------------------------'
+print 'Verrechnung allgemeine Gebühren (Aufschlag für jeden: %.2f)' % common
+print_price(price)
+
+vat = sum * 0.16
+gross = sum + vat
+
+for k, v in price.iteritems():
+    price[k] *= 1.16
+
+print '----------------------------------------'
+print 'Aufschlag Mehrwertsteuer:'
+print_price(price)
+
+print '----------------------------------------'
+print 'Berechnete MwST: %.3f, Rechnungs-MwSt: %.2f' % (vat, bill_vat)
+print 'Berechnete Bruttosume: %.3f, Rechnungs-Bruttosumme: %.2f' % (gross, bill_gross)
+
diff --git a/ubuntu-mirror b/ubuntu-mirror
new file mode 100755 (executable)
index 0000000..e107dd7
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/sh -e
+debmirror --dist hoary,hoary-updates,hoary-security,breezy,breezy-updates,breezy-security,dapper,dapper-updates,dapper-security --section main,restricted --arch none --source --progress --nocleanup --method http --ignore-release-gpg --host archive.ubuntu.com --exclude-deb-section translation --exclude 'openoffice.*amd.*tar.gz' --exclude 'ia32-libs*' --root ubuntu /mirror
+
+#debmirror --dist dapper --section main,restricted --arch i386 --no-source --progress --nocleanup --method http --ignore-release-gpg --host archive.ubuntu.com --exclude-deb-section translation --root ubuntu /mirror
+debmirror --dist breezy,breezy-updates,breezy-security,dapper,dapper-updates,dapper-security --section main,restricted --arch amd64 --no-source --progress --nocleanup --method http --ignore-release-gpg --host archive.ubuntu.com --exclude-deb-section translation --exclude 'linux-(image|headers|source|patch|doc).*\.deb' --exclude 'ia32-libs*' --root ubuntu /mirror
+
+ORPHANS=`mirror-orphans`
+if [ -n "$ORPHANS" ]; then
+    echo ----------------------
+    echo Orphans:
+    /bin/echo -e "$ORPHANS"
+    read -p 'ok to remove? [y/N] ' a
+    if [ "$a" = y ]; then
+        rm -f $ORPHANS
+    fi
+fi
diff --git a/update-chroots b/update-chroots
new file mode 100755 (executable)
index 0000000..5c20ecb
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+dchroot -a -- 'apt-get update'
+dchroot -d -c breezy -- 'apt-get -u -y dist-upgrade'
+dchroot -d -c dapper -- 'apt-get -u -y dist-upgrade'
diff --git a/uup b/uup
new file mode 100755 (executable)
index 0000000..1fca44a
--- /dev/null
+++ b/uup
@@ -0,0 +1,47 @@
+#!/bin/bash -e
+
+LOGIN=pitti
+HOST=chinstrap.ubuntu.com
+
+if [ -z "$1" ]; then
+    echo "Usage: $0 <changes file>"
+    exit 0
+fi
+
+# open changes file
+exec 3<$1
+
+# read until Files: section
+while true; do
+    read -u 3 line
+    if [ "$line" = "Files:" ]; then
+       break
+    fi
+done
+
+# read files
+count=0
+while true; do
+    read -u 3 md5sum size section priority fname
+    if [ -z "$fname" ]; then break; fi
+    files[$count]="$fname"
+    ((count=count+1))
+done
+
+if [ $count = 0 ]; then
+    echo "No files found. Exiting."
+    exit -1
+fi
+
+echo "Uploading files to $HOST..."
+echo ${files[*]} $1
+scp ${files[*]} $1 $LOGIN@$HOST:
+
+if grep -q '^Distribution:.*security' "$1"; then
+    QUEUE=security
+else
+    QUEUE=ubuntu
+fi
+
+echo "dput'ing to queue $QUEUE..."
+ssh $LOGIN@$HOST "dput -u $QUEUE $1 && rm ${files[*]} $1"
diff --git a/vcard2gnokii b/vcard2gnokii
new file mode 100755 (executable)
index 0000000..9b40a87
--- /dev/null
@@ -0,0 +1,58 @@
+#!/usr/bin/python
+
+import sys
+
+def output_info(info):
+    if info.has_key('X-EVOLUTION-FILE-AS'):
+       result = info['X-EVOLUTION-FILE-AS']
+    elif info.has_key('N'):
+       name_comp = info['N'].split(';')
+       result = '%s\, %' % (name_comp[0], ' '.join([c for c in name_comp[1:] if c]))
+    else:
+       print >> sys.stderr, 'No suitable name for', info
+       return
+
+    result += ';;ME;;5'
+
+    for k, v in info.iteritems():
+       kf = k.split(';')
+       type = 0
+       if len(kf) > 1:
+           if kf[1] == 'TYPE=HOME':
+               type = 2
+           elif kf[1] == 'TYPE=CELL':
+               type = 3
+           elif kf[1] == 'TYPE=WORK':
+               type = 6
+
+       if kf[0] == 'ADR':
+           result += ';9;%i;9;%s' % (type, '\\n'.join([f for f in v.split(';') if f]))
+       if kf[0] == 'EMAIL':
+           result += ';8;%i;8;%s' % (type, v)
+       if kf[0] == 'TEL':
+           result += ';11;%i;11;%s' % (type, v)
+       if kf[0] == 'BDAY':
+           result += ';10;0;10;BDAY: ' + v
+
+    print result
+
+info = {}
+for line in open(sys.argv[1]):
+    if not line or line[0] == ' ':
+       continue
+    line = line.strip()
+    if not line:
+       continue
+    try:
+       (key, value) = line.split(':', 1)
+    except ValueError:
+       print >> sys.stderr, 'ignoring invalid line:', line
+       continue
+    value = value.strip()
+    if value == 'VCARD':
+       if key == 'BEGIN':
+           info = {}
+       elif key == 'END':
+           output_info(info)
+    if value:
+       info[key] = value.strip()