File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / rsync / support / files-to-excludes
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Wed Mar 17 00:32:36 2021 UTC (3 years, 2 months ago) by misho
Branches: rsync, MAIN
CVS tags: v3_2_3, HEAD
rsync 3.2.3

#!/usr/bin/env 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>