-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 On 2011-05-13 11:19, Niels Thykier wrote: > On 2011-05-13 00:06, Colin Watson wrote: >> [...] > > I had a short chat with Raphaël Hertzog (buxy) in #debian-qa about this > and he said that the unpacking part of the module was rather stable and > "it's certainly ok as a fallback when dpkg-source is not there". > > So as long as we only need dpkg-source -x (and not dpkg-source -b) we > can use libdpkg-perl. > > ~Niels > > [...] > Functional proof-of-concept patch; simply apply and profit! The code is stolen from dpkg-source and cooked down a bit (... a lot). The patch here disables dpkg-source unpacking all together (saves you from peeling out dpkg-dev from a system). The patch does not account for updating the Lintian Depends; I suspect that dpkg-dev should be replaced with bzip2, xz-utils and libdpkg-perl. The former two can be most likely be left out if you know there are no bz2 / xz / lmza sources. I had to redirect STDOUT of unpacked to keeping it the unpack process quiet (otherwise it would break the output format of Lintian)[1]. ~Niels [1] Technically there was an API to do it from within libdpkg-perl, but it was not declared stable, so I went with a redirect instead. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQIcBAEBCAAGBQJNzsDxAAoJEAVLu599gGRCb6UP/1Vzcdf5ddiyNNVEm+fe2PA8 5trbrJj5CgaCc4+MrmxLxZcHuazaX6A7mpWQ0NokxzGy2r8MmRztv7QQ/GY14m+1 bidbsHIRixwLeHeHB8TDVs1G2aSNke+kWkCP6r8fex7uXi7L8njIiy6epntb9f4a s70DFwNg0kzXLzrbLah3Cxo/6TNTqXXUEHI8d2mXWVLFeICvJW+wNI2pqjk25Qsg DpZTmZ3HS719Y66Ta3aVky8KBjGPRQUrqA9bxDu9A95yYgnm7xrSmwOoK6ucpCci sS1um+lFLOJ95hnpiQJ0BhuplloK+64ja+Lgo01F8N1bg9eKv6vi6421zLBXjJDq Y2ShnedHnkMn0YURYFEipbs80Fn68jlq8MjaltNiUmYIldiSt74H+IrUXvBRm4ox BcD+QdwWgl7PUpYi4uYqqkAqp+IXXhJteYrsQM5ZkmIWgVwTmSFrqSr9xJD0ucTr PSEkXycnfwaDUd6ft57ecrzuN25qpL6mPUch6f1HG8MnB2BXwNqTfVCz9Tau4/Nj 3+9EXFoVuD5axdMSaOQcLRumLIhTDri+B23bTpngUMDFnfj+2mKvvtf3af/+SQuU wUAhnBH37sPDErjKnnGhpV4BBHF3spdHjL/8Mv869wlc4XN2ViyigBO2LGuNKcah XhBsmp6qiIQ1RjnUNSeV =HXyf -----END PGP SIGNATURE-----
>From 5e17cad62d101b6795c7230a7b257201d489787b Mon Sep 17 00:00:00 2001
From: Niels Thykier <niels@thykier.net>
Date: Sat, 14 May 2011 19:37:26 +0200
Subject: [PATCH] Sample patch to unpack using libdpkg-perl instead
dpkg-source
---
collection/unpacked | 36 ++++++++++++++++++++++++++++--------
1 files changed, 28 insertions(+), 8 deletions(-)
diff --git a/collection/unpacked b/collection/unpacked
index 1cceb5a..a98a65c 100755
--- a/collection/unpacked
+++ b/collection/unpacked
@@ -48,18 +48,25 @@ if ($type =~ m/^remove-/) {
if ($type eq 'source') {
# Ignore STDOUT of the child process because older versions of
# dpkg-source print things out even with -q.
- my $opts = { out => '/dev/null', err => 'unpacked-errors' };
- unless (spawn($opts, ['dpkg-source', '-q', '-x', 'dsc', 'unpacked'])) {
- open(ERRORS, '<', 'unpacked-errors')
- or fail("cannot open unpacked-errors: $!");
- print STDERR while <ERRORS>;
- close ERRORS;
- fail('dpkg-source -x failed with status ', $opts->{harness}->result);
+ if (0) {
+ my $opts = { out => '/dev/null', err => 'unpacked-errors' };
+ unless (spawn($opts, ['dpkg-source', '-q', '-x', 'dsc', 'unpacked'])) {
+ open(ERRORS, '<', 'unpacked-errors')
+ or fail("cannot open unpacked-errors: $!");
+ print STDERR while <ERRORS>;
+ close ERRORS;
+ fail('dpkg-source -x failed with status ', $opts->{harness}->result);
+ }
+
+
+ } else {
+ print STDERR "N: Using libdpkg-perl.\n";
+ libdpkg_unpack_dsc ('dsc', 'unpacked');
}
# fix permissions
spawn({ fail => 'error' },
- ['chmod', '-R', 'u+rwX,o+rX,o-w', 'unpacked']);
+ ['chmod', '-R', 'u+rwX,o+rX,o-w', 'unpacked']);
} else {
mkdir('unpacked', 0777) or fail("mkdir unpacked: $!");
@@ -85,3 +92,16 @@ if ($type eq 'source') {
['chmod', '-R', 'u+rwX,go-w', 'unpacked']);
}
+sub libdpkg_unpack_dsc {
+ my ($dsc, $target) = @_;
+ require Dpkg::Source::Package;
+ open(STDOUT, '>', '/dev/null') or fail "Redirecting stdout failed: $!";
+ # Create the object that does everything
+ my $srcpkg = Dpkg::Source::Package->new(filename => $dsc);
+
+ $srcpkg->check_checksums();
+
+ # Unpack the source package (delegated to Dpkg::Source::Package::*)
+ $srcpkg->extract($target);
+ return 1;
+}
--
1.7.4.4
Attachment:
0001-Sample-patch-to-unpack-using-libdpkg-perl-instead-dp.patch.sig
Description: Binary data