dpkg-repack

Posted at 2007-02-07 19.57

I was on a friend’s machine looking to copy some of his software.

$ dpkg-repack <pkg>
bash: dpkg-repack: command not found

So, here’s a hacky and woefully incomplete replacement for dpkg-repack.

#! /bin/sh

set -eu
[ 0 != $(id -u) ] && { echo "Must be run as (fake)root" 1>&2; exit 1; }

pkg=$1; pkgdir=$(mktemp -d "$pkg.XXXXXX")
mkdir "$pkgdir"

dpkg -L $pkg | tar cf - –no-recursion –files-from - | (cd "$pkgdir" && tar xvf -)

install -d -m 755 "$pkgdir/DEBIAN"
dpkg -s "$pkg" |sed '/^Status: /d' > "$pkgdir/DEBIAN/control"

dpkg-deb -b "$pkgdir" .
rm -rf "$pkgdir"

Works For Me ™.

Update: it was pointed out that wordpress had prettified the code, turning pairs of dashes into em-dashes and other atrocities. so I've uploaded the script: [fake-repack]


2 Comments for 'dpkg-repack'

  1.  
    Gerhard
    2007-02-14 | 13.40 +0000
     

    dpkg -L $pkg | tar cf - –no-recursion –files-from - | (cd "$pkgdir" && tar xvf -)

    I would use cpio instead:

    dpkg -L "$pkg" | cpio -vmdp "$pkgdir"

  2.  
    ads
    2007-02-14 | 14.59 +0000
     

    Mm, thanks. cpio is something I avoided learning because I didn't see any value in it at first glance. I'll reappraise this.

Leave a comment

(required)

(required)


Information for comment users
Line and paragraph breaks are implemented automatically. Your e-mail address is never displayed. Please consider what you're posting.

Use the buttons below to customise your comment.


RSS feed for comments on this post | TrackBack URI

 
ok