]> git.nbdom.net Git - nb.git/commitdiff
repo-dirs.conf
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 26 Aug 2016 10:09:06 +0000 (12:09 +0200)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 26 Aug 2016 10:09:06 +0000 (12:09 +0200)
bin/nb-repo-dirs
etc/repo-dirs.conf [new file with mode: 0644]

index 660f9fdb7de2763e4b7b4c614c480471aee5b85e..c4c006da894cc8e3dacc074d88988cb09ed51c23 100755 (executable)
@@ -10,25 +10,25 @@ use Cwd;
 use File::Basename;
 my $FILE_EXISTS = '.nb-install';
 
-my $debug = 0;
-($ARGV[0]||'') =~ /^--?(all|debug)$/ and $debug = 1 and shift @ARGV;
+my $NB_ROOT = dirname ( dirname ( File::Spec->rel2abs( Cwd::abs_path(__FILE__) ) ) );
+my $CONF = "$NB_ROOT/etc/repo-dirs.conf";
+my $DEBUG = 0;
+($ARGV[0]||'') =~ /^--?(all|debug)$/ and $DEBUG = 1 and shift @ARGV;
 
 my @DIRS = (
-       dirname ( dirname ( File::Spec->rel2abs( Cwd::abs_path(__FILE__) ) ) ),
-       '/opt/backup_servers',
-       '/{opt,home/www}/rent',
-       '/etc/puppet',
-       '/home/www/izideal',
-#      '/opt/*/.nb-install',
-#      '/home/*/.nb-install',
-#      '/home/www/*/.nb-install',
-#      '/home/*/Dev/*/.nb-install',
-#      '/usr/local/src/*/.nb-install',
-       "/{opt,opt/www,home,home/www,usr/local/src,home/*/Dev,home/share/git}/*/$FILE_EXISTS",
+  $NB_ROOT,
 );
 
+if (-r $CONF) {
+  open(CONF,$CONF) or die "$0: can't read $CONF: $!";
+  while (<CONF>) {
+    chomp $_;
+    push @DIRS,$_ unless /^\s*(#|$)/;
+  }
+  close CONF;
+}
 
-#print map {"$_\n"} add_args(@DIRS) and exit 0 if $debug;
+#print map {"$_\n"} add_args(@DIRS) and exit 0 if $DEBUG;
 
 my %h;
 print
@@ -37,15 +37,14 @@ print
        map {
 
     # To reduce glob return, we permit to use file
-               #my $dir = /\/\Q$FILE_EXISTS\E$/ ? dirname($_) : $_;
                my $dir = !-d  $_ ? dirname($_) : $_;
 
                if (-d "$dir/.git") {
-      warn "DEBUG: MISSING: $dir/$FILE_EXISTS\n" if $debug and !-r "$dir/$FILE_EXISTS";
+      warn "DEBUG: MISSING: $dir/$FILE_EXISTS\n" if $DEBUG and !-r "$dir/$FILE_EXISTS";
       add_args($dir);
                        #$dir;
                } else {
-      warn "DEBUG: REJECT : $dir\n" if $debug;
+      warn "DEBUG: REJECT : $dir\n" if $DEBUG;
                        "";
                }
 
@@ -60,10 +59,10 @@ sub add_args {
   for my $d (@_) {
        #for my $d (glob join(' ',@_)) {
   #for my $d (map { glob $_ } @_) {
-      #warn ".. $d" if $debug;
+      #warn ".. $d" if $DEBUG;
     for my $a (@ARGV) {
       #warn "$d/$a";
-      #warn ".. $d/$a" if $debug;
+      #warn ".. $d/$a" if $DEBUG;
       push @new, glob "$d/$a";
     }
   }
diff --git a/etc/repo-dirs.conf b/etc/repo-dirs.conf
new file mode 100644 (file)
index 0000000..1f8dd49
--- /dev/null
@@ -0,0 +1,11 @@
+/opt/backup_servers
+/{opt,home/www}/rent
+/etc/puppet
+/home/www/izideal
+#      /opt/*/.nb-install
+#      /home/*/.nb-install
+#      /home/www/*/.nb-install
+#      /home/*/Dev/*/.nb-install
+#      /usr/local/src/*/.nb-install
+/{opt,opt/www,home,home/www,usr/local/src,home/*/Dev,home/share/git}/*/.nb-install
+