--- /dev/null
+drwxr-xr-x root/root etc/
+drwxr-xr-x root/root etc/ports/
+drwxr-xr-x root/root etc/ports/drivers/
+-rwxr-xr-x root/root etc/ports/drivers/rsync
+drwxr-xr-x root/root etc/rc.d/
+-rwxr-xr-x root/root etc/rc.d/rsyncd
+-rw-r--r-- root/root etc/rsyncd.conf
+drwxr-xr-x root/root usr/
+drwxr-xr-x root/root usr/bin/
+-rwxr-xr-x root/root usr/bin/rsync
+drwxr-xr-x root/root usr/share/
+drwxr-xr-x root/root usr/share/man/
+drwxr-xr-x root/root usr/share/man/man1/
+-rw-r--r-- root/root usr/share/man/man1/rsync.1.gz
+drwxr-xr-x root/root usr/share/man/man5/
+-rw-r--r-- root/root usr/share/man/man5/rsyncd.conf.5.gz
+drwxr-xr-x root/root var/
+drwxr-xr-x root/root var/log/
+-rw-r--r-- root/root var/log/rsyncd.log (EMPTY)
--- /dev/null
+# Description: Utility for incremental file transfers over networks
+# URL: http://rsync.samba.org
+# Maintainer: CRUX System Team, core-ports at crux dot nu
+# Depends on: acl
+
+name=rsync
+version=3.1.1
+release=3
+source=(http://rsync.samba.org/ftp/$name/src/$name-$version.tar.gz \
+ rsyncd.conf rsyncd rsync.driver)
+
+build () {
+ cd $name-$version
+
+ ./configure --build=$CHOST \
+ --host=$CTARGET \
+ --prefix=/usr \
+ --with-rsh=ssh \
+ --with-included-popt \
+ --with-included-zlib
+
+ make
+ make DESTDIR=$PKG install
+
+ install -d $PKG/etc/{rc.d,ports/drivers} $PKG/var/log
+ install -m 755 $SRC/rsyncd $PKG/etc/rc.d
+ install -m 644 $SRC/rsyncd.conf $PKG/etc
+ install -m 755 $SRC/rsync.driver $PKG/etc/ports/drivers/rsync
+ touch $PKG/var/log/rsyncd.log
+}
--- /dev/null
+#!/usr/bin/perl
+#
+# /etc/ports/drivers/rsync: rsync(1) driver script for ports(8)
+#
+
+use warnings;
+use strict;
+use File::Basename;
+
+my $host = '';
+my $collection = '';
+my $destination = '';
+my %new_checkouts;
+my %old_checkouts;
+
+sub error
+{
+ my $message = shift;
+ print "Error: $message ($!)\nUpdating failed\n";
+ exit 1;
+}
+
+sub warning
+{
+ my $message = shift;
+ print "Warning: $message ($!)\n";
+}
+
+if ($#ARGV < 0)
+{
+ print "Usage: $0 <file>\n";
+ exit 1;
+}
+
+open(FILE, $ARGV[0]) or error("Couldn't open $ARGV[0]");
+while (<FILE>)
+{
+ chomp;
+ if (/^host=(.*)/) { $host = $1; }
+ elsif (/^collection=(.*)/) { $collection = $1; }
+ elsif (/^destination=(.*)/) { $destination = $1; }
+}
+close(FILE);
+
+if ($host eq '') { error("Host field not set in $ARGV[0]"); }
+if ($collection eq '') { error("Collection field not set in $ARGV[0]"); }
+if ($destination eq '') { error("Destination field not set in $ARGV[0]"); }
+
+if (-e "$destination/.checkouts")
+{
+ # read the old .checkouts file into memory
+ open(FILE, "$destination/.checkouts") or error("Couldn't read checkouts from $destination/.checkouts");
+ while (<FILE>)
+ {
+ chomp;
+ $old_checkouts{$_} = 1;
+ }
+ close(FILE);
+}
+
+print "Updating file list from " . $host . "::$collection\n";
+
+# get the remote file list (new .checkouts)
+open(PIPE, 'rsync -crz --no-human-readable ' . $host . '::' . $collection . '|') or error("Couldn't open pipe to rsync");
+while (<PIPE>)
+{
+ chomp;
+
+ next if /^MOTD:/; # ignore MOTD lines
+ s/^(.{43})//; # ignore the first 43 characters (mode, date etc...)
+ next if /^.$/; # ignore the . directory
+
+ $new_checkouts{$_} = 1;
+}
+close(PIPE);
+error("Running rsync failed") unless $? == 0;
+
+print "Updating collection " . basename($destination) . "\n";
+
+# now really run rsync
+open(PIPE, 'rsync -crz --no-human-readable --log-format "%o %n" ' . $host . "::$collection $destination|") or error("Couldn't open pipe to rsync");
+while (<PIPE>)
+{
+ chomp;
+
+ if (/^recv (.*)/)
+ {
+ if ($old_checkouts{$1})
+ {
+ s/^recv/ Edit/;
+ }
+ else
+ {
+ s/^recv/ Checkout/;
+ }
+ }
+
+ print $_ . "\n";
+}
+close(PIPE);
+error("Running rsync failed") unless $? == 0;
+
+# save new checkouts into .checkouts
+open(FILE, ">$destination/.checkouts") or error("Couldn't save checkouts to $destination/.checkouts");
+foreach my $checkout (sort keys %new_checkouts)
+{
+ print FILE "$checkout\n";
+}
+close(FILE);
+
+# use chroot as an additional safety measure when removing files
+chroot($destination) or error("Couldn't chroot into $destination");
+chdir('/');
+
+# iterate through old checkouts, remove obsolete files
+foreach my $checkout (sort keys %old_checkouts)
+{
+ if (!$new_checkouts{$checkout})
+ {
+ if (-f $checkout)
+ {
+ print " Delete $checkout\n";
+ unlink($checkout) or warning("Couldn't delete $checkout");
+ }
+ }
+}
+
+# iterate through old checkouts, remove obsolete directories
+foreach my $checkout (sort keys %old_checkouts)
+{
+ if (!$new_checkouts{$checkout})
+ {
+ if (-d $checkout)
+ {
+ print " Delete $checkout\n";
+ rmdir($checkout) or warning("Couldn't delete $checkout");
+ }
+ }
+}
+
+print "Finished successfully\n";
+
+# End of file
--- /dev/null
+#!/bin/sh
+#
+# /etc/rc.d/rsyncd: start/stop rsyncd daemon
+#
+
+SSD=/sbin/start-stop-daemon
+PROG=/usr/bin/rsync
+PID=/var/run/rsyncd.pid
+OPTS="--daemon"
+
+case $1 in
+start)
+ $SSD --start --pidfile $PID --exec $PROG -- $OPTS
+ ;;
+stop)
+ $SSD --stop --retry 10 --pidfile $PID
+ ;;
+restart)
+ $0 stop
+ $0 start
+ ;;
+status)
+ $SSD --status --pidfile $PID
+ case $? in
+ 0) echo "$PROG is running with pid $(cat $PID)" ;;
+ 1) echo "$PROG is not running but the pid file $PID exists" ;;
+ 3) echo "$PROG is not running" ;;
+ 4) echo "Unable to determine the program status" ;;
+ esac
+ ;;
+*)
+ echo "usage: $0 [start|stop|restart|status]"
+ ;;
+esac
+
+# End of file