Skip to content

Commit

Permalink
Fix bashlets install.
Browse files Browse the repository at this point in the history
  • Loading branch information
Roberto Reale committed Mar 2, 2018
1 parent 071a4e5 commit 07d6474
Showing 1 changed file with 12 additions and 32 deletions.
44 changes: 12 additions & 32 deletions bin/bashlets-install
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,11 @@
BASHLETS_BASE=~/.bashlets
BASHLETS_REMOTE_CORE=https://github.com/bashlets
BASHLETS_REMOTE_PACKAGES=https://github.com/bashlets
BASHLETS_LOADER_1ST_STAGE_DESTINATIONS=~/.local/bin:/usr/local/bin
BASHLETS_BIN_TARGETS=~/.local/bin:/usr/local/bin

# which Git branch are we interested in?
branch=master

# are we installing the core library?
unset is_core_library

# install the first stage loader
unset install_1st_stage_loader

Expand Down Expand Up @@ -129,7 +126,8 @@ trap cleanup EXIT

function install_local()
{
local module="${1:-core}"
local repo_name
local module
local path
local rev
local destinations
Expand All @@ -147,20 +145,16 @@ function install_local()
# save the name of the repository
repo_name=$(basename $(git rev-parse --show-toplevel))

# extract the module name from the repository name
module=${repo_name#bashlets.}
[[ $module == bashlets ]] && module=core

# calculate install base folder
install_base="$BASHLETS_BASE/$(tr . / <<<$module)"

# save the current branch, in case we need to switch branch
current_branch=$(git rev-parse --abbrev-ref HEAD)

# the user can only ask for installation of the first-stage loader if this is
# the core library
# [[ -z $is_core_library && -n $install_1st_stage_loader ]] && {
# echo "ERROR: installing the first-stage loader is only possible for the core library!" >&2
# exit 1
# }


#
# determine (and create it if needed) the installation folder
################################################################################
Expand Down Expand Up @@ -195,11 +189,7 @@ function install_local()
# export the codebase into the installation folder
for path in lib bin
do
git archive $rev $path | tar -x -C "$install_path" || {
# echo "ERROR: could not install the first-stage loader!" >&2 XXX
#exit 1
:
}
(git archive $rev $path | tar -x -C "$install_path") 2> /dev/null
done

# if required set the current installation as the default one
Expand All @@ -212,31 +202,21 @@ function install_local()
# install the first-stage loader if needed
################################################################################

unset _1st_stage_loader_installed

local d f

# cycle possible destinations to install the 1st stage loader
IFS=: read -r -a destinations <<< "$BASHLETS_LOADER_1ST_STAGE_DESTINATIONS"
IFS=: read -r -a destinations <<< "$BASHLETS_BIN_TARGETS"
for d in ${destinations[@]}
do
[[ -d $install_path/bin ]] || continue
for f in $(ls $install_path/bin)
do
#_1st_stage_loader="$d/bashlet"

# if the loader does already exist AND the user did not require
# anything, we are done
#[[ -e $file_name && -z $install_1st_stage_loader ]] && break

{
# try and create the directory
mkdir -p "$d"
# install the 1st stage loader
cp -p $install_path/bin/$f $d

ln -fs $(readlink -m $install_path/bin/$f) $d

# we are done
#_1st_stage_loader_installed=1
#break
} 2> /dev/null || continue
done

Expand Down

0 comments on commit 07d6474

Please sign in to comment.