#!/bin/bash # # Proof of concept Wig & Pen package converter # # Copyright © 2008 Guillem Jover # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # Required: gpg, procmail, perl, patchutils # set -e fdsc=$1 echo "Switching $fdsc to Wig&Pen format..." cp -f $fdsc $fdsc.orig echo " getting rid of gpg signature..." if gpg -d $fdsc >$fdsc.asc 2>/dev/null; then mv $fdsc.asc $fdsc fi echo " extracting information..." dscfiles=`formail -z -xFiles <$fdsc | cut -d' ' -f4` pkgdir=`echo "$dscfiles" | sed -n -e 's:_:-:;s:\.orig\.tar\.gz::p'` fdiff=`echo "$dscfiles" | grep 'diff\.gz$'` fdebian=`echo $fdiff | sed -e 's:diff:debian.tar:'` paths="`zcat $fdiff | lsdiff --strip 1 | grep -v '^debian' || true`" if [ -n "$paths" ]; then echo " diff modifies files outside debian/ dir, bailing out." exit 1 fi echo " extracting sources..." dpkg-source -x $fdsc echo " remove quilt series file..." rm -f $pkgdir/debian/patches/series echo " rename patches to run-parts expected names..." cd $pkgdir rename 's:\.patch$::' debian/patches/* rename 'tr:_\.:-:' debian/patches/* cd .. echo " converting $fdiff to $fdebian..." tar czf $fdebian -C $pkgdir/debian/ . echo " fixing $fdsc to refer to $fdebian..." fdebian_size=`stat -c %s $fdebian` fdebian_md5=`md5sum $fdebian | sed -e "s: : $fdebian_size :"` sed -i -e "s:^.* $fdiff$: $fdebian_md5:" $fdsc echo " fixing $fdsc Format..." sed -i -e 's/^Format: 1\.0/Format: 2.0/' $fdsc echo " cleaning up after conversion..." rm -f "$fdiff" rm -rf "$pkgdir" echo "done."