]> git.proxmox.com Git - dab.git/commitdiff
finalize: output also restuling archive size for convenience
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 21 Feb 2020 12:00:41 +0000 (13:00 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 21 Feb 2020 12:00:47 +0000 (13:00 +0100)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
DAB.pm

diff --git a/DAB.pm b/DAB.pm
index b0e140335893bd478721ac97cb51b9e0d5670da2..86e7f8865f42dd2aeaf9e25cf07a6b4f886954d5 100644 (file)
--- a/DAB.pm
+++ b/DAB.pm
@@ -738,15 +738,18 @@ sub finalize {
 
     write_file ("", "$rootdir/var/log/syslog");
 
-    $self->logmsg ("detecting final size: ");
+    my $get_path_size = sub {
+       my ($path) = @_;
+       my $sizestr = $self->run_command ("du -sm $path", undef, 1);
+       if ($sizestr =~ m/^(\d+)\s+\Q$path\E$/) {
+           return int($1);
+       } else {
+           die "unable to detect size for '$path'\n";
+       }
+    };
 
-    my $sizestr = $self->run_command ("du -sm $rootdir", undef, 1);
-    my $size;
-    if ($sizestr =~ m/^(\d+)\s+\Q$rootdir\E$/) {
-       $size = $1;
-    } else {
-       die "unable to detect size\n";
-    }
+    $self->logmsg ("detecting final appliance size: ");
+    my $size = $get_path_size->($rootdir);
     $self->logmsg ("$size MB\n");
 
     $self->write_config ("$rootdir/etc/appliance.info", $size);
@@ -754,12 +757,19 @@ sub finalize {
     $self->logmsg ("creating final appliance archive\n");
 
     my $target = "$self->{targetname}.tar";
+    my $final_archive = "${target}.gz";
     unlink $target;
-    unlink "$target.gz";
+    unlink $final_archive;
 
     $self->run_command ("tar cpf $target --numeric-owner -C '$rootdir' ./etc/appliance.info");
     $self->run_command ("tar rpf $target --numeric-owner -C '$rootdir' --exclude ./etc/appliance.info .");
     $self->run_command ("gzip $target");
+
+    $self->logmsg ("detecting final commpressed appliance size: ");
+    $size = $get_path_size->($final_archive);
+    $self->logmsg ("$size MB\n");
+
+    $self->logmsg ("appliance archive: $final_archive\n");
 }
 
 sub read_installed {