Subject: Re: `use sup' not tar balls ....
To: None <current-users@NetBSD.ORG>
From: Luke Mewburn <lm@melb.cpr.itg.telecom.com.au>
List: current-users
Date: 01/13/1995 09:48:28
> The output of the daily CVS update already contains this information,
> and if you're subscribed to source-changes, you'll see it.   Granted
> it's not in exactly the form you'd like, but the point is that there's
> no particular reason to run a find...

At one stage I was SUPping off sun-lamp to a machine at work, and then
running a script I wrote on the output of sup -v that generated a
shar file that I took to home via a disk and then ran that shar file
on my source tree.

This script correctly handled file additions/changes and
file/directory deletes. I haven't used it in ages though; for a long
time I had my netbsd box in at work directly on the 'net, and recently
I got an EXB-8200 for home so I just take a tar file home when I feel
productive and want to play around with -current :)

Here's the script. It may need some work.

--- cut here --- file: bin/sup2shar
#!/usr/bin/perl
#
# Copyright 1994 Luke Mewburn <lm@werj.com.au>.  All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
#    must display the following acknowledgement:
# 	This product includes software developed by Luke Mewburn.
# 4. The name of the author may not be used to endorse or promote products
#    derived from this software without specific prior written permission.
# 
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# 
# sup2shar --
#	Parses the output of a sup -v logfile and generates a shell script
#	to run on another host containing the commands to get its source
#	tree in sync.
#
# 940226, lm	- original program
# 940227, lm	- added killdir functionalitiy (to clean up objdir symlinks)
#		- added file mod time restoration (touch)
# 940311, lm	- removed touch
# 940510, lm	- added -u.
#

require "getopts.pl";

($progname = $0) =~ s@.*/@@;

sub usage
{
    print <<USAGE;
Usage: $progname [-u] file
parses the output of a 'sup -v logfile' and generates a shar file
containing the commands to get its source tree in sync.
	-u	`Updating' lines are considered `Receiving' lines.
		(when the log file is of a 2nd attempt and you
		already had 1/2 the files.)
USAGE
    exit 1;
}


&Getopts('u') || &usage();


select(STDERR); $| = 1;
select(STDOUT); $| = 1;

chop($date = `date`);
chop($user = `whoami`);
chop($hostname = `hostname`);

print <<HEADER;
#!/bin/sh
#
# Made $date by $user@$hostname
#

HEADER

print <<'SHFUNCS';
killdir()
{
    if [ -e $1/obj ]; then
	rm -rf `cd $1/obj;pwd`
    fi
    rm -rf $1
}

SHFUNCS


MAIN:
while (<>)
{
    chop;
    next MAIN unless /^SUP /;
    if (   /^SUP Backup of/
	|| /^SUP Executing/
	|| /^SUP Created (\S*)link/
	|| /^SUP Deleted symbolic link/
	|| /^SUP Removed/ )
    {
	print STDERR "Unsupported directive: $_\n";
	next MAIN;
    }

    SW:
    {
    /^SUP Deleted directory (\S*)$/o && do
	{
	    print "echo remove dir $1\n";
	    print "killdir $1\n";
	    print STDERR "killdir $1\n";
	    last SW;
	};
    /^SUP Deleted file (\S*)$/o && do
	{
	    print "echo rm $1\n";
	    print "rm $1\n";
	    print STDERR "rm $1\n";
	    last SW;
	};
    /^SUP Created directory (\S*) for (\S*)$/o && do
	{
	    print "echo mkdir $1\n";
	    print "mkdir $1\n";
	    print STDERR "mkdir $1\n";
	    last SW;
	};
    /^SUP (Receiving|Updating) file (\S*)$/o && do
	{
	    local($func, $file)=($1, $2);
	    next if (($func eq "Updating") && (! $opt_u));
	    next unless (-e $file);
	    print "echo x - $file\n";
	    print "sed 's/^X//' >$file <<'SHAR_EOF'\n";
	    system("sed 's/^/X/' $file");
	    print "SHAR_EOF\n";
	    print STDERR "-- $file\n";
	    last SW;
	};
    } # endSW
}


#
# Messages that we may need to handle from sup -v
#	
# Used:
#	SUP Deleted directory %s
#	SUP Deleted file %s
#	SUP Receiving file %s
#	SUP Created directory %s for %s
#	
# Unused (ignored during parsing):
#	SUP Backup of %s created
#	SUP Updating file %s
#	SUP Executing %s
#	SUP Created directory %s\n"
#	SUP Updated directory %s\n"
#	SUP Created symbolic link %s to %s
#	SUP Created %slink %s to %s
#	SUP Deleted symbolic link %s
#	SUP Removed %s %s
#
--- cut here ---


-- 
Luke Mewburn, <lm@cpr.itg.telecom.com.au>
`Think of it as Evolution in Action.' - "Oath of Fealty", Niven & Pournelle