From a9241c516e441e8adaa0299e36dc4b9f78676b7a Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Fri, 26 Aug 2016 12:09:06 +0200 Subject: [PATCH] repo-dirs.conf --- bin/nb-repo-dirs | 37 ++++++++++++++++++------------------- etc/repo-dirs.conf | 11 +++++++++++ 2 files changed, 29 insertions(+), 19 deletions(-) create mode 100644 etc/repo-dirs.conf diff --git a/bin/nb-repo-dirs b/bin/nb-repo-dirs index 660f9fdb..c4c006da 100755 --- a/bin/nb-repo-dirs +++ b/bin/nb-repo-dirs @@ -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 () { + 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 index 00000000..1f8dd499 --- /dev/null +++ b/etc/repo-dirs.conf @@ -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 + -- 2.47.3