From 82f59f31ceef20a262846fc1912de86b9d2df677 Mon Sep 17 00:00:00 2001 From: Mike Burns Date: Fri, 30 May 2014 16:53:57 +0200 Subject: Allow the user to override SYMLINK_DIRS with -s This adds a `-s` that can be used to override the `SYMLINK_DIRS` config, or the `-S` flag, to lsrc(1), mkrc(1), rcup(1), and rcdn(1). The `-s` flag is the opposite of -S: any argument, if it is a directory, is not symlinked but instead recurred down. --- bin/lsrc.in | 30 ++++++++++++++++++++---------- bin/mkrc.in | 7 ++++++- bin/rcdn.in | 7 ++++++- bin/rcup.in | 7 ++++++- 4 files changed, 38 insertions(+), 13 deletions(-) (limited to 'bin') diff --git a/bin/lsrc.in b/bin/lsrc.in index ec900a2..db5dcd0 100755 --- a/bin/lsrc.in +++ b/bin/lsrc.in @@ -54,9 +54,10 @@ show_dir() { local exclude_file_globs="$6" local include_file_globs="$7" local symlink_dirs_file_globs="$8" + local mk_dirs_file_globs="$9" local dest_path="$(build_path "$dest_dir" "$dir" $dotted)" - $DEBUG "show_dir $1 $2 $3 $4 $5 $6 $7 $8" + $DEBUG "show_dir $1 $2 $3 $4 $5 $6 $7 $8 $9" $VERBOSE "recurring on $dest_path" @@ -64,7 +65,7 @@ show_dir() { for f in *; do $DEBUG "handling the file $f" next_dir="$(file_join "$dotfiles_subdir" "$dir")" - handle_file "$f" "$dest_path" "$dotfiles_dir" "$next_dir" 1 "$exclude_file_globs" "$include_file_globs" "$symlink_dirs_file_globs" + handle_file "$f" "$dest_path" "$dotfiles_dir" "$next_dir" 1 "$exclude_file_globs" "$include_file_globs" "$symlink_dirs_file_globs" "$mk_dirs_file_globs" done popdir } @@ -134,17 +135,18 @@ handle_file() { local exclude_file_globs="$6" local include_file_globs="$7" local symlink_dirs_file_globs="$8" + local mk_dirs_file_globs="$9" - $DEBUG "handle_file $1 $2 $3 $4 $5 $6 $7 $8" + $DEBUG "handle_file $1 $2 $3 $4 $5 $6 $7 $8" "$9" if [ ! -e "$file" ]; then $VERBOSE "skipping non-existent file $file" elif is_excluded "$file" "$exclude_file_globs" "$include_file_globs"; then $VERBOSE "skipping excluded file $file" - elif [ -d "$file" ] && is_excluded $file "$symlink_dirs_file_globs"; then - show_file "$file" "$dest_dir" "$dotfiles_dir" "$dotfiles_subdir" $dotted "$symlink_dirs_file_globs" + elif [ -d "$file" ] && is_excluded "$file" "$symlink_dirs_file_globs" "$mk_dirs_file_globs"; then + show_file "$file" "$dest_dir" "$dotfiles_dir" "$dotfiles_subdir" $dotted elif [ -d "$file" ]; then - show_dir "$file" "$dest_dir" "$dotfiles_dir" "$dotfiles_subdir" $dotted "$exclude_file_globs" "$include_file_globs" "$symlink_dirs_file_globs" + show_dir "$file" "$dest_dir" "$dotfiles_dir" "$dotfiles_subdir" $dotted "$exclude_file_globs" "$include_file_globs" "$symlink_dirs_file_globs" "$mk_dirs_file_globs" else show_file "$file" "$dest_dir" "$dotfiles_dir" "$dotfiles_subdir" $dotted fi @@ -227,9 +229,10 @@ handle_command_line() { local excludes= local includes= local symlink_dirs= + local never_symlink_dirs= local hostname= - while getopts :FVqvhI:x:B:S:t:d: opt; do + while getopts :FVqvhI:x:B:S:s:t:d: opt; do case "$opt" in F) show_sigils=1;; h) show_help ;; @@ -241,6 +244,7 @@ handle_command_line() { V) version=1;; x) excludes="$excludes $OPTARG";; S) symlink_dirs="$symlink_dirs $OPTARG";; + s) never_symlink_dirs="$never_symlink_dirs $OPTARG";; B) hostname="$OPTARG";; ?) show_help 64 ;; esac @@ -255,6 +259,7 @@ handle_command_line() { EXCLUDES="${excludes:-$EXCLUDES}" INCLUDES="${includes:-$INCLUDES}" SYMLINK_DIRS="${symlink_dirs:-$SYMLINK_DIRS}" + MK_DIRS="${never_symlink_dirs:-$MK_DIRS}" FILES="$@" $DEBUG "TAGS: $TAGS" @@ -274,6 +279,9 @@ $DEBUG "COPY_ALWAYS: $COPY_ALWAYS" : ${SYMLINK_DIRS:=""} $DEBUG "SYMLINK_DIRS: $SYMLINK_DIRS" +: ${MK_DIRS:=""} +$DEBUG "MK_DIRS: $MK_DIRS" + relative_root_dir="$PWD" for DOTFILES_DIR in $DOTFILES_DIRS; do @@ -293,6 +301,8 @@ for DOTFILES_DIR in $DOTFILES_DIRS; do include_file_globs="$(dotfiles_dir_excludes "$DOTFILES_DIR" "$INCLUDES")" symlink_dirs_file_globs="$(dotfiles_dir_excludes "$DOTFILES_DIR" "$SYMLINK_DIRS")" $DEBUG "symlink_dirs_file_globs: $symlink_dirs_file_globs" + mk_dirs_file_globs=$(dotfiles_dir_excludes "$DOTFILES_DIR" "$MK_DIRS") + $DEBUG "mk_dirs_file_globs: $mk_dirs_file_globs" cd "$DOTFILES_DIR" DIR_STACK=":$DOTFILES_DIR" @@ -302,7 +312,7 @@ for DOTFILES_DIR in $DOTFILES_DIRS; do continue fi - handle_file "$file" "$DEST_DIR" "$DOTFILES_DIR" . 0 "$exclude_file_globs" "$include_file_globs" "$symlink_dirs_file_globs" + handle_file "$file" "$DEST_DIR" "$DOTFILES_DIR" . 0 "$exclude_file_globs" "$include_file_globs" "$symlink_dirs_file_globs" "$mk_dirs_file_globs" done cd "$DOTFILES_DIR" @@ -311,7 +321,7 @@ for DOTFILES_DIR in $DOTFILES_DIRS; do if [ -d "$host_files" ]; then pushdir "$(basename "$host_files")" for file in ${FILES:-*}; do - handle_file "$file" "$DEST_DIR" "$host_files" . 0 "$exclude_file_globs" "$include_file_globs" "$symlink_dirs_file_globs" + handle_file "$file" "$DEST_DIR" "$host_files" . 0 "$exclude_file_globs" "$include_file_globs" "$symlink_dirs_file_globs" "$mk_dirs_file_globs" done popdir fi @@ -323,7 +333,7 @@ for DOTFILES_DIR in $DOTFILES_DIRS; do pushdir "$(basename "tag-$tag")" for file in ${FILES:-*}; do $DEBUG "TAG: $tag, exclude_file_globs: $exclude_file_globs" - handle_file "$file" "$DEST_DIR" "$DOTFILES_DIR/tag-$tag" . 0 "$exclude_file_globs" "$include_file_globs" "$symlink_dirs_file_globs" + handle_file "$file" "$DEST_DIR" "$DOTFILES_DIR/tag-$tag" . 0 "$exclude_file_globs" "$include_file_globs" "$symlink_dirs_file_globs" "$mk_dirs_file_globs" done popdir fi diff --git a/bin/mkrc.in b/bin/mkrc.in index 6545e55..55a7cd8 100755 --- a/bin/mkrc.in +++ b/bin/mkrc.in @@ -43,7 +43,7 @@ verbosity=0 in_host=0 version=0 always_copy=0 -force_symlink=0 +force_symlink=50 install_args= while getopts :ChSsVvqot:d:B: opt; do @@ -86,6 +86,11 @@ if [ $force_symlink -eq 1 ]; then dedotted="$(de_dot "$file")" INSTALL="$INSTALL -S $dedotted" done +elif [ $force_symlink -eq 0 ]; then + for file in $files; do + dedotted="$(de_dot "$file")" + INSTALL="$INSTALL -s $dedotted" + done fi for file in $files; do diff --git a/bin/rcdn.in b/bin/rcdn.in index 1179b97..e5cb119 100755 --- a/bin/rcdn.in +++ b/bin/rcdn.in @@ -37,9 +37,10 @@ handle_command_line() { local excludes= local includes= local symlink_dirs= + local never_symlink_dirs= local hostname= - while getopts :VqvhI:x:S:t:d:B: opt; do + while getopts :VqvhI:x:S:s:t:d:B: opt; do case "$opt" in h) show_help ;; B) hostname="$OPTARG" ;; @@ -48,6 +49,7 @@ handle_command_line() { K) run_hooks=0 ;; t) arg_tags="$arg_tags $OPTARG" ;; S) symlink_dirs="$symlink_dirs $OPTARG";; + s) never_symlink_dirs="$never_symlink_dirs $OPTARG";; v) verbosity=$(($verbosity + 1));; q) verbosity=$(($verbosity - 1));; d) dotfiles_dirs="$dotfiles_dirs $OPTARG" ;; @@ -81,6 +83,9 @@ handle_command_line() { for symlink_dir in $symlink_dirs; do LS_ARGS="$LS_ARGS -S $symlink_dir" done + for never_symlink_dir in $symlink_dirs; do + LS_ARGS="$LS_ARGS -s $never_symlink_dir" + done LS_ARGS="$LS_ARGS -B $hostname $files" $DEBUG "LS_ARGS: $LS_ARGS" diff --git a/bin/rcup.in b/bin/rcup.in index 24d7177..1823099 100755 --- a/bin/rcup.in +++ b/bin/rcup.in @@ -104,10 +104,11 @@ handle_command_line() { local includes= local always_copy=0 local symlink_dirs= + local never_symlink_dirs= local hostname= REPLACE_ALL=0 - while getopts :CVqvfhikKI:x:S:t:d:B: opt; do + while getopts :CVqvfhikKI:x:S:s:t:d:B: opt; do case "$opt" in B) hostname="$OPTARG" ;; C) always_copy=1 ;; @@ -121,6 +122,7 @@ handle_command_line() { q) verbosity=$(($verbosity - 1)) ;; t) arg_tags="$arg_tags $OPTARG" ;; S) symlink_dirs="$symlink_dirs $OPTARG";; + s) never_symlink_dirs="$never_symlink_dirs $OPTARG";; v) verbosity=$(($verbosity + 1)) ;; V) version=1 ;; x) excludes="$excludes $OPTARG" ;; @@ -157,6 +159,9 @@ handle_command_line() { for symlink_dir in $symlink_dirs; do LS_ARGS="$LS_ARGS -S $symlink_dir" done + for never_symlink_dir in $never_symlink_dirs; do + LS_ARGS="$LS_ARGS -s $never_symlink_dir" + done LS_ARGS="$LS_ARGS -B $hostname $files" $DEBUG "LS_ARGS: $LS_ARGS" -- cgit v1.2.3