File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / rsync / support / files-to-excludes
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Fri Feb 17 15:09:30 2012 UTC (12 years, 4 months ago) by misho
Branches: rsync, MAIN
CVS tags: v3_1_2p5, rsync3_0_9p0, RSYNC3_1_0, RSYNC3_0_9, HEAD
rsync

#!/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";

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>