There was also a missing import, attaching a revised patch.
diff --git a/scripts/debrebuild.pl b/scripts/debrebuild.pl index 561db866..01c445d5 100755 --- a/scripts/debrebuild.pl +++ b/scripts/debrebuild.pl @@ -20,6 +20,7 @@ use autodie; use Getopt::Long qw(:config gnu_getopt no_bundling no_auto_abbrev); use Dpkg::Control; +use Dpkg::Control::FieldsCore; use Dpkg::Index; use Dpkg::Deps; use Dpkg::Source::Package; @@ -234,16 +235,20 @@ my $srcpkgver = $cdata->{Version}; # make $@ local, so we don't print "Undefined subroutine" error message # in other parts where we evaluate $@ local $@ = ''; + # in some cases the source field contains a version in the form: name (version) + # for example: binclock (1.5-6) # field_parse_binary_source is only available starting with dpkg 1.21.0 - eval { ($srcpkgname, $srcpkgver) = field_parse_binary_source($cdata); }; - if ($@) { - ($srcpkgname, $srcpkgver) = split / /, $srcpkgname, 2; - # Add a simple control check to avoid the worst surprises and stop - # obvious cases of garbage-in-garbage-out. - die("Unexpected source package name: ${srcpkgname}\n") - if $srcpkgname =~ m{[ \t_/\(\)<>!\n%&\$\#\@]}; - # remove the surrounding parenthesis from the version - $srcpkgver =~ s/^\((.*)\)$/$1/; + if ($srcpkgname =~ / /) { + eval { ($srcpkgname, $srcpkgver) = field_parse_binary_source($cdata); }; + if ($@) { + ($srcpkgname, $srcpkgver) = split / /, $srcpkgname, 2; + # Add a simple control check to avoid the worst surprises and stop + # obvious cases of garbage-in-garbage-out. + die("Unexpected source package name: ${srcpkgname}\n") + if $srcpkgname =~ m{[ \t_/\(\)<>!\n%&\$\#\@]}; + # remove the surrounding parenthesis from the version + $srcpkgver =~ s/^\((.*)\)$/$1/; + } } }