15 sa [options] [status|update|checkout] [directories to sync]
18 --quick, -Q don't update external projects
19 --verbose, -v be more verbose
21 --debug, -d debugging level (Default 0)
22 --help, -h display this help
23 --man, -m display manual
31 Debug verbosity. (Default 0)
35 Display brief useage information.
51 use vars qw($DEBUG $VERBOSE);
53 my %options = (quick => 1,
61 GetOptions(\%options,'quick|Q+','quiet|q!','debug|d+','help|h|?','man|m','verbose|v+');
63 pod2usage() if $options{help};
64 pod2usage({verbose=>2}) if $options{man};
66 # parse configuration file
70 Reads configuration information from Start by parsing /etc/sa.conf,
71 then the contents of ~/sa.d/ which match ^[\w\d][\w\d_.-]+$
73 The configuration file contains a list of svn repositories which
74 should be queried; each line can contain a tab, which indicates that
75 the command following the tab should be run after the svn directory is
78 The configuration files are read in the order given above.
82 sub parse_config_file {
83 my ($repos,$filename,$home) = @_;
84 return unless -e $filename and -r _;
85 my $fh = new IO::File $filename, 'r' or die "Unable to read configuration file $filename $!";
89 my ($repo,$command) = split /\t/,$_,2;
90 $repo =~ s/^\~/$home/;
91 $$repos{$repo} = $command;
96 my $HOSTNAME=qx(hostname);
98 my $CAN_IGNORE_EXTERNALS = 0;
99 qx(svn --version) =~ /\(r(\d+)\)/;
101 $CAN_IGNORE_EXTERNALS = 1;
104 sub available_config_files{
106 opendir($dir, "$HOME/.sa.d/") or return ();
107 return map {"$HOME/.sa.d/$_"} grep /^[\w\d][\w\d_.-]+$/, readdir $dir;
111 for ('/etc/sa.conf', available_config_files()) {
113 parse_config_file(\%repos,$_,$HOME);
117 $DEBUG = $options{debug};
118 $VERBOSE = $options{verbose};
122 if (@ARGV and $ARGV[0] =~ /^(st(?:atus)?|up(?:date)?|checkout)$/) {
129 while (my ($repo,$run_after) = each(%repos)) {
130 if (-e "$repo/.svn") {
131 print "Checking [$repo]\n";
134 (not $VERBOSE and $options{quiet})?'-q':(),
135 ($VERBOSE >= 2)?'-v':(),
136 ($options{quick} and $CAN_IGNORE_EXTERNALS)?'--ignore-externals':(),
137 $options{quick}>1?'-N':(),
141 if ($command =~ /^up(?:date)|checkout$/) {
142 system('sh', '-c',"$run_after $repo") if defined $run_after and length $run_after;