[buildd-tools-devel] Bug#825359: Aw: Re: sbuild: unrealistic figure about total space used

Johannes Schauer josch at debian.org
Fri Jul 1 14:18:46 UTC 2016


Control: tag -1 + patch

Hi,

Quoting Helge Deller (2016-07-01 15:55:28)
> The patch is obvious if you look at the full code of the loop:
> 
>     foreach (@files) {
>         my $space = $self->get('Host')->read_command(
>             { COMMAND => ['du', '-k', '-s', $_],           USER => $self->get_conf('USERNAME'),              PRIORITY => 0,              DIR => '/'});
> 
>         if (!$space) {
>             $self->log_error("Cannot determine space needed (du failed): $!\n");
>             next;
>         }
>         if ($pkgbuilddirspc !~ /^(\d+)/) {
>             $self->log_error("Cannot determine space needed (unexpected du output): $space\n");
>         }
> 
>         $sum += $1;
>     }
> 
> The "$sum+=$1" is wrong. Instead it needs to read "$sum+=$space;"

I cannot test this but are you sure that the solution to this problem is not
instead this patch:


diff --git a/lib/Sbuild/Build.pm b/lib/Sbuild/Build.pm
index 6d36ec6..68c1f40 100644
--- a/lib/Sbuild/Build.pm
+++ b/lib/Sbuild/Build.pm
@@ -2185,7 +2185,7 @@ sub check_space {
            $self->log_error("Cannot determine space needed (du failed): $!\n");
            next;
        }
-       if ($pkgbuilddirspc !~ /^(\d+)/) {
+       if ($space !~ /^(\d+)/) {
            $self->log_error("Cannot determine space needed (unexpected du output): $space\n");
        }
        $sum += $1;

The variable '$pkgbuilddirspc' is only used to hold an integer before the loop
starts. Inside the loop, the variable '$space' is used but '$pkgbuilddirspc'
was erroneously used, probably as the result of a copy&paste error when I
created that loop.

What your patch does, is to add a string to an integer that still has trailing
"garbage" in it. But perl will not complain about that (and thus your patch
"works") because in perl this is legal:

my $foo = 1 + "2 bbar"; # $foo is now 3

Can you confirm that my patch fixes the issue?

Thanks!

cheers, josch
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: signature
URL: <http://lists.alioth.debian.org/pipermail/buildd-tools-devel/attachments/20160701/557c714e/attachment.sig>


More information about the Buildd-tools-devel mailing list