The following commit has been merged in the master branch:
commit 3470d4d118e79d5ec6bac11706e59d26a2596cd1
Author: Raphael Hertzog <[EMAIL PROTECTED]>
Date:   Sun Jun 1 12:07:17 2008 +0200

    dpkg-gencontrol: accept "-c-" to read the control file from stdin
    
    * scripts/Dpkg/Control.pm (parse, parse_fh, new): Add a new function
    parse_fh() to be able to parse the control file from an arbitrary
    file handle. Change parse() to use it and modify new() to parse
    STDIN instead of a real file if the parameter is "-".

diff --git a/ChangeLog b/ChangeLog
index 3da9455..f0bcd2c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-06-01  Raphael Hertzog  <[EMAIL PROTECTED]>
+
+       * scripts/Dpkg/Control.pm (parse, parse_fh, new): Add a new function
+       parse_fh() to be able to parse the control file from an arbitrary
+       file handle. Change parse() to use it and modify new() to parse
+       STDIN instead of a real file if the parameter is "-".
+
 2008-06-01  Daniel Hahler  <[EMAIL PROTECTED]>
 
        * src/archives.c (tarobject): Improve error message stating that
diff --git a/debian/changelog b/debian/changelog
index 26c5271..1194fdf 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -23,6 +23,8 @@ dpkg (1.15.0) UNRELEASED; urgency=low
   * Improve error message stating that dpkg is unable to create a file so that
     it also refers to the real filename instead of the non-diverted name only.
     Thanks to Daniel Hahler for the patch. Closes: #457135
+  * dpkg-gencontrol can now again read the control file from its standard
+    input with "-c-". Closes: #465340
 
   [ Pierre Habouzit ]
   * Add a --query option to update-alternatives. Closes: #336091, #441904
diff --git a/scripts/Dpkg/Control.pm b/scripts/Dpkg/Control.pm
index b9e4c94..fd0c27e 100644
--- a/scripts/Dpkg/Control.pm
+++ b/scripts/Dpkg/Control.pm
@@ -39,7 +39,7 @@ syntax than debian/control.
 =item $c = Dpkg::Control->new($file)
 
 Create a new Dpkg::Control object for $file. If $file is omitted, it parses
-debian/control.
+debian/control. If file is "-", it parses the standard input.
 
 =cut
 sub new {
@@ -51,7 +51,11 @@ sub new {
     };
     bless $self, $class;
     if ($arg) {
-       $self->parse($arg);
+        if ($arg eq "-") {
+            $self->parse_fh(\*STDIN);
+        } else {
+            $self->parse($arg);
+        }
     } else {
        $self->parse("debian/control");
     }
@@ -76,24 +80,33 @@ Parse the content of $file. Exits in case of errors.
 =cut
 sub parse {
     my ($self, $file) = @_;
-    $self->reset();
-    # Parse
     open(CDATA, "<", $file) || syserr(_g("cannot read %s"), $file);
-    my $cdata = parsecdata(\*CDATA, $file);
+    $self->parse_fh(\*CDATA);
+    close(CDATA);
+}
+
+=item $c->parse_fh($fh)
+
+Parse a control file from the given filehandle. Exits in case of errors.
+
+=cut
+sub parse_fh {
+    my ($self, $fh) = @_;
+    $self->reset();
+    my $cdata = parsecdata($fh, _g("standard input"));
     return if not defined $cdata;
     $self->{source} = $cdata;
     unless (exists $cdata->{Source}) {
-       syntaxerr($file, _g("first block lacks a source field"));
+       syntaxerr(_g("standard input"), _g("first block lacks a source field"));
     }
     while (1) {
-       $cdata = parsecdata(\*CDATA, $file);
+       $cdata = parsecdata($fh, _g("standard input"));
        last if not defined $cdata;
        push @{$self->{packages}}, $cdata;
        unless (exists $cdata->{Package}) {
-           syntaxerr($file, _g("block lacks a package field"));
+           syntaxerr(_g("standard input"), _g("block lacks a package field"));
        }
     }
-    close(CDATA);
 }
 
 =item $c->get_source()

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to