File-RdistByRsync

 view release on metacpan or  search on metacpan

RdistByRsync.pm  view on Meta::CPAN

# can make the string grow, but cannot add elements to
# any surrounding list (if there is one)
#

sub expand_val
{
	my ($val) = @_;
	#
	# \ is an escape character in rdist distfiles.  It can
	# escape $ and itself.   Presumably, other things too.
	# I'm not sure what the right behavior is.
	#
	my $nv = '';
	pos($val) = 0;
	while (pos($val) < length($val)) {
		(($val =~ /\G([^\\\$]*)/gc) || ($val =~ /\G\\(.)/gc))
			&& do { 
				$nv .= $1; 
				next; 
			};
		(($val =~ /\G\$(\w)/) || ($val =~ /\G\$\{(.+?)\}/)) 
			&& do { 
				$nv .= expand_var($1); 
				next; 
			};
		die "illegal variable expansion in $val";
	}
	return $nv;
}

#
# This is used for variables that occur inside strings
# rather than all by themselves in a list.
#

sub expand_var
{
	my ($var) = @_;
	if (defined $vars->{$var}) {
		my $r;
		for my $val (@{$vars->{$var}}) {
			$r .= expand_val($val);
		}
		return $r;
	} else {
		warn "no variable $var defined!";
		if (length($var) eq 1) {
			return "\$$var";
		} else {
			return "\${$var}";
		}
	}
}

my %host;

sub rdist
{
	my (@argv) = @_;

	local(@ARGV) = @argv;

	our(@hosts);
	our(%definitions);
	our(@rsync_options);
	our(@targets);
	our($cflag);

	local(@hosts);
	local(%definitions);
	local(@rsync_options);
	local(@targets);
	local($cflag);

	my $rdist_cmdline_grammar = <<'END';
		
		-f <distfile:if>	Use the specified distfile

		-c <files>... [<user>@]<host>:[<path>]	Interpret the rest of the aguments as a mini distfile
					{ 
						our($cflag);
						$cflag = {
							HOSTS => [ $user 
								? "$user\@$host" 
								: $host ],
							FILES => [ @files ],
							INSTALL => [
								{
									DESTINATION => $path,
									FLAGS => {},
								},
							],
						};
					}

		-P <rshcmd>		Use rshcmd instead of rsh for remote access

		-d <var>=<value>	Set the variable to the value
					[repeatable]
					{
						our(%definitions);
						$definitions{$var} = $value;
					}

		-h			Follow symbolic links

		-i			Ignore unresolved links

		-m <host>		Limit which meachines are updated
					[repeatable]
					{
						our(@hosts);
						push(@hosts, $host);
					}
		
		-n			Print the commands w/o executing them

		-q			Quite mode.

		-R			Remove extraneous files.



( run in 0.549 second using v1.01-cache-2.11-cpan-6aa56a78535 )