chiark / gitweb /
Revert "fishdescriptor: for revert: attempt at setuptools"
[chiark-utils.git] / backup / backuplib.pl
index ddeb5bbb4bd9b9243b80c33403fdd0223d732f1b..cbbe6f4619b5612f248eb86cc70289ed6ab773dc 100644 (file)
@@ -5,12 +5,13 @@
 # other UN*X-compatible machines, as used on chiark.greenend.org.uk.
 #
 # chiark backup is:
 # other UN*X-compatible machines, as used on chiark.greenend.org.uk.
 #
 # chiark backup is:
-#  Copyright (C) 1997-1998,2000-2001 Ian Jackson <ian@chiark.greenend.org.uk>
+#  Copyright (C) 1997-1998,2000-2001,2007
+#                     Ian Jackson <ian@chiark.greenend.org.uk>
 #  Copyright (C) 1999 Peter Maydell <pmaydell@chiark.greenend.org.uk>
 #
 # This is free software; you can redistribute it and/or modify it under the
 # terms of the GNU General Public License as published by the Free Software
 #  Copyright (C) 1999 Peter Maydell <pmaydell@chiark.greenend.org.uk>
 #
 # This is free software; you can redistribute it and/or modify it under the
 # terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2, or (at your option) any later version.
+# Foundation; either version 3, or (at your option) any later version.
 #
 # This is distributed in the hope that it will be useful, but WITHOUT ANY
 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 #
 # This is distributed in the hope that it will be useful, but WITHOUT ANY
 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
@@ -18,8 +19,8 @@
 # details.
 #
 # You should have received a copy of the GNU General Public License along
 # details.
 #
 # You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# with this program; if not, consult the Free Software Foundation's
+# website at www.fsf.org, or the GNU Project website at www.gnu.org.
 
 require IO::File;
 
 
 require IO::File;
 
@@ -173,8 +174,6 @@ sub parsefsys () {
        $dopts= $3;
        $prefix= '<local>';
        $pcstr= '';
        $dopts= $3;
        $prefix= '<local>';
        $pcstr= '';
-       stat $atf or die "stat $atf: $!";
-       -d _ or die "not a dir: $atf";
        $rstr= '';
     } elsif ($tf =~ m#^(/\S*)\s+(\w+)([,=0-9a-z]*)\s+(\w+)$#) {
         # Line of form '[/device:]/file/system dumptype[,options] prefix'
        $rstr= '';
     } elsif ($tf =~ m#^(/\S*)\s+(\w+)([,=0-9a-z]*)\s+(\w+)$#) {
         # Line of form '[/device:]/file/system dumptype[,options] prefix'
@@ -197,11 +196,16 @@ sub parsefsys () {
 
     $dev = $atf =~ s,^(.*)\:,, ? $1 : '';
 
 
     $dev = $atf =~ s,^(.*)\:,, ? $1 : '';
 
+    if (!length $pcstr) {
+       stat $atf or die "stat $atf: $!";
+       -d _ or die "not a dir: $atf";
+    }
+
     undef %dopt;
     foreach $dopt (split /\,/,$dopts) {
     undef %dopt;
     foreach $dopt (split /\,/,$dopts) {
-       if (grep { $dopt eq $_ } qw(gz)) {
+       if (grep { $dopt eq $_ } qw(gz noinc)) {
            $dopt{$dopt}= 'y';
            $dopt{$dopt}= 'y';
-       if (grep { $dopt eq $_ } qw(snap)) {
+       } elsif (grep { $dopt eq $_ } qw(snap)) {
            $dopt{$dopt}= $dopt;
        } elsif ($dopt =~ m/\=/ && grep { $` eq $_ } qw(gz snap)) {
            $dopt{$`}= $';
            $dopt{$dopt}= $dopt;
        } elsif ($dopt =~ m/\=/ && grep { $` eq $_ } qw(gz snap)) {
            $dopt{$`}= $';
@@ -222,6 +226,10 @@ sub parsefsys () {
            $$gzo= '';
        }
     }
            $$gzo= '';
        }
     }
+
+    if (length $dopt{'snap'}) {
+       length $dev or die "$pcstr:$atf no device but needed for snap";
+    }
 }
 
 sub execute ($) {
 }
 
 sub execute ($) {
@@ -230,14 +238,19 @@ sub execute ($) {
 }
 
 sub prepfsys () {
 }
 
 sub prepfsys () {
+    $dev_print= $dev;
+    $atf_print= $atf;
+    
     if (length $dopt{'snap'}) {
     if (length $dopt{'snap'}) {
+       
        system('snap-drop'); $? and die $?;
        
        $snapscripts= '/etc/chiark-backup/snap';
        system('snap-drop'); $? and die $?;
        
        $snapscripts= '/etc/chiark-backup/snap';
-       $snapbase= "$rstr $snapscripts/$dopt{'snap'} /var/lib/chiark-backup";
+       $snapbase= "$rstr $snapscripts/$dopt{'snap'}";
+       $snapargs= "/var/lib/chiark-backup";
 
 
-       $snapsnap= "$snapbase snap $dev $atf";
-       $snapdrop= "$snapbase drop";
+       $snapsnap= "$snapbase snap $snapargs $dev $atf";
+       $snapdrop= "$snapbase drop $snapargs";
 
        open SD, ">snap-drop.new" or die $!;
        print SD $snapdrop,"\n" or die $!;
 
        open SD, ">snap-drop.new" or die $!;
        print SD $snapdrop,"\n" or die $!;