Subject: Re: Automagic 'cvs update'
To: None <current-users@netbsd.org>
From: Thomas Klausner <wiz@danbala.ifoer.tuwien.ac.at>
List: current-users
Date: 07/14/2000 19:15:01
--h31gzZEtNLTqOjlF
Content-Type: text/plain; charset=us-ascii

Yeah, great, I did it again.
Hope you find it even more useful when I attach it properly ;-)
 Thomas

-- 
Thomas Klausner - wiz@danbala.tuwien.ac.at
I wanted to emulate some of my heroes, but I didn't know their
op-codes. --dowe

--h31gzZEtNLTqOjlF
Content-Type: application/x-perl
Content-Disposition: attachment; filename="autofetch.pl"

#!/usr/pkg/bin/perl
# (c) Copyright 2000 Thomas Klausner <wiz@netbsd.org>
#
# uses NetBSD-source-changes postings as input for cvs update

# Modify the next lines to specify the place for your CVS archive(s);
# comment out lines for parts of the repository that you don't want 
# to follow. Branch commits are logged internally as commits to
# 'directory-branchname' (see syssrc below as an example).

# $base = "/usr";
$base = "/archive/cvs";
$base15 = "/archive/cvs/1.5";

%nametodir = ("basesrc" => "$base/src",
	      "cryptosrc-intl" => "$base/src",
	      "gnusrc" => "$base/src",
	      "pkgsrc" => "$base/pkgsrc",
	      "sharesrc" => "$base/src",
	      "syssrc" => "$base/src",
	      "syssrc-netbsd-1-5" => "$base15/syssrc",
	      "xsrc" => "$base/xsrc");

# you shouldn't have to change anything below this line

%output = ();
$dir = "";
$collection = "";
@files = ();

while (<>) {
    chomp();
    if (/Update of \/cvsroot\/([\S]*src[^\/]*)\/(\S*)$/) {
	# import of new packages
	$collection = $1;
	# not really necessary, but oh well...
	$dir = $2;
	@files = split ' ', $2;
    }
    elsif (/\t([\S]*src[^\/]*)\/([^:]*): (.*)/) {
	# update of files in a directory
	$collection = $1;
	$dir = $2;
	if ($dir =~ /\[(.*)\]/) {
	    # branch commit, change collection
	    $collection .= "-$1";
	    $dir =~ s/ \[(.*)\]//g;
#	    print "branch commit: $1 ($collection, $dir)\n";
	}
	@files = split ' ', $3;
	foreach $entry (@files) {
	    $entry =~ s,^,$dir/,;
	}
    } 
    elsif (/^\t    ([^ ].*)$/) {
	# continuation line of above
	@files = split ' ', $1;
	foreach $entry (@files) {
	    $entry =~ s,^,$dir/,;
	}
    }
    else {
	next;
    }

    if ($nametodir{$collection}) {
	push @{$output{$collection}}, @files;
	@files = ();
    }
}

$last = "thisshouldntmatchanything";

foreach $entry (keys %output) {
    print "cd $nametodir{$entry}; cvs update ";
    foreach $line (sort @{$output{$entry}}) {
	# optimize cvs update, remove duplicates (which break cvs update
	# with bogus conflicts)
	$_ = $line;
	if (! /^$last/) {
	    print "$line ";
	    $last = $line;
	}
    }
    print "\n";
}

--h31gzZEtNLTqOjlF--