Subject: [PATCH 01/25] Add an unpack script for .changes files

From: Adam D. Barratt <[email-masked]>
Date: Mon, 4 Jan 2010 19:12:50 +0000

The only data currently "unpacked" is the collection of fields.  This is the
first step towards making .changes files first-class objects in the checking
process.
---
 unpack/unpack-changes-l1 |   66 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 66 insertions(+), 0 deletions(-)
 create mode 100755 unpack/unpack-changes-l1

diff --git a/unpack/unpack-changes-l1 b/unpack/unpack-changes-l1
new file mode 100755
index 0000000..c536e12
--- /dev/null
+++ b/unpack/unpack-changes-l1
@@ -0,0 +1,66 @@
+#!/usr/bin/perl
+# unpack-changes-l1 -- lintian unpack script (changes file level 1)
+#
+# syntax: unpack-changes-l1 <base-dir> <changes-file>
+#
+# Note, that <changes-file> must be specified with absolute path.
+
+# Copyright (C) 1998 Christian Schwarz
+# Copyright (C) 2010 Adam D. Barratt
+#
+# 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.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, you can find it on the World Wide
+# Web at http://www.gnu.org/copyleft/gpl.html, or write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+use strict;
+use vars qw($verbose);
+
+($#ARGV == 1) or die "syntax: unpack-changes-l1 <base-dir> <changes-file>";
+my $base_dir = shift;
+my $file = shift;
+
+# import perl libraries
+use lib "$ENV{'LINTIAN_ROOT'}/lib";
+use Util;
+
+# stat $file
+(my @stat = stat $file) or fail("$file: cannot stat: $!");
+
+# get package control information
+my $data = get_dsc_info($file);
+
+# create directory in lab
+print "N: Creating directory $base_dir ...\n" if $verbose;
+mkdir("$base_dir", 0777) or fail("mkdir $base_dir: $!");
+mkdir("$base_dir/fields", 0777) or fail("mkdir $base_dir/fields: $!");
+
+# create control field files
+for my $field (keys %$data) {
+    my $field_file = "$base_dir/fields/$field";
+    open(F, '>', $field_file)
+        or fail("cannot open file $field_file for writing: $!");
+    print F $data->{$field},"\n";
+    close(F);
+}
+
+symlink($file,"$base_dir/changes") or fail("cannot symlink changes file: $!");
+
+exit 0;
+
+# Local Variables:
+# indent-tabs-mode: nil
+# cperl-indent-level: 4
+# End:
+# vim: syntax=perl sw=4 sts=4 ts=4 et shiftround
-- 
1.6.6