This perl script automates the conversion of a list of pathnames
authorWayne Davison <wayned@samba.org>
Mon, 30 Jan 2006 21:52:17 +0000 (21:52 +0000)
committerWayne Davison <wayned@samba.org>
Mon, 30 Jan 2006 21:52:17 +0000 (21:52 +0000)
to a set of includes/excludes needed for rsync to copy just the
listed files.

support/files-to-excludes [new file with mode: 0755]

diff --git a/support/files-to-excludes b/support/files-to-excludes
new file mode 100755 (executable)
index 0000000..5fb13b0
--- /dev/null
@@ -0,0 +1,27 @@
+#!/usr/bin/perl
+# This script takes an input of filenames and outputs a set of
+# include/exclude directives that can be used by rsync to copy
+# just the indicated files using an --exclude-from=FILE option.
+use strict;
+
+my %hash;
+
+while (<>) {
+    chomp;
+    s#^/+##;
+    my $path = '/';
+    while (m#([^/]+/)/*#g) {
+       $path .= $1;
+       print "+ $path\n" unless $hash{$path}++;
+    }
+    if (m#([^/]+)$#) {
+       print "+ $path$1\n";
+    } else {
+       delete $hash{$path};
+    }
+}
+
+foreach (sort keys %hash) {
+    print "- $_*\n";
+}
+print "- /*\n";