Skip to content

Commit

Permalink
Speaking of S&M, this commit was... tedious.
Browse files Browse the repository at this point in the history
  • Loading branch information
wayneeseguin committed Aug 14, 2011
1 parent 370edb1 commit ac1c775
Show file tree
Hide file tree
Showing 55 changed files with 334 additions and 353 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Expand Up @@ -16,6 +16,6 @@ limitations under the License.

= License Exceptions

bin/bdsm-ll is GNU parallel (http://www.gnu.org/s/parallel/) and is licensed
bin/sm-ll is GNU parallel (http://www.gnu.org/s/parallel/) and is licensed
under the GPLv3. See LICENSE.gplv3 for a copy of the GNU parallel license.

8 changes: 2 additions & 6 deletions ROADMAP.md
Expand Up @@ -15,13 +15,9 @@ Features Roadmap
* API for publishing extensions.
* Interface for browsing published extensions.

## Package (pkg) extension and module
* Package activation and deactivation.
$ bdsm pkg {activate/deactivate} {package}

## Service (srv) extension and module
## Service (svc) extension and module
* Overridable start/stop/restart/status actions, à la package_install.
* Init scripts.
* Activate/deactivate -- autostart on boot.
$ bdsm srv {activate/deactivate} {service}
$ sm svc {activate/deactivate} {service}

6 changes: 3 additions & 3 deletions bin/bdsm → bin/sm
Expand Up @@ -20,9 +20,9 @@
initial_pwd="$PWD"

# set BDSM basic paths
bdsm_path="/usr/local/bdsm"
modules_path="${bdsm_path}/core/bdsm/modules"
export initial_pwd bdsm_path modules_path
sm_path="/usr/local/sm"
modules_path="${sm_path}/core/sm/modules"
export initial_pwd sm_path modules_path

# basic options parsing
. "${modules_path}/shell/core/cli"
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions bin/smp
Expand Up @@ -18,7 +18,7 @@ os_cpu_count()
printf "%d" ${_cpu_count}
}

bdsm-parallel()
sm-parallel()
{
local _before=() _current _sequential _sequence _parallel

Expand All @@ -44,17 +44,17 @@ bdsm-parallel()
_parallel=( ${_sequence//\// } )
if (( ${#_parallel[@]} > 1 ))
then
bdsm-ll --noswap -j $(os_cpu_count) bdsm "${_before[@]}" {} "$@" ::: ${_parallel[@]}
sm-ll --noswap -j $(os_cpu_count) sm "${_before[@]}" {} "$@" ::: ${_parallel[@]}
else
bdsm "${_before[@]}" ${_parallel} "$@"
sm "${_before[@]}" ${_parallel} "$@"
fi
done
}

case "$*" in
*/*|*,*)
bdsm-parallel "$@"
sm-parallel "$@"
;;
*)
bdsm "$@"
sm "$@"
esac
2 changes: 1 addition & 1 deletion core/bdsm/config/defaults
Expand Up @@ -4,7 +4,7 @@ latest_version_url=https://bdsm.beginrescueend.com/releases/latest-version.txt
extensions_url=https://extensions.beginrescueend.com
extensions_repository_url=git://github.com/wayneeseguin/bdsm-extensions
service_url=https://bdsm.beginrescueend.com/services
bdsm_repo_url=git://github.com/wayneeseguin/bdsm
sm_repo_url=git://github.com/wayneeseguin/bdsm
service_repo_url=git://github.com/wayneeseguin/bdsm-services
website_url=https://bdsm.beginrescueend.com/
#pkg
Expand Down
8 changes: 4 additions & 4 deletions core/bdsm/modules/shell/core/cli
Expand Up @@ -73,9 +73,9 @@ do
printf "ERROR: unknown flag: '${token}'.\n"
;;
*)
if [[ -f "$token" && -z "$bdsm_script" ]]
if [[ -f "$token" && -z "$sm_script" ]]
then
bdsm_script=$1
sm_script=$1
else
extension_args=("$@")
break
Expand All @@ -90,7 +90,7 @@ then
extension_args=()
fi

PS4="# \${BASH_SOURCE##\${bdsm_path}\/} \${FUNCNAME[0]:+\${FUNCNAME[0]}()} \${LINENO} $ "
PS4="# \${BASH_SOURCE##\${sm_path}\/} \${FUNCNAME[0]:+\${FUNCNAME[0]}()} \${LINENO} $ "
export PS4

if [[ " ${trace_flags} " =~ " all " ]]
Expand All @@ -102,4 +102,4 @@ fi
debug_flags="${debug_flags## }"
trace_flags="${trace_flags## }"

export debug_flag debug_flags trace_flag trace_flags extension_args bdsm_script var_debug_flags var_debug_type_flag
export debug_flag debug_flags trace_flag trace_flags extension_args sm_script var_debug_flags var_debug_type_flag
35 changes: 17 additions & 18 deletions core/bdsm/modules/shell/core/dsl
@@ -1,9 +1,9 @@
#!/usr/bin/env bash

#
# ## bdsm_exports()
# ## sm_exports()
#
# Exports bdsm framework relevant environment variables for extension action
# Exports relevant framework environment variables for extension action
# processes.
#
# ### Input Parameters
Expand All @@ -24,17 +24,17 @@
#
# ### Usage Examples
#
# user$ bdsm_exports
# user$ sm_exports
#
bdsm_exports()
sm_exports()
{ # TODO: Filter this list of exports down.
export action archives_path bdsm_path branch config_path database database_name debug_flag environment error_message extension extension_action extension_args extension_actions_path extension_config_path extension_modules_path extension_path extension_templates_path flags framework head_flag hooks_flag keep_releases modules_path old_releases parse_break paths prefix_path previous_path project project_path release_path remote repository result revision shared_path src_path templates_path timestamp tmp_path trace_flag user extension_log_path packages_path
export action archives_path sm_path branch config_path database database_name debug_flag environment error_message extension extension_action extension_args extension_actions_path extension_config_path extension_modules_path extension_path extension_templates_path flags framework head_flag hooks_flag keep_releases modules_path old_releases parse_break paths prefix_path previous_path project project_path release_path remote repository result revision shared_path src_path templates_path timestamp tmp_path trace_flag user extension_log_path packages_path
}

#
# ## bdsm_version()
# ## sm_version()
#
# Reads the currently installed bdsm version into the variable 'bdsm_version'.
# Reads the currently installed sm version into the variable 'sm_version'.
#
# ### Input Parameters
#
Expand All @@ -46,7 +46,7 @@ bdsm_exports()
#
# ### Environmental effects
#
# The variable 'bdsm_version' will be set after the function is executed.
# The variable 'sm_version' will be set after the function is executed.
#
# ### Return Codes
#
Expand All @@ -58,17 +58,17 @@ bdsm_exports()
#
# ### Usage Examples
#
# user$ bdsm_version
# user$ echo $bdsm_version
# user$ sm_version
# user$ echo $sm_version
# 69.69.69
#
bdsm_version()
sm_version()
{
if [[ -s "$bdsm_path/VERSION" ]]
if [[ -s "$sm_path/VERSION" ]]
then
read -r bdsm_version < "$bdsm_path/VERSION"
read -r sm_version < "$sm_path/VERSION"
else
bdsm_version="?.?.?"
sm_version="?.?.?"
fi
}

Expand Down Expand Up @@ -102,16 +102,15 @@ bdsm_version()
# ### Usage Examples
#
# user$ cat $HOME/test
# #!/usr/bin/env bash
# source "/usr/local/bdsm/extensions/builtin/core/modules/shell/core/initialize" # Load BDSM framework core.
# #!/usr/bin/env sm
# NIY
#
# user$ $HOME/test
# ERROR: This feature has not yet been implemented.
# Backtrace:
# Trace Line Function File
# 3. 262 fail() /usr/local/bdsm/extensions/builtin/core/modules/shell/logging/dsl
# 2. 5 NIY() /usr/local/bdsm/extensions/builtin/core/modules/shell/extensions/dsl
# 3. 262 fail() /usr/local/sm/extensions/builtin/core/modules/shell/logging/dsl
# 2. 5 NIY() /usr/local/sm/extensions/builtin/core/modules/shell/extensions/dsl
# 1. 5 main() /Users/wayneeseguin/test
# > modules/shell/logging/dsl fail() 263 $ exit 1
#
Expand Down
52 changes: 26 additions & 26 deletions core/bdsm/modules/shell/core/initialize
Expand Up @@ -2,10 +2,10 @@

shopt -s extglob # Extended globs must always be on for BDSM.

saved_bdsm_path="${bdsm_path:-/usr/local/bdsm}"
saved_sm_path="${sm_path:-/usr/local/sm}"

# Load System BDSM Configuration, if it exists.
for file in /etc/bdsmrc "$HOME/.bdsmrc"
for file in /etc/smrc "$HOME/.smrc"
do
if [[ -s "${file}" ]]
then
Expand All @@ -16,7 +16,7 @@ do
done
unset previous_preload_modules

bdsm_path="${saved_bdsm_path}"
sm_path="${saved_sm_path}"

if (( UID == 0 ))
then # FHS
Expand All @@ -27,35 +27,35 @@ then # FHS
"${profile_d_path:="/etc/profile.d"}"
else
true \
"${var_path:="${bdsm_path}/var"}" \
"${var_path:="${sm_path}/var"}" \
"${etc_path:="$HOME/.etc"}" \
"${profile_path:="$HOME/.profile"}" \
"${profile_d_path:="$HOME/.profile.d"}"
fi

true \
"${modules_path:="${bdsm_path}/core/bdsm/modules"}" \
"${templates_path:="${bdsm_path}/templates"}" \
"${src_path:="${bdsm_path}/src"}" \
"${md5_path:="${bdsm_path}/md5"}" \
"${archives_path:="${bdsm_path}/archives"}" \
"${scm_path:="${bdsm_path}/scm"}" \
"${extension_sets_path:="${bdsm_path}/sets"}" \
"${extension_exts_path:="${bdsm_path}/exts"}" \
"${modules_path:="${sm_path}/core/sm/modules"}" \
"${templates_path:="${sm_path}/templates"}" \
"${src_path:="${sm_path}/src"}" \
"${md5_path:="${sm_path}/md5"}" \
"${archives_path:="${sm_path}/archives"}" \
"${scm_path:="${sm_path}/scm"}" \
"${extension_sets_path:="${sm_path}/sets"}" \
"${extension_exts_path:="${sm_path}/exts"}" \
"${extensions_src_path:="${src_path}/extensions"}" \
"${tmp_path:="${bdsm_path}/tmp"}" \
"${bin_path:="${bdsm_path}/bin"}" \
"${repos_path:="${bdsm_path}/repos"}" \
"${tmp_path:="${sm_path}/tmp"}" \
"${bin_path:="${sm_path}/bin"}" \
"${repos_path:="${sm_path}/repos"}" \
"${remote:="origin"}" \
"${branch:="master"}" \
"${language:="shell"}" \
"${user:=$USER}" \
"${user_bdsm_path:=$HOME/.bdsm}" \
"${user_sm_path:=$HOME/.sm}" \
"${keep_releases:=4}" \
"${hooks_flag:=1}" \
"${PAGER:="less"}" \
"${config_path:="${bdsm_path}/core/bdsm/config"}" \
"${packages_path:="${bdsm_path}/pkg"}" \
"${config_path:="${sm_path}/core/sm/config"}" \
"${packages_path:="${sm_path}/pkg"}" \
"${active_path:="${packages_path}/active"}" \
"${extension_args:=""}"

Expand All @@ -75,7 +75,7 @@ then
then
extension_sets_home="${extension_sets_path}"
else
extension_sets_home="${user_bdsm_path}/sets"
extension_sets_home="${user_sm_path}/sets"
fi
fi

Expand All @@ -85,7 +85,7 @@ then
then
extension_exts_home="${extension_exts_path}"
else
extension_exts_home="${user_bdsm_path}/exts"
extension_exts_home="${user_sm_path}/exts"
fi
fi

Expand All @@ -97,7 +97,7 @@ then
export PATH="${active_path}/bin:${active_path}/sbin:${PATH}"
fi

export bdsm_path modules_path initial_pwd extension_action_calls=0
export sm_path modules_path initial_pwd extension_action_calls=0

# Load module() function, then load core modules.
source "${modules_path}/shell/core/dsl"
Expand All @@ -113,12 +113,12 @@ then # custom compilations + g*
fi

# Ensure that any variables you wish export to extensions actually *are* exported.
bdsm_exports
sm_exports

if [[ -n $bdsm_script ]]
if [[ -n $sm_script ]]
then
# load script
action_source $bdsm_script "${extension_args[@]}"
action_source $sm_script "${extension_args[@]}"
elif [[ -n "${call_action}" ]]
then
if ! declare -F "${call_action}" >/dev/null
Expand All @@ -138,8 +138,8 @@ then
for sequence in "${sequential[@]}"
do
parallel=("${sequence//\// }")
PATH="${bdsm_path}/bin:${PATH}"
bdsm-ll --noswap -j $(os_cpu_count) bdsm {} ${extension_args[*]} ::: ${parallel[@]}
PATH="${sm_path}/bin:${PATH}"
sm-ll --noswap -j $(os_cpu_count) sm {} ${extension_args[*]} ::: ${parallel[@]}
done
;;
*)
Expand Down
17 changes: 8 additions & 9 deletions core/bdsm/modules/shell/logging/dsl
Expand Up @@ -108,7 +108,7 @@ warn()
#
# ### Usage Examples
#
# The following appears when bdsm is called with --debug=[welcome|all],
# The following appears when sm is called with --debug=[welcome|all],
# or if you set debug_flags to welcome|all.
# Code:
#
Expand Down Expand Up @@ -175,7 +175,7 @@ debug()
# ### Usage Examples
#
# user$ ./install --debug=search help
# DEBUG search: module bdsm/help in builtin/bdsm/modules/shell/help.
# DEBUG search: module sm/help in builtin/sm/modules/shell/help.
#
core_log_search()
{
Expand Down Expand Up @@ -224,14 +224,14 @@ log_search()
# ### Usage Examples
#
# user$ ./install --debug=search help
# DEBUG search: module bdsm/help in builtin/bdsm/modules/shell/help.
# DEBUG search: module sm/help in builtin/sm/modules/shell/help.
#
core_log_todo()
{
if (( debug_flag == 1 )) && options_check "$debug_flags" "todo"
then
local file="${BASH_SOURCE[2]}" line="${BASH_LINENO[1]}"
printf "DEBUG todo: ${file##${bdsm_path}\/}:${line}:\n"
printf "DEBUG todo: ${file##${sm_path}\/}:${line}:\n"
printf "$*" | xargs -s 72 | xargs -I {} printf "DEBUG todo: # {}\n"
else
return 0
Expand Down Expand Up @@ -405,15 +405,15 @@ fail()
# '+ '
# user$ set_ps4
# user$ echo "'$PS4'"
# ' > ${BASH_SOURCE##${bdsm_path}\/} ${FUNCNAME[0]:+${FUNCNAME[0]}()} ${LINENO} $ '
# ' > ${BASH_SOURCE##${sm_path}\/} ${FUNCNAME[0]:+${FUNCNAME[0]}()} ${LINENO} $ '
#
# ### Code Walkthrough
set_ps4()
{
# Set and export the PS4 variable, so that this script -- and called bash scripts --
# will display more detailed and formatted trace output.
# Finally, return true, 0, for success.
PS4="# \${BASH_SOURCE##\${bdsm_path}\/} \${FUNCNAME[0]:+\${FUNCNAME[0]}()} \${LINENO} $ "
PS4="# \${BASH_SOURCE##\${sm_path}\/} \${FUNCNAME[0]:+\${FUNCNAME[0]}()} \${LINENO} $ "
export PS4
return 0
}
Expand Down Expand Up @@ -596,8 +596,7 @@ separator()
# ### Usage Examples
#
# user$ cat ./test
# #!/usr/bin/env bash
# source "/usr/local/bdsm/extensions/builtin/core/modules/shell/core/initialize" # Load BDSM framework core.
# #!/usr/bin/env sm
# modules trace # Load the trace module.
#
# functiona()
Expand Down Expand Up @@ -709,7 +708,7 @@ backtrace()
done

# Determine the format string output for the backtrace, based on your
# set editor. If you haven't set an editor, BDSM defaults the editor variable to
# set editor. If you haven't set an editor, SM defaults the editor variable to
# the pager, or to empty string.
case "${EDITOR:=${PAGER:-}}" in
(mvim*|mate*)
Expand Down

0 comments on commit ac1c775

Please sign in to comment.