From 57d5db7d4e42a29a9205ac101a2119bcdac8a03c Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 12 Apr 2009 12:37:04 +0200 Subject: Added support and tests for a package directory outside of /home --- bin/pkg | 8 ++++++-- test/main | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/bin/pkg b/bin/pkg index 9a5ef98..0263ae9 100755 --- a/bin/pkg +++ b/bin/pkg @@ -559,7 +559,11 @@ function populate_collected { if [[ -L $HOME/$i || ! -e $HOME/$i ]] { if [[ $(readlink $HOME/$i) != "../$1/$i" ]] { rm -f $HOME/$i - ln -s ../${PDIR//$HOME\/}/$1/$i $HOME/$i + if [[ $PDIR == ${HOME}* ]] { + ln -s ../${PDIR//$HOME\/}/$1/$i $HOME/$i + } else { + ln -s $PDIR/$1/$i $HOME/$i + } } } else { warn "populate_collected: Not updating ~/$i since it's not a symlink\n" @@ -586,7 +590,7 @@ function genocide_collected { } clear_line for i in bin/*(-*N); { - if [[ $(readlink $HOME/$i) = "../${PDIR//$HOME\/}/$1/$i" ]] { + if [[ $(readlink $HOME/$i) == (../${PDIR//$HOME\/}|$PDIR)/$1/$i ]] { rm -f $HOME/$i } } diff --git a/test/main b/test/main index 62bc7b6..ada8709 100755 --- a/test/main +++ b/test/main @@ -43,6 +43,8 @@ echo "# checking for success" [[ -d $test_pdir/core ]] [[ -L $test_home/bin/pkg ]] [[ -L $test_home/bin/checklinks ]] +[[ -x $(readlink $test_home/bin/pkg) ]] +[[ -x $(readlink $test_home/bin/checklinks) ]] echo "# pkg list local" stringcmp "core" "$(pkg list)" @@ -70,6 +72,7 @@ echo "# pkg add (already installed)" echo "# populate_collected (~/bin)" [[ -L $test_home/bin/ra ]] +[[ -x $(readlink $test_home/bin/ra) ]] repeat 2 { echo "# pkg list" -- cgit v1.2.3