]> git.donarmstrong.com Git - bin.git/blobdiff - sa
update sa with the new features for modular home directories
[bin.git] / sa
diff --git a/sa b/sa
index adb8b53fb34197a21c8f5f86fbb0fd19afac6efe..6cacfda6cfebffdf09e8090faefaae8dd5fec0d8 100755 (executable)
--- a/sa
+++ b/sa
@@ -16,6 +16,7 @@ sa [options] [status|update|checkout] [directories to sync]
 
  Options:
   --quick, -Q don't update external projects
+  --verbose, -v be more verbose
   --quiet, -q be quiet
   --debug, -d debugging level (Default 0)
   --help, -h display this help
@@ -47,16 +48,17 @@ Display this manual.
 
 use User;
 use IO::File;
-use vars qw($DEBUG);
+use vars qw($DEBUG $VERBOSE);
 
 my %options = (quick           => 1,
               quiet           => 1,
               debug           => 0,
               help            => 0,
               man             => 0,
+              verbose         => 0,
              );
 
-GetOptions(\%options,'quick|Q+','quiet|q!','debug|d+','help|h|?','man|m');
+GetOptions(\%options,'quick|Q+','quiet|q!','debug|d+','help|h|?','man|m','verbose|v+');
 
 pod2usage() if $options{help};
 pod2usage({verbose=>2}) if $options{man};
@@ -66,11 +68,11 @@ pod2usage({verbose=>2}) if $options{man};
 =head1 CONFIGURATION
 
 Reads configuration information from Start by parsing /etc/sa.conf,
-then ~/.sarc then ~/.sarc_$hostname, then ~/.sarc_local
+then the contents of ~/sa.d/ which match ^[\w\d][\w\d_.-]+$
 
 The configuration file contains a list of svn repositories which
 should be queried; each line can contain a tab, which indicates that
-the command following the tab should be run fater the svn directory is
+the command following the tab should be run after the svn directory is
 updated.
 
 The configuration files are read in the order given above.
@@ -90,7 +92,6 @@ sub parse_config_file {
      }
 }
 
-
 my $HOME=User->Home;
 my $HOSTNAME=qx(hostname);
 $HOSTNAME=~s/\n//g;
@@ -100,14 +101,21 @@ if ($1 > 13838) {
      $CAN_IGNORE_EXTERNALS = 1;
 }
 
+sub available_config_files{
+     my $dir;
+     opendir($dir, "$HOME/.sa.d/") or return ();
+     return map {"$HOME/.sa.d/$_"} grep /^[\w\d][\w\d_.-]+$/, readdir $dir;
+}
+
 my %repos;
-for ('/etc/sa.conf', "${HOME}/.sarc", "${HOME}/.sarc_${HOSTNAME}", "${HOME}/.sarc_local") {
+for ('/etc/sa.conf', available_config_files()) {
      if (-e $_) {
          parse_config_file(\%repos,$_,$HOME);
      }
 }
 
 $DEBUG = $options{debug};
+$VERBOSE = $options{verbose};
 
 my $command;
 
@@ -120,15 +128,17 @@ else {
 
 while (my ($repo,$run_after) = each(%repos)) {
      if (-e "$repo/.svn") {
+         print "Checking [$repo]\n";
          system('svn',
                 $command,
-                $options{quiet}?'-q':(),
+                (not $VERBOSE and $options{quiet})?'-q':(),
+                ($VERBOSE >= 2)?'-v':(),
                 ($options{quick} and $CAN_IGNORE_EXTERNALS)?'--ignore-externals':(),
                 $options{quick}>1?'-N':(),
                 $repo,
                );
      }
      if ($command =~ /^up(?:date)|checkout$/) {
-         system($run_after,$repo) if defined $run_after and length $run_after;
+         system('sh', '-c',"$run_after $repo") if defined $run_after and length $run_after;
      }
 }