chiark / gitweb /
Dgit.pm: Move debinatag_maintview from dgit
[dgit.git] / Debian / Dgit.pm
index 8f069f7575e64739be6d9a25237d2f0640f3dff6..0e2464d6d1505bd52e3c4976eb12a8094bb8c063 100644 (file)
@@ -31,6 +31,7 @@ use Data::Dumper;
 use IPC::Open2;
 use File::Path;
 use File::Basename;
+use Dpkg::Control::Hash;
 
 BEGIN {
     use Exporter   ();
@@ -41,6 +42,7 @@ BEGIN {
     @EXPORT      = qw(setup_sigwarn forkcheck_setup forkcheck_mainprocess
                      dep14_version_mangle
                       debiantags debiantag_old debiantag_new
+                     debiantag_maintview
                      server_branch server_ref
                       stat_exists link_ltarget
                      hashfile
@@ -67,7 +69,7 @@ BEGIN {
                      changedir git_slurp_config_src
                      gdr_ffq_prev_branchinfo
                      parsecontrolfh parsecontrol parsechangelog
-                     getfield
+                     getfield parsechangelog_loop
                      playtree_setup);
     # implicitly uses $main::us
     %EXPORT_TAGS = ( policyflags => [qw(NOFFCHECK FRESHREPO NOCOMMITCHECK)],
@@ -208,6 +210,11 @@ sub debiantag_new ($$) {
     return "archive/$distro/".dep14_version_mangle $v;
 }
 
+sub debiantag_maintview ($$) { 
+    my ($v,$distro) = @_;
+    return "$distro/".dep14_version_mangle $v;
+}
+
 sub debiantags ($$) {
     my ($version,$distro) = @_;
     map { $_->($version, $distro) } (\&debiantag_new, \&debiantag_old);
@@ -609,6 +616,27 @@ sub getfield ($$) {
     fail "missing field $field in ".$dctrl->get_option('name');
 }
 
+sub parsechangelog_loop ($$$) {
+    my ($clogcmd, $descbase, $fn) = @_;
+    # @$clogcmd is qw(dpkg-parsechangelog ...some...options...)
+    # calls $fn->($thisstanza, $desc);
+    debugcmd "|",@$clogcmd;
+    open CLOGS, "-|", @$clogcmd or die $!;
+    for (;;) {
+       my $stanzatext = do { local $/=""; <CLOGS>; };
+       printdebug "clogp stanza ".Dumper($stanzatext) if $debuglevel>1;
+       last if !defined $stanzatext;
+
+       my $desc = "$descbase, entry no.$.";
+       open my $stanzafh, "<", \$stanzatext or die;
+       my $thisstanza = parsecontrolfh $stanzafh, $desc, 1;
+
+       $fn->($thisstanza, $desc);
+    }
+    die $! if CLOGS->error;
+    close CLOGS or $?==SIGPIPE or failedcmd @$clogcmd;
+}      
+
 # ========== playground handling ==========
 
 # terminology: