Skip to content

Commit

Permalink
Refactoring sets install into wrapping set install.
Browse files Browse the repository at this point in the history
  • Loading branch information
wayneeseguin committed Aug 14, 2011
1 parent 3bc173d commit d1ea6f0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
48 changes: 23 additions & 25 deletions core/cli/modules/shell/sets/dsl
Original file line number Diff line number Diff line change
Expand Up @@ -66,36 +66,37 @@ sets_list_known()

sets_install()
{
local _name="${1:-}" _uri="${2:-}"
local _name _names="${1:-}" _uri="${2:-}"
shift || fail "$FUNCNAME: Cannot install a set; No set name was given."

shift || fail "name must be the first parameter to sets_install()."
_names=(${_names//,/ })

[[ "${_name}" != "builtin" ]] ||
error "builtin extension set may not be (re-)installed, except by updating BDSM core (bdsm get head)."
for _name in ${_names[@]}
do
log_step "bdsm-${_name}" set_install "${_name}" "${_uri}"
done
}

if [[ -n "${_uri}" ]]
then
shift
else
_uri=$( awk -F = "/^${_name}=/ {print \$2 }" < "${bdsm_path}/core/cli/config/known_sets" | tail -n 1 )
fi
set_install()
{
local _name="${1:-}"
shift || fail "$FUNCNAME: Cannot install a set; No set name was given."

[[ -n "${_uri}" ]] ||
error "Cannot find ${_name} in known extension sets list."
local _uri="${1:-}"
shift || _uri=$( awk -F = "/^${_name}=/ {print \$2 }" < "${bdsm_path}/core/cli/config/known_sets" | tail -n 1 )

local _identifier="$(scm_identifier "${_uri}")"

log_step "bdsm-${_name}"
[[ -n "${_uri}" ]] ||
error "$FUNCNAME: uri not given and cannot find ${_name} in known extension sets."

ensure_paths_exist "${extension_sets_home}"
enter "${extension_sets_home}"
if fetch_uri "${_uri}" "${src_path}/${_identifier}" "$@"
then
remove_paths "${_name}"
copy_directory "${src_path}/${_identifier}" to "${_name}"
log_step success
else
log_step failure
fi

fetch_uri "${_uri}" "${src_path}/${_identifier}" "$@" || return $?

remove_paths "${_name}"
copy_directory "${src_path}/${_identifier}" to "${_name}"
}

sets_install_all()
Expand Down Expand Up @@ -201,10 +202,7 @@ sets_uninstall()
fi
fi

#TODO: are you sure ?

log "Uninstalling extension set: ${_name}."
rm -rf "${_name}"
log_step "Uninstalling extension set: ${_name}." rm -rf "${_name}"
}

sets_check_availability()
Expand Down
2 changes: 1 addition & 1 deletion install
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ extension_exts_home="${bdsm_path}/exts"

export install_path prefix_path archives_path scm_path src_path extension_sets_home

./local --call=install/install_bdsm "$@"
"${PWD}/local" --call=install/install_bdsm "$@"
2 changes: 2 additions & 0 deletions local
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ initial_pwd="$PWD"
# Path to load everything from.
bdsm_path="$PWD"
modules_path="${bdsm_path}/core/bdsm/modules"

export initial_pwd bdsm_path modules_path

# Basic options parsing.
. "${modules_path}/shell/core/cli"

# Initialize BDSM.
. "${modules_path}/shell/core/initialize"

0 comments on commit d1ea6f0

Please sign in to comment.