remove Filesys::Df dependency
authorDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 3 Jan 2011 21:56:20 +0000 (21:56 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 3 Jan 2011 21:56:20 +0000 (21:56 +0000)
bin/BackupPC_burnArchiveCLI

index 399e2a4..3a6d8dc 100755 (executable)
@@ -2,7 +2,7 @@
 
 use strict;
 
-use lib "__INSTALLDIR__/lib";
+use lib "/usr/local/BackupPC/lib";
 
 use DBI;
 use BackupPC::Lib;
@@ -12,7 +12,6 @@ use POSIX qw/strftime/;
 use Term::Menus;
 use File::Which;
 use File::Path;
-use Filesys::Df;
 use Cwd qw/abs_path/;
 use Data::Dumper;
 
@@ -64,6 +63,14 @@ die "problem with $iso_dir, check ISOTempDir in configuration\n" unless (-d $iso
 
 #---- subs ----
 
+sub df_bytes_available {
+       my $path = shift;
+       my $out = `df -P $path`;
+       my $bytes = (split(/\s+/, (split(/\n/,$out))[-1]))[3];
+       return $bytes * 1024;
+
+}
+
 sub fmt_time {
        my $t = shift || return;
        my $out = "";
@@ -413,8 +420,7 @@ foreach my $copy_nr ( 1 .. $copies ) {
 
                # check available disk space
 
-               my $df = df($iso_dir)->{bavail} || die "can't get free space on $iso_dir";
-               $df *= 1024;    # calulate space in bytes
+               my $df = df_bytes_available($iso_dir);
                if ($df < $v_size) {
                        warn "ABORTED: not enough disk space to create ISO ! [need ", fmt_mb($v_size), " have ", fmt_mb( $df ), " on $iso_dir]\n";
                        next;