chiark / gitweb /
No need for Makefile-etc now - we hope.
[chiark-utils.git] / backup / backuplib.pl
index 37b3d7936f6c8bf3568739f77e5b56bcc315c6fd..26a8533d1150e85ee3e2fa7079f742ddf2df5647 100644 (file)
@@ -73,11 +73,14 @@ sub killprocesses {
 # Trailing whitespace is ignored. Lines of the form 'prefix foo bar'
 # are handled specially, as arex lines 'exclude regexp'; otherwise 
 # we just shove the line into @fsys and let parsefsys deal with it.
 # Trailing whitespace is ignored. Lines of the form 'prefix foo bar'
 # are handled specially, as arex lines 'exclude regexp'; otherwise 
 # we just shove the line into @fsys and let parsefsys deal with it.
-sub readfsys ($) {
-    my ($fsnm) = @_;
-    open F, "$etc/fsys.$fsnm" or die "Filesystems $fsnm unknown ($!).\n";
+
+sub readfsysfile ($) {
+    my ($fn) = @_;
+    my ($fh,$sfn);
+    $fh= new IO::File "$fn", "r" or die "cannot open fsys file $fn ($!).\n";
     for (;;) {
     for (;;) {
-       $_= <F> or die "unexpected EOF in $etc/fsys.$fsnm\n"; chomp; s/\s*$//;
+       $!=0; $_= <$fh> or die "unexpected EOF in $fn ($!)\n";
+       chomp; s/\s*$//;
        last if m/^end$/;
        next unless m/\S/;
        next if m/^\#/;
        last if m/^end$/;
        next unless m/\S/;
        next if m/^\#/;
@@ -89,11 +92,23 @@ sub readfsys ($) {
             push @excldir,$1;
         } elsif (m/^exclude\s+(\S.*\S)$/) {
             push @excl,$1;
             push @excldir,$1;
         } elsif (m/^exclude\s+(\S.*\S)$/) {
             push @excl,$1;
+       } elsif (m/^include\s+(\S.*\S)$/) {
+           $sfn =~ s/^\./fsys./;
+           $sfn = "$etc/$sfn" if $sfn !~ m,^/,;
+           readfsysfile($sfn);
         } else {
            push @fsys,$_;
        }
     }
         } else {
            push @fsys,$_;
        }
     }
-    close F or die $!;
+    close $fn or die $!;
+}
+
+sub readfsys ($) {
+    my ($fsnm) = @_;
+    my ($fsf);
+    $fsf= "$etc/fsys.$fsnm";
+    stat $fsf or die "Filesystems $fsnm unknown ($!).\n";
+    readfsysfile($fsf);
 }
 
 # Parse a line from a filesystem definition file. We expect the line
 }
 
 # Parse a line from a filesystem definition file. We expect the line