Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

More work on package api, currently working out spacing in actions map.

See core/api/shell/package/actions for examples.
  • Loading branch information...
commit 3fd1d6c7b8f10b3d76fef048103c76dfef24daaf 1 parent 91b4e9d
Wayne E. Seguin wayneeseguin authored
2  core/api/shell/database/functions
View
@@ -16,7 +16,7 @@ api_database_initialize()
true "${data_path:="${data_base_path}/${package_version}"}"
}
-database_cli()
+__sm.database.cli()
{
local _ignored_args=() args_count=${#extension_args[@]}
24 core/api/shell/package/actions
View
@@ -1,17 +1,17 @@
-package/install=package_install()
-install=package_install()
+package/install=package install()
+install=package install()
-package/uninstall=package_uninstall()
-uninstall=package_uninstall()
+package/uninstall=package uninstall()
+uninstall=package uninstall()
-package/update=package_update()
-update=package_update()
+package/update=package update()
+update=package update()
-package/info=package_info()
-info=package_info()
+package/info=package info()
+info=package info()
-package/activate=package_activate()
-activate=package_activate()
+package/activate=package activate()
+activate=package activate()
-package/man=package_man()
-man=package_man()
+package/man=package man()
+man=package man()
943 core/api/shell/package/functions
View
@@ -1,7 +1,42 @@
#!/bin/sh
# TODO: Rework this into a 1.0.0 module API
-
+#
+# ## package install
+#
+# Performs all package installation steps based on selected strategy:
+# preinstall
+#
+# if gnu:
+# prefetch
+# fetch
+# preextract
+# extract
+# prepatch
+# patch
+# preconfigure
+# configure
+# prebuild
+# build
+# preinstall
+# install
+# preactivate
+# activate
+# service setup, if service module is loaded
+#
+# if binary:
+# prefetch
+# fetch
+# preextract
+# extract
+# preinstall
+# install
+# preactivate
+# activate
+# service setup, if service module is loaded
+#
+# postinstall
+#
package()
{
local _token _command _logfile _lines=50 _params=()
@@ -51,6 +86,16 @@ package()
done
case "${_command}" in
+ (install|uninstall)
+ case "${package_strategy:=gnu}" in
+ (gnu|binary|java)
+ __sm.package.${package_strategy}.${_command}
+ ;;
+ *)
+ fail "Unknown package strategy ${package_strategy}"
+ ;;
+ esac
+ ;;
(configure)
case "${_subcommand}" in
(flag)
@@ -60,7 +105,7 @@ package()
__sm.package.configure.flags "${_params[@]}"
;;
(*)
- package_configure
+ __sm.package.configure
;;
esac
;;
@@ -82,902 +127,10 @@ package()
__sm.package.error "${_params[@]}" "${_log}" "${_lines}"
;;
(cli)
- package_cli
+ __sm.package.cli "${_params[@]}"
;;
(*)
fail "Unknown package command '${_token}'"
esac
}
-package_cli()
-{
- local _ignored_args=() _package_args=( $@ ) _token
- local number_of_args=${#_package_args[@]} index
-
- for (( index=0 ; index < $number_of_args ; index++ ))
- do
- _token="${_package_args[$index]}"
- case "${_token}" in
- prefix)
- packages_path="${_package_args[$((++index))]}"
- [[ -n "${packages_path}" ]] ||
- error "a path must follow keyword 'prefix'"
- ;;
- src)
- src_path="${_package_args[$((++index))]}"
- [[ -n "${src_path}" ]] ||
- error "a path must follow keyword 'src'"
- ;;
- data)
- data_path="${_package_args[$((++index))]}"
- [[ -n "${data_path}" ]] ||
- error "a path must follow keyword 'data'"
- ;;
- user)
- package_user="${_package_args[$((++index))]}"
- [[ -n "${package_user}" ]] ||
- error "a user name must follow keyword 'user'"
- ;;
- version)
- package_version="${_package_args[$((++index))]}"
- [[ -n "${package_version}" ]] ||
- error "a version number string must follow keyword 'version'"
- ;;
- base_url)
- package_base_url="${_package_args[$((++index))]}"
- [[ -n "${package_base_url}" ]] ||
- error "a base path url must follow keyword 'base_url'"
- ;;
- file)
- package_file="${_package_args[$((++index))]}"
- [[ -n "${package_file}" ]] ||
- error "a path must follow keyword 'file'"
- ;;
- dir)
- package_directory="${_package_args[$((++index))]}"
- [[ -n "${package_directory}" ]] ||
- error "a single extracted directory name must follow keyword 'dir'"
- ;;
- archive_format)
- archive_format="${_package_args[$((++index))]}"
- [[ -n "${archive_format}" ]] ||
- error "an archive format (tar.gz,tar.bz2,tar.xz,zip,...) must follow keyword 'archive_format'"
- ;;
- md5)
- package_md5="${_package_args[$((++index))]}"
- [[ -n "${package_md5}" ]] ||
- error "an md5 sum string must follow keyword 'md5'"
- ;;
- force)
- force_flag=1
- ;;
- static)
- static_flag=1
- __sm.package.configure.flags --static
- ;;
- shared)
- shared_flag=1
- __sm.package.configure.flags --enable-shared
- ;;
- licence)
- extension_license
- succeed
- ;;
- help)
- package_usage
- succeed
- ;;
- --with*|--enable*|--disable*)
- __sm.package.configure.flags "${_token}"
- ;;
- *)
- _ignored_args+=("${_token}")
- ;;
- esac
-
- done
-
- package_init "${_ignored_args[@]}"
-}
-
-package_init()
-{
- package_name="${1:-${package_name:-${extension}}}"
-
- [[ -n "${package_name}" ]] || fail "Package name must be given.\n"
-
- case "${package_name}" in
- *=*) # exact version specifier
- package_version="${package_name#*=}"
- package_name="${package_name%%=*}"
- ;;
- *:*) # minimum version specifier
- # TODO: concept of 'minimum' ;)
- package_version="${package_name#*:}"
- package_name="${package_name%%:*}"
- ;;
- *)
- true "${package_version:="${2:-}"}" "${archive_format:="${3:-}"}"
- ;;
- esac
-
- if command exists "${package_name}_initialize"
- then
- __sm.string.contains "${package_name}_initialize" "${FUNCNAME[*]}" ||
- "${package_name}_initialize"
- fi
-
- true \
- "${source_path:="${sm_path}/src"}" \
- "${archives_path:="${sm_path}/archives"}" \
- ${static_flag:=0}
-
- case "${package_strategy:-gnu}" in
- gnu)
- __sm.package.set.cflags
- __sm.package.set.ldflags
-
- if os is darwin && [[ -x /usr/bin/gcc-4.2 ]]
- then
- export CC=/usr/bin/gcc-4.2
- fi
- ;;
- *)
- fail "Unknown strategy ${package_strategy}"
- ;;
- esac
-
- export package_name packages_path package_name package_version archive_format \
- package_file package_url package_md5_url packages_path bin_path source_path \
- LDFLAGS CFLAGS package_default_version
- # Ensure that package_version is set at this point
-
- [[ -n "${package_default_version}" ]] || read_default version prefix package_default for ${package_name}
- [[ -n "${package_base_url}" ]] || read_default base_url prefix package for ${package_name}
- [[ -n "${package_md5_url}" ]] || read_default md5_url prefix package for ${package_name}
- [[ -n "${package_user}" ]] || read_default user prefix package for ${package_name}
- [[ -n "${website_url}" ]] || read_default website_url prefix package for ${package_name}
- [[ -n "${archive_format}" ]] || read_default archive_format for ${package_name}
-
- local default_configure_flags _flag
- [[ -n "${default_configure_flags}" ]] || read_default configure_flags prefix default for ${package_name}
- __sm.package.configure.flags "${default_configure_flags[@]}"
-
- true \
- "${package_version:="${package_default_version}"}" \
- "${init_scripts_path:="$(init_scripts_path)"}" \
- "${archive_format:=tar.gz}" \
- "${package_file:="${package_name}-${package_version}.${archive_format}"}" \
- "${install_base_path:="${packages_path}/versions/${package_name}"}" \
- "${install_path:="${install_base_path}/${package_version}"}"
-
- package configure flag key --prefix "${install_path}"
-
- # This check should only happen in places that require a version...
- #[[ -n "${package_version}" ]] ||
- # fail "Package version must be specified.\n"\
- # "(For example version=x.y.z set in extension's config/defaults file.)\n"
-
- fhs_dirs=( bin etc include lib libexec sbin share man )
-
- paths create "${active_path}"
-
- for dir in ${fhs_dirs}
- do
- paths create "${active_path}/${fhs_dirs}"
- done
-
- if user is root
- then
- true \
- "${log_path:="/var/log/${package_name}"}" \
- "${package_user:="${package_name}"}"
- else
- true \
- "${log_path:="${active_path}/log"}" \
- "${package_user:="$USER"}"
- fi
-
- extension_patches_path="${extension_path}/patches"
-}
-
-#
-# ## package\_install
-#
-# Performs all package installation steps:
-# * download
-# * extract
-# * patch
-# * confiure
-# * build
-# * install
-# * postinstall
-# * activation
-# * service setup, if service module is loaded
-#
-# ### Usage Examples
-#
-# Example Usage:
-#
-# user$ package_definition \
-# name "bash" \
-# version "4.2" \
-# url "ftp.gnu.org/gnu/bash/"
-#
-# user$ package_install
-#
-package_install()
-{
- (( $# == 0 )) || package_cli $@
-
- if package_installed_versions | grep -q "${package_version}" &&
- [[ "${force_flag}" != "1" ]]
- then
- log "The ${package_name} ${package_version} package is already installed.
-To force it to reinstall, call:\n\tsm ${package_name} package install force\n"
- exit 0
- fi
-
- true "${package_dir:="${package_name}-${package_version}"}"
-
- paths create "${source_path}"
-
- paths enter "${source_path}"
-
- if command exists "${package_name}_dependencies"
- then
- log_step "${package_name} ${package_version} ~ dependencies" \
- "${package_name}_dependencies"
- else
- log_step "${package_name} ${package_version} ~ dependencies" \
- package_dependencies
- fi
-
- if command exists "${package_name}_prefetch"
- then
- log_step "${package_name} ${package_version} ~ prefetch" \
- "${package_name}_prefetch"
- fi
-
- if command exists "${package_name}_fetch"
- then
- log_step "${package_name} ${package_version} ~ download" \
- "${package_name}_fetch"
- else
- log_step "${package_name} ${package_version} ~ download" \
- package_fetch
- fi
-
- paths enter "${source_path}/${package_dir}"
-
- if command exists "${package_name}_postfetch"
- then
- log_step "${package_name} ${package_version} ~ postfetch" \
- "${package_name}_postfetch"
- fi
-
- if command exists "${package_name}_patch"
- then
- log_step "${package_name} ${package_version} ~ patch" \
- "${package_name}_patch"
- else
- log_step "${package_name} ${package_version} ~ patch" \
- package_patch
- fi
-
- if command exists "${package_name}_preconfigure"
- then
- log_step "${package_name} ${package_version} ~ preconfigure" \
- "${package_name}_preconfigure"
- fi
-
- if command exists "${package_name}_configure"
- then
- "${package_name}_configure"
- else
- log_step "${package_name} ${package_version} ~ configure" \
- package_configure
- fi
-
- if command exists "${package_name}_postconfigure"
- then
- log_step "${package_name} ${package_version} ~ postconfigure" \
- "${package_name}_postconfigure"
- fi
-
- if command exists "${package_name}_build"
- then
- log_step "${package_name} ${package_version} ~ build" \
- "${package_name}_build"
- else
- log_step "${package_name} ${package_version} ~ build" \
- package_build
- fi
-
- if command exists "${package_name}_preinstall"
- then
- log_step "${package_name} ${package_version} ~ preinstall" \
- "${package_name}_preinstall"
- else
- log_step "${package_name} ${package_version} ~ preinstall" \
- package_preinstall
- fi
-
- versionedfs add \
- path "${packages_path}" name "${package_name}" version "${package_version}" \
- source "${install_path}"
-
- if command exists "${package_name}_install"
- then
- log_step "${package_name} ${package_version} ~ install" \
- "${package_name}_install"
- else
- package_make_install
- fi
-
- files link symbolic force \
- from "${source_path}/${package_dir}" \
- to "${install_path}/src"
-
- if command exists "${package_name}_postinstall"
- then
- log_step "${package_name} ${package_version} ~ postinstall" \
- "${package_name}_postinstall"
- else
- log_step "${package_name} ${package_version} ~ postinstall" \
- package_postinstall
- fi
-
- if ! __sm.string.contains 'package_update' "${FUNCNAME[*]}"
- then
- package_activate_if_first "${package_name}" "${package_version}"
- fi
-
- if command exists "${package_name}_postactivate"
- then
- log_step "${package_name} ${package_version} ~ postactivate" \
- "${package_name}_postactivate"
- fi
-
- package_setup
-}
-
-package_update()
-{
- (( $# == 0 )) || package_cli $@
-
- # TODO: check if newer version exists, if so then...
- if package_installed_versions | grep -q "${package_version}" \
- && [[ "${force_flag}" != "1" ]]
- then
- log "The latest version (${package_version}) of the ${package_name} package is already installed."
- else
- package_install ${package_name} ${package_version:-} ${archive_format:-} --force
- package_activate ${package_name} ${package_version}
- fi
-}
-
-package_fetch_md5()
-{
- (( $# == 0 )) || package_cli $@
-
- local download_url
-
- : \
- "${package_file:="${package_name}-${package_version}.${archive_format}"}" \
- "${packge_md5_url:="${package_base_url}/${package_file}.md5"}"
-
- [[ -n "${package_md5}" ]] || read_config "${package_name}" md5 "${package_file}" as package_md5
- [[ -n "${package_md5}" ]] ||
- if [[ -n "${package_md5_url}" ]]
- then # TODO: Can this be added into fetch_uri ?
- curl -L "${packge_md5_url}" -o "${archives_path}/${package_file}.md5" 2>/dev/null ||
- error "Fetching MD5 checksum from '${package_md5_url}' failed."
-
- package_md5=$(cat "${archives_path}/${package_file}.md5")
-
- rm "${archives_path}/${package_file}.md5"
- else
- package_md5="" # not known.
- fi
-}
-
-package_fetch()
-{
- (( $# == 0 )) || package_cli $@
-
- local _args=()
-
- true \
- "${package_file:="${package_name}-${package_version}.${archive_format}"}" \
- "${package_url:="${package_base_url}/${package_file}"}"
-
- package_fetch_md5
- if [[ -n "${scm_type:-}" ]]
- then
- _args+=( "scm_type" "${scm_type}" )
- fi
-
- fetch_uri "${package_url}" "${source_path}/${package_dir}" \
- "${package_md5:-#}" ${_args[@]} || return 1
-
- [[ -z "${__vcs_failed}" ]] || return 1
-
- [[ -d "${source_path}/${package_dir}/${package_dir}" ]] || return 0
-
- shopt -s nullglob
- local _entries=( "${source_path}/${package_dir}/${package_dir}"/* )
- shopt -u nullglob
-
- mv "${_entries[@]}" "${source_path}/${package_dir}/"
-
- rm -rf "${source_path}/${package_dir}/${package_dir}/"
-}
-
-package_configure()
-{
- local _command
-
- command exists gcc || command exists cc || fail "No C compiler found."
-
- if [[ -n "${configure_command}" ]]
- then
- _command="${configure_command}"
- else
- export PREFIX="${install_base_path}/${package_version}"
-
- # package configure flag key --prefix "${install_path}"
- __sm.package.configure.flag "--prefix" "${install_path}"
-
- _command="./configure ${configure_flags[*]}"
-
- [[ -x "${_command%% *}" ]] || return 0
- fi
-
- debug package "package_configure: ${_command}"
-
- ${_command} > configure.log 2>&1 ||
- __sm.package.error \
- "Configuration of ${package_name} ${package_version} failed." \
- "configure.log"
-}
-
-package_build()
-{
- local _command
-
- if [[ -n ${build_command:-} ]]
- then
- _command="${build_command}"
- else
- _command="make ${make_flags[@]:-"-j$(os cpu count)"}"
- fi
-
- debug package "package_build: ${_command}"
-
- ${_command} > build.log 2>&1 ||
- package error \
- message "Compilation of ${package_name} ${package_version} failed! " \
- log "build.log"
-}
-
-package_preinstall()
-{
- true
-}
-
-package_make_install()
-{
- local _command
-
- if [[ -n ${install_command:-} ]]
- then
- _command="${install_command}"
- else
- _command="make ${make_install_flags[@]:-install}"
- fi
-
- log_step "${package_name} ${package_version} ~ install"
- ${_command} > make.install.log 2>&1 ||
- package error \
- message "Installation of ${package_name} ${package_version} failed! " \
- log "make.install.log"
- log_step success
-
-}
-
-package_postinstall()
-{
- true
-}
-
-package_activate()
-{
- (( $# == 0 )) || package_cli $@
-
- versionedfs activate \
- path "${packages_path}" name "${package_name}" version "${package_version}"
-
- package_ldconfig "${package_name}"
-
- package_setup "${package_name}"
-}
-
-package_setup()
-{
- local _package="${1:-${package_name}}"
-
- package_profile_d "${_package}"
-
- if __sm.module.is.loaded "service"
- then
- __sm.service.setup "${_package}"
- fi
-
- if __sm.module.is.loaded "database"
- then
- __sm.database.setup "${_package}"
- fi
-}
-
-package_deactivate()
-{
- (( $# == 0 )) || package_cli $@
-
- log_step "${package_name} ${_version} ~ deactivate"
-
- versionedfs deactivate \
- path "${packages_path}" name "${package_name}"
-
- log_step success
-
- __sm.string.contains 'package_activate' "${FUNCNAME[*]}" ||
- package_ldconfig "${_package}"
-}
-
-package_activate_if_first()
-{
- local _package="${1:-}" _version="${2:-}"
- shift || fail "Package name must be given as first parameter."
- shift || fail "Package version must be given as second parameter."
-
- if paths exist "${install_path}"
- then
- package_activate "${_package}" "${_version}"
- else
- log "'${install_path}' not found; skipping activation."
- fi
-}
-
-package_ldconfig()
-{
- local _package="${1:-${package_name}}" _path _files _ldconfig="/sbin/ldconfig"
- [[ -n "${_package}" ]] || fail "Package name must be given."
-
- # paths exist "${packages_path}/versions/${_package}/active/lib" ||
- # return 0 # no lib/ directory for activated package, no need to update ldconfig
-
- user is root || return 0
-
- # TODO: Figure out if solaris and freebsd have an analog to this?
- if os is linux
- then
- if paths exist "/etc/ld.so.conf.d"
- then
- files write \
- string "${active_path}/lib\n" \
- to "/etc/ld.so.conf.d/sm.conf" \
- mode 0444
- fi
-
- if [[ -d /selinux ]] && command exists restorecon
- then
- restorecon -R "${active_path}/lib" # -v ~ verbose
- restorecon -R "${packages_path}/versions/${package_name}" # -v ~ verbose
- fi
-
- command exists "${_ldconfig}" || ldconfig="ldconfig"
-
- log_step "${package_name} ${package_version} ~ ldconfig" \
- "${_ldconfig}" "${active_path}/lib"
-
- elif os is darwin
- then # Cluster Fuck!
- true
- # This should be handled by the profile.d?
- # _files=($(find "${packages_path}/versions/${_package}/active" -mindepth 1 -maxdepth 1 -type d))
- # (( ${#_files[@]} > 0 )) && copy_files to "${packages_path}" "${_files[@]}"
- fi
-}
-
-package_profile_d()
-{
- local _package="${1:-${package_name}}"
- [[ -n "${_package}" ]] || fail "Package name must be given."
-
- templates exist "profile.d.template" || return 0
-
- log_step "Updating shell profile for ${_package}"
-
- paths create "${profile_d_path}"
- files create "${profile_path}"
-
- templates install "profile.d" to "${profile_d_path}/${_package}.sh" mode 0755
-
- log_step success
-}
-
-package_uninstall()
-{
- (( $# == 0 )) || package_cli $@
-
- if package_is_active "${package_name}" "${package_version}"
- then # Deactivate the package if active.
- package_deactivate "${package_name}" "${package_version}"
- fi
-
- log_step "${package_name} ${package_version} ~ uninstall"
-
- paths remove "${install_path}"
-
- ! module_is_loaded service || service_uninstall # Remove any service reminants
-
- log_step success
-}
-
-package_patch()
-{
- local _patches _patch _path _paths
-
- _paths=(
- "${extension_patches_path}"
- "${extension_patches_path}/$(os type)"
- "${extension_patches_path}/$(os type)/${package_version}"
- )
-
- for _path in "${_paths[@]}"
- do
- paths exists "${_path}" || continue # No patch path
- shopt -s nullglob
- _patches=( "${_path}"/*.patch )
- shopt -u nullglob
- package_apply_patches "${_patches[@]}"
- done
-}
-
-package_apply_patches()
-{
- local _patch _patches=("$@")
- shift || fail "No patches were given."
-
- for _patch in "${_patches[@]}"
- do
- [[ -f "${_patch}" && -s "${_patch}" ]] || continue
- error "TODO: patch application is NIY (see package_patch())"
- done
-}
-
-package_usage() {
- log "
- Usage:
-
- $0 [options]
-
- options:
-
- --prefix - specify prefix path
- --src) - specify source directory
- --data) - specify data directory
- --user) - specify user to install as
- --version) - specify version to install
- --licence) - view licence
- --help) - view this usage information
-
- "
-}
-
-package_is_active()
-{
- local _name="${1:-}" _version="${2:-}"
- shift || fail "No package name was given, or name is empty."
-
- local _path="${packages_path}/versions/${_name}"
-
- if shift
- then # version was passed
- [[ -d "${_path}/${_version}" ]]
- else # version was not passed
- [[ -L "${_path}/active" && -d $(readlink "${_path}/active") ]]
- fi
-}
-
-package_must_be_active()
-{
- local _name="${1:-}"
-
- shift || fail "No package name was given (or name is empty.)"
-
- package_is_active "${_name}" ||
- error "Install/activate the node package extension, before installing ${_name}."
-}
-
-packages_must_be_active()
-{
- local _package _packages="$@"
- shift || fail "No packages were given."
-
- for _package in "${_packages[@]}"
- do
- package_must_be_active "${_package}"
- done
-}
-
-package_docs()
-{
- os open "${package_docs_url}"
-}
-
-package_website()
-{
- os open "${package_website_url}"
-}
-
-package_dependencies()
-{
- local dependency _dependencies=(${package_dependencies[@]}) _missing_dependencies=()
-
- unset package_dependencies
-
- # TODO: improve dependency management.
- for dependency in "${_dependencies[@]}"
- do
- package_is_active ${dependency/-/ } || _missing_dependencies+=( ${dependency} )
- done
-
- if [[ -n "${_missing_dependencies}" ]]
- then
- local IFS=','
- error "${extension} requires ${_missing_dependencies[*]}.\n
-Please install via sm package module, and retry. Typically, this can be done as follows:\n
-\tsm ${_missing_dependencies[*]} package install\n"
- fi
-}
-
-
-#
-# ## package\_info
-#
-# Displays package information.
-#
-# ### Input Parameters
-#
-# None.
-#
-# ### Stream Outputs
-#
-# Steps performed are logged to STDOUT of the calling environment.
-#
-# ### Environmental effects
-#
-# Package installation artifacts are created in the system and source directories.
-#
-# ### Return Codes
-#
-# 0 for success.
-#
-# ### Failure Scenarios
-#
-# Fails if any of the constituant components fail.
-#
-# ### Usage Examples
-#
-# Example Usage:
-#
-# user$ package_info "bash"
-#
-# default_version: "4.2"
-# base_url "ftp.gnu.org/gnu/bash/"
-# ...
-#
-# user$ package_info
-#
-# ### Notes
-#
-package_info()
-{
- (( $# == 0 )) || package_cli $@
-
- local _installed _path="${packages_path}/versions/${package_name}" package_md5
-
- : \
- "${package_dir:="${package_name}-${package_version}"}" \
- "${package_url:="${package_base_url}/${package_file}"}"
-
- [[ -n "${package_md5}" ]] || read_config "${package_name}" md5 "${package_file}" as package_md5
-
- log "package_name: ${package_name}"
- if paths exist "${_path}"
- then
- local _installed=($( package_installed_versions ${package_name} ${package_version} ))
- log " versions_installed: ${_installed[*]}"
- else
- log " versions_installed: none"
- fi
- log " default_version: ${package_default_version}"
-
- if [[ -d "${_path}" ]] && [[ -L "${_path}/active" ]]
- then
- log " version_active: $(readlink "${_path}/active")"
- else
- log " version_active: none"
- fi
- log " base_url: ${package_base_url}"
- log " download_url: ${package_url}"
- log " archive_format: ${package_file}"
- log " stored archive_md5: ${package_md5:-}"
- log " source_path: ${source_path}/${package_dir}"
-
- [[ -z "${package_dependencies}" ]] ||
- log " dependencies: ${package_dependencies[*]}"
-}
-
-package_man()
-{
- (( $# == 0 )) || package_cli $@
-
- true "${package_path:="${packages_path}/versions/${package_name}/${package_version}"}"
-
- MANPATH="${package_path}/man"
-
- paths exist $MANPATH ||
- error "No man page available for package ${package_name} ${package_version}"
-
- man ${extension_actions[@]:-${package_name}} || true
-}
-
-package_installed_versions()
-{
- versionedfs versions path "${packages_path}" name "${package_name}"
-}
-
-packages_installed()
-{
- versionedfs versions path "${packages_path}"
-}
-
-packages_active()
-{
- local _name="${1:-}"
- if [[ -n "${_name}" ]]
- then
- versionedfs active path "${packages_path}" name "${_name}"
- else
- versionedfs active path "${packages_path}"
- fi
-}
-
-packages_available()
-{
- __sm.extension.installed module "api/package" "$@"
-}
-
-packages_list()
-{
- local _action="${1:-}" _args
- shift || true
-
- case "${_action}" in
- (active)
- packages_active "$@"
- ;;
-
- (available)
- packages_available "$@"
- ;;
-
- (installed|*)
- packages_installed "$@"
- ;;
- esac
-}
-
3  core/cli/bin/install
View
@@ -2,4 +2,5 @@
modules api/package
-package_install "${extension_args[@]}"
+package install "${extension_args[@]}"
+
2  core/internal/shell/database/functions
View
@@ -16,7 +16,7 @@ api_database_initialize()
true "${data_path:="${data_base_path}/${package_version}"}"
}
-database_cli()
+__sm.database.cli()
{
local _ignored_args=() args_count=${#extension_args[@]}
24 core/internal/shell/extensions/execution/functions
View
@@ -88,21 +88,25 @@ __sm.extension.modules.include()
__sm.extension.action.prerequisites()
{
trace_filter action_pre
- local _pre _name
+ local _pre _name _action="${action// *}" _extension="${_extension// *}"
_pre=(
- ${action}_cli
- ${action}_initialize
+ ${_action}_cli
+ ${_action}_initialize
)
- __sm.string.contains "${action%%_*}_cli" "${_pre[*]}" || _pre+=(
- ${action%%_*}_cli
- ${action%%_*}_initialize
+ __sm.string.contains "${_action%%_*}.cli" "${_pre[*]}" || _pre+=(
+ ${_action%%_*}_cli
+ ${_action%%_*}_initialize
)
- __sm.string.contains "${extension}_cli" "${_pre[*]}" || _pre+=(
- ${extension}_cli
- ${extension}_initialize
+ __sm.string.contains "${_extension}.cli" "${_pre[*]}" || _pre+=(
+ ${_extension}_cli
+ ${_extension}_initialize
+ )
+ __sm.string.contains "__sm.${_extension}.cli" "${_pre[*]}" || _pre+=(
+ __sm.${_extension}.cli
+ __sm.${_extension}.initialize
)
for _name in ${_pre[@]}
@@ -129,7 +133,7 @@ __sm.extension.run()
__sm.extension.modules.include ${_namespaces//\// }
action=${action%%(*}
__sm.extension.action.prerequisites
- __sm.actions.call "${action}" "${extension_args[@]}"
+ __sm.actions.call ${action} "${extension_args[@]}"
;;
(shell)
782 core/internal/shell/package/functions
View
@@ -1,5 +1,96 @@
#!/bin/sh
+__sm.package.cli()
+{
+ local _ignored_args=() _package_args=( $@ ) _token
+ local number_of_args=${#_package_args[@]} index
+
+ for (( index=0 ; index < $number_of_args ; index++ ))
+ do
+ _token="${_package_args[$index]}"
+ case "${_token}" in
+ (prefix)
+ packages_path="${_package_args[$((++index))]}"
+ [[ -n "${packages_path}" ]] ||
+ error "a path must follow keyword 'prefix'"
+ ;;
+ (src)
+ src_path="${_package_args[$((++index))]}"
+ [[ -n "${src_path}" ]] ||
+ error "a path must follow keyword 'src'"
+ ;;
+ (data)
+ data_path="${_package_args[$((++index))]}"
+ [[ -n "${data_path}" ]] ||
+ error "a path must follow keyword 'data'"
+ ;;
+ (user)
+ package_user="${_package_args[$((++index))]}"
+ [[ -n "${package_user}" ]] ||
+ error "a user name must follow keyword 'user'"
+ ;;
+ (version)
+ package_version="${_package_args[$((++index))]}"
+ [[ -n "${package_version}" ]] ||
+ error "a version number string must follow keyword 'version'"
+ ;;
+ (base_url)
+ package_base_url="${_package_args[$((++index))]}"
+ [[ -n "${package_base_url}" ]] ||
+ error "a base path url must follow keyword 'base_url'"
+ ;;
+ (file)
+ package_file="${_package_args[$((++index))]}"
+ [[ -n "${package_file}" ]] ||
+ error "a path must follow keyword 'file'"
+ ;;
+ (dir)
+ package_directory="${_package_args[$((++index))]}"
+ [[ -n "${package_directory}" ]] ||
+ error "a single extracted directory name must follow keyword 'dir'"
+ ;;
+ (archive_format)
+ archive_format="${_package_args[$((++index))]}"
+ [[ -n "${archive_format}" ]] ||
+ error "an archive format (tar.gz,tar.bz2,tar.xz,zip,...) must follow keyword 'archive_format'"
+ ;;
+ (md5)
+ package_md5="${_package_args[$((++index))]}"
+ [[ -n "${package_md5}" ]] ||
+ error "an md5 sum string must follow keyword 'md5'"
+ ;;
+ (force)
+ force_flag=1
+ ;;
+ (static)
+ static_flag=1
+ __sm.package.configure.flags --static
+ ;;
+ (shared)
+ shared_flag=1
+ __sm.package.configure.flags --enable-shared
+ ;;
+ (licence)
+ extension_license
+ succeed
+ ;;
+ (help)
+ __sm.package.usage
+ succeed
+ ;;
+ (--with*|--enable*|--disable*)
+ __sm.package.configure.flags "${_token}"
+ ;;
+ (*)
+ _ignored_args+=("${_token}")
+ ;;
+ esac
+
+ done
+
+ __sm.package.init "${_ignored_args[@]}"
+}
+
__sm.package.error()
{
local _message="$1" _log="$2" _lines="$3"
@@ -119,4 +210,695 @@ __sm.package.set.ldflags()
export LDFLAGS="-L${active_path}/lib ${LDFLAGS:-}"
fi
}
+__sm.package.set.cc()
+{
+ if os is darwin && [[ -x /usr/bin/gcc-4.2 ]]
+ then
+ export CC=/usr/bin/gcc-4.2
+ fi
+}
+__sm.package.exports()
+{
+ export package_name packages_path package_name package_version archive_format \
+ package_file package_url package_md5_url packages_path bin_path source_path \
+ LDFLAGS CFLAGS package_default_version
+}
+
+__sm.package.gnu.install()
+{
+ (( $# == 0 )) || __sm.package.cli $@
+
+ __sm.package.set.cflags
+ __sm.package.set.cc
+ __sm.package.set.ldflags
+
+ if __sm.package.versions.installed | grep -q "${package_version}" &&
+ [[ "${force_flag}" != "1" ]]
+ then
+ log "The ${package_name} ${package_version} package is already installed.
+To force it to reinstall, call:\n\tsm ${package_name} package install force\n"
+ exit 0
+ fi
+
+ true "${package_dir:="${package_name}-${package_version}"}"
+
+ paths create "${source_path}"
+
+ paths enter "${source_path}"
+
+ if command exists "${package_name}_dependencies"
+ then
+ log_step "${package_name} ${package_version} ~ dependencies" \
+ "${package_name}_dependencies"
+ else
+ log_step "${package_name} ${package_version} ~ dependencies" \
+ __sm.package.dependencies
+ fi
+
+ if command exists "${package_name}_prefetch"
+ then
+ log_step "${package_name} ${package_version} ~ prefetch" \
+ "${package_name}_prefetch"
+ fi
+
+ if command exists "${package_name}_fetch"
+ then
+ log_step "${package_name} ${package_version} ~ download" \
+ "${package_name}_fetch"
+ else
+ log_step "${package_name} ${package_version} ~ download" \
+ __sm.package.fetch
+ fi
+
+ paths enter "${source_path}/${package_dir}"
+
+ if command exists "${package_name}_postfetch"
+ then
+ log_step "${package_name} ${package_version} ~ postfetch" \
+ "${package_name}_postfetch"
+ fi
+
+ if command exists "${package_name}_patch"
+ then
+ log_step "${package_name} ${package_version} ~ patch" \
+ "${package_name}_patch"
+ else
+ log_step "${package_name} ${package_version} ~ patch" \
+ __sm.package.patch
+ fi
+
+ if command exists "${package_name}_preconfigure"
+ then
+ log_step "${package_name} ${package_version} ~ preconfigure" \
+ "${package_name}_preconfigure"
+ fi
+
+ if command exists "${package_name}_configure"
+ then
+ "${package_name}_configure"
+ else
+ log_step "${package_name} ${package_version} ~ configure" \
+ __sm.package.configure
+ fi
+
+ if command exists "${package_name}_postconfigure"
+ then
+ log_step "${package_name} ${package_version} ~ postconfigure" \
+ "${package_name}_postconfigure"
+ fi
+
+ if command exists "${package_name}_build"
+ then
+ log_step "${package_name} ${package_version} ~ build" \
+ "${package_name}_build"
+ else
+ log_step "${package_name} ${package_version} ~ build" \
+ __sm.package.build
+ fi
+
+ if command exists "${package_name}_preinstall"
+ then
+ log_step "${package_name} ${package_version} ~ preinstall" \
+ "${package_name}_preinstall"
+ else
+ log_step "${package_name} ${package_version} ~ preinstall" \
+ __sm.package.preinstall
+ fi
+
+ versionedfs add \
+ path "${packages_path}" name "${package_name}" version "${package_version}" \
+ source "${install_path}"
+
+ if command exists "${package_name}_install"
+ then
+ log_step "${package_name} ${package_version} ~ install" \
+ "${package_name}_install"
+ else
+ __sm.package.make.install
+ fi
+
+ files link symbolic force \
+ from "${source_path}/${package_dir}" \
+ to "${install_path}/src"
+
+ if command exists "${package_name}_postinstall"
+ then
+ log_step "${package_name} ${package_version} ~ postinstall" \
+ "${package_name}_postinstall"
+ else
+ log_step "${package_name} ${package_version} ~ postinstall" \
+ __sm.package.postinstall
+ fi
+
+ if ! __sm.string.contains '__sm.package.update' "${FUNCNAME[*]}"
+ then
+ __sm.package.activate.first "${package_name}" "${package_version}"
+ fi
+
+ if command exists "${package_name}_postactivate"
+ then
+ log_step "${package_name} ${package_version} ~ postactivate" \
+ "${package_name}_postactivate"
+ fi
+
+ __sm.package.setup
+}
+
+__sm.package.init()
+{
+ package_name="${1:-${package_name:-${extension}}}"
+
+ [[ -n "${package_name}" ]] || fail "Package name must be given.\n"
+
+ case "${package_name}" in
+ *=*) # exact version specifier
+ package_version="${package_name#*=}"
+ package_name="${package_name%%=*}"
+ ;;
+ *:*) # minimum version specifier
+ # TODO: concept of 'minimum' ;)
+ package_version="${package_name#*:}"
+ package_name="${package_name%%:*}"
+ ;;
+ *)
+ true "${package_version:="${2:-}"}" "${archive_format:="${3:-}"}"
+ ;;
+ esac
+
+ if command exists "${package_name}_initialize"
+ then
+ __sm.string.contains "${package_name}_initialize" "${FUNCNAME[*]}" ||
+ "${package_name}_initialize"
+ fi
+
+ true \
+ "${source_path:="${sm_path}/src"}" \
+ "${archives_path:="${sm_path}/archives"}" \
+ ${static_flag:=0}
+
+__sm.package.exports
+ # Ensure that package_version is set at this point
+
+ [[ -n "${package_default_version}" ]] || read_default version prefix package_default for ${package_name}
+ [[ -n "${package_base_url}" ]] || read_default base_url prefix package for ${package_name}
+ [[ -n "${package_md5_url}" ]] || read_default md5_url prefix package for ${package_name}
+ [[ -n "${package_user}" ]] || read_default user prefix package for ${package_name}
+ [[ -n "${website_url}" ]] || read_default website_url prefix package for ${package_name}
+ [[ -n "${archive_format}" ]] || read_default archive_format for ${package_name}
+
+ local default_configure_flags _flag
+
+ [[ -n "${default_configure_flags}" ]] || read_default configure_flags prefix default for ${package_name}
+ __sm.package.configure.flags "${default_configure_flags[@]}"
+
+ true \
+ "${package_version:="${package_default_version}"}" \
+ "${init_scripts_path:="$(init_scripts_path)"}" \
+ "${archive_format:=tar.gz}" \
+ "${package_file:="${package_name}-${package_version}.${archive_format}"}" \
+ "${install_base_path:="${packages_path}/versions/${package_name}"}" \
+ "${install_path:="${install_base_path}/${package_version}"}"
+
+ package configure flag key --prefix "${install_path}"
+
+ # This check should only happen in places that require a version...
+ #[[ -n "${package_version}" ]] ||
+ # fail "Package version must be specified.\n"\
+ # "(For example version=x.y.z set in extension's config/defaults file.)\n"
+
+ fhs_dirs=( bin etc include lib libexec sbin share man )
+
+ paths create "${active_path}"
+
+ for dir in ${fhs_dirs}
+ do
+ paths create "${active_path}/${fhs_dirs}"
+ done
+
+ if user is root
+ then
+ true \
+ "${log_path:="/var/log/${package_name}"}" \
+ "${package_user:="${package_name}"}"
+ else
+ true \
+ "${log_path:="${active_path}/log"}" \
+ "${package_user:="$USER"}"
+ fi
+
+ extension_patches_path="${extension_path}/patches"
+}
+
+__sm.package.binary.install()
+{
+ NIY "Binary package strategy"
+ # TODO: download, extract, copy to install path.
+}
+
+__sm.package.java.install()
+{
+ NIY "Java package strategy"
+ # TODO: download, extract, copy to install path, setup java launcher.
+}
+
+__sm.package.fetch.md5()
+{
+ (( $# == 0 )) || __sm.package.cli $@
+
+ local download_url
+
+ : \
+ "${package_file:="${package_name}-${package_version}.${archive_format}"}" \
+ "${packge_md5_url:="${package_base_url}/${package_file}.md5"}"
+
+ [[ -n "${package_md5}" ]] || read_config "${package_name}" md5 "${package_file}" as package_md5
+ [[ -n "${package_md5}" ]] ||
+ if [[ -n "${package_md5_url}" ]]
+ then # TODO: Can this be added into fetch_uri ?
+ curl -L "${packge_md5_url}" -o "${archives_path}/${package_file}.md5" 2>/dev/null ||
+ error "Fetching MD5 checksum from '${package_md5_url}' failed."
+
+ package_md5=$(cat "${archives_path}/${package_file}.md5")
+
+ rm "${archives_path}/${package_file}.md5"
+ else
+ package_md5="" # not known.
+ fi
+}
+
+__sm.package.update()
+{
+ (( $# == 0 )) || __sm.package.cli $@
+
+ # TODO: check if newer version exists, if so then...
+ if __sm.package.versions.installed | grep -q "${package_version}" \
+ && [[ "${force_flag}" != "1" ]]
+ then
+ log "The latest version (${package_version}) of the ${package_name} package is already installed."
+ else
+ __sm.package.${package_strategy:-gnu}.install \
+ ${package_name} ${package_version:-} ${archive_format:-} force
+ __sm.package.activate ${package_name} ${package_version}
+ fi
+}
+
+__sm.package.configure()
+{
+ local _command
+
+ command exists gcc || command exists cc || fail "No C compiler found."
+
+ if [[ -n "${configure_command}" ]]
+ then
+ _command="${configure_command}"
+ else
+ export PREFIX="${install_base_path}/${package_version}"
+
+ # package configure flag key --prefix "${install_path}"
+ __sm.package.configure.flag "--prefix" "${install_path}"
+
+ _command="./configure ${configure_flags[*]}"
+
+ [[ -x "${_command%% *}" ]] || return 0
+ fi
+
+ debug package "__sm.package.configure: ${_command}"
+
+ ${_command} > configure.log 2>&1 ||
+ __sm.package.error \
+ "Configuration of ${package_name} ${package_version} failed." \
+ "configure.log"
+}
+
+__sm.package.build()
+{
+ local _command
+
+ if [[ -n ${build_command:-} ]]
+ then
+ _command="${build_command}"
+ else
+ _command="make ${make_flags[@]:-"-j$(os cpu count)"}"
+ fi
+
+ debug package "__sm.package.build: ${_command}"
+
+ ${_command} > build.log 2>&1 ||
+ package error \
+ message "Compilation of ${package_name} ${package_version} failed! " \
+ log "build.log"
+}
+
+__sm.package.preinstall()
+{
+ true # nothing to be done for now.
+}
+
+__sm.package.make.install()
+{
+ local _command
+
+ if [[ -n ${install_command:-} ]]
+ then
+ _command="${install_command}"
+ else
+ _command="make ${make_install_flags[@]:-install}"
+ fi
+
+ log_step "${package_name} ${package_version} ~ install"
+ ${_command} > make.install.log 2>&1 ||
+ package error \
+ message "Installation of ${package_name} ${package_version} failed! " \
+ log "make.install.log"
+ log_step success
+}
+
+
+__sm.package.postinstall()
+{
+ true
+}
+
+__sm.package.activate()
+{
+ (( $# == 0 )) || __sm.package.cli $@
+
+ versionedfs activate \
+ path "${packages_path}" name "${package_name}" version "${package_version}"
+
+ __sm.package.ldconfig "${package_name}"
+ __sm.package.setup "${package_name}"
+}
+
+__sm.package.setup()
+{
+ local _package="${1:-${package_name}}"
+
+ __sm.package.profile.d "${_package}"
+
+ if __sm.module.is.loaded "service"
+ then
+ __sm.service.setup "${_package}"
+ fi
+
+ if __sm.module.is.loaded "database"
+ then
+ __sm.database.setup "${_package}"
+ fi
+}
+
+__sm.package.deactivate()
+{
+ (( $# == 0 )) || __sm.package.cli $@
+
+ log_step "${package_name} ${_version} ~ deactivate"
+
+ versionedfs deactivate \
+ path "${packages_path}" name "${package_name}"
+
+ log_step success
+
+ if ! __sm.string.contains '__sm.package.activate' "${FUNCNAME[*]}"
+ then
+ __sm.package.ldconfig "${_package}"
+ fi
+}
+
+__sm.package.activate.first()
+{
+ local _package="${1:-}" _version="${2:-}"
+ shift || fail "Package name must be given as first parameter."
+ shift || fail "Package version must be given as second parameter."
+
+ if paths exist "${install_path}"
+ then
+ __sm.package.activate "${_package}" "${_version}"
+ else
+ log "'${install_path}' not found; skipping activation."
+ fi
+}
+
+__sm.package.ldconfig()
+{
+ local _package="${1:-${package_name}}" _path _files _ldconfig="/sbin/ldconfig"
+ [[ -n "${_package}" ]] || fail "Package name must be given."
+
+ # paths exist "${packages_path}/versions/${_package}/active/lib" ||
+ # return 0 # no lib/ directory for activated package, no need to update ldconfig
+
+ user is root || return 0
+
+ # TODO: Figure out if solaris and freebsd have an analog to this?
+ if os is linux
+ then
+ if paths exist "/etc/ld.so.conf.d"
+ then
+ files write \
+ string "${active_path}/lib\n" \
+ to "/etc/ld.so.conf.d/sm.conf" \
+ mode 0444
+ fi
+
+ if [[ -d /selinux ]] && command exists restorecon
+ then
+ restorecon -R "${active_path}/lib" # -v ~ verbose
+ restorecon -R "${packages_path}/versions/${package_name}" # -v ~ verbose
+ fi
+
+ command exists "${_ldconfig}" || ldconfig="ldconfig"
+
+ log_step "${package_name} ${package_version} ~ ldconfig" \
+ "${_ldconfig}" "${active_path}/lib"
+
+ elif os is darwin
+ then # Cluster Fuck!
+ true
+ # This should be handled by the profile.d?
+ # _files=($(find "${packages_path}/versions/${_package}/active" -mindepth 1 -maxdepth 1 -type d))
+ # (( ${#_files[@]} > 0 )) && copy_files to "${packages_path}" "${_files[@]}"
+ fi
+}
+
+__sm.package.profile.d()
+{
+ local _package="${1:-${package_name}}"
+ [[ -n "${_package}" ]] || fail "Package name must be given."
+
+ templates exist "profile.d.template" || return 0
+
+ log_step "Updating shell profile for ${_package}"
+
+ paths create "${profile_d_path}"
+ files create "${profile_path}"
+
+ templates install "profile.d" to "${profile_d_path}/${_package}.sh" mode 0755
+
+ log_step success
+}
+
+__sm.package.uninstall()
+{
+ (( $# == 0 )) || __sm.package.cli $@
+
+ if __sm.package.is.active "${package_name}" "${package_version}"
+ then # Deactivate the package if active.
+ __sm.package.deactivate "${package_name}" "${package_version}"
+ fi
+
+ log_step "${package_name} ${package_version} ~ uninstall"
+
+ paths remove "${install_path}"
+
+ ! module_is_loaded service || service_uninstall # Remove any service reminants
+
+ log_step success
+}
+
+__sm.package.patch()
+{
+ local _patches _patch _path _paths
+
+ _paths=(
+ "${extension_patches_path}"
+ "${extension_patches_path}/$(os type)"
+ "${extension_patches_path}/$(os type)/${package_version}"
+ )
+
+ for _path in "${_paths[@]}"
+ do
+ paths exists "${_path}" || continue # No patch path
+ shopt -s nullglob
+ _patches=( "${_path}"/*.patch )
+ shopt -u nullglob
+ __sm.package.patches.apply "${_patches[@]}"
+ done
+}
+
+__sm.package.patches.apply()
+{
+ local _patch _patches=("$@")
+ shift || fail "No patches were given."
+
+ for _patch in "${_patches[@]}"
+ do
+ [[ -f "${_patch}" && -s "${_patch}" ]] || continue
+ error "TODO: patch application is NIY (see __sm.package.patch())"
+ done
+}
+
+
+__sm.package.is.active()
+{
+ local _name="${1:-}" _version="${2:-}"
+ shift || fail "No package name was given, or name is empty."
+
+ local _path="${packages_path}/versions/${_name}"
+
+ if shift
+ then # version was passed
+ [[ -d "${_path}/${_version}" ]]
+ else # version was not passed
+ [[ -L "${_path}/active" && -d $(readlink "${_path}/active") ]]
+ fi
+}
+
+__sm.package.docs()
+{
+ os open "${package_docs_url}"
+}
+
+__sm.package.website()
+{
+ os open "${package_website_url}"
+}
+
+__sm.package.dependencies()
+{
+ local dependency _dependencies=(${package_dependencies[@]}) _missing_dependencies=()
+
+ unset package_dependencies
+
+ # TODO: improve dependency management.
+ for dependency in "${_dependencies[@]}"
+ do
+ if ! __sm.package.is.active ${dependency/-/ }
+ then
+ _missing_dependencies+=( ${dependency} )
+ fi
+ done
+
+ if [[ -n "${_missing_dependencies}" ]]
+ then
+ local IFS=','
+ error "${extension} requires ${_missing_dependencies[*]}.\n
+Please install via sm package module, and retry. Typically, this can be done as follows:\n
+\tsm ${_missing_dependencies[*]} package install\n"
+ fi
+}
+
+__sm.package.info()
+{
+ (( $# == 0 )) || __sm.package.cli $@
+
+ local _installed _path="${packages_path}/versions/${package_name}" package_md5
+
+ : \
+ "${package_dir:="${package_name}-${package_version}"}" \
+ "${package_url:="${package_base_url}/${package_file}"}"
+
+ [[ -n "${package_md5}" ]] || read_config "${package_name}" md5 "${package_file}" as package_md5
+
+ log "package_name: ${package_name}"
+ if paths exist "${_path}"
+ then
+ local _installed=($( __sm.package.versions.installed ${package_name} ${package_version} ))
+ log " versions_installed: ${_installed[*]}"
+ else
+ log " versions_installed: none"
+ fi
+ log " default_version: ${package_default_version}"
+
+ if [[ -d "${_path}" ]] && [[ -L "${_path}/active" ]]
+ then
+ log " version_active: $(readlink "${_path}/active")"
+ else
+ log " version_active: none"
+ fi
+ log " base_url: ${package_base_url}"
+ log " download_url: ${package_url}"
+ log " archive_format: ${package_file}"
+ log " stored archive_md5: ${package_md5:-}"
+ log " source_path: ${source_path}/${package_dir}"
+
+ if [[ -n "${package_dependencies}" ]]
+ then
+ log " dependencies: ${package_dependencies[*]}"
+ fi
+}
+
+__sm.package.man()
+{
+ (( $# == 0 )) || __sm.package.cli $@
+
+ true "${package_path:="${packages_path}/versions/${package_name}/${package_version}"}"
+
+ MANPATH="${package_path}/man"
+
+ paths exist $MANPATH ||
+ error "No man page available for package ${package_name} ${package_version}"
+
+ man ${extension_actions[@]:-${package_name}} || true
+}
+
+__sm.package.versions.installed()
+{
+ versionedfs versions path "${packages_path}" name "${package_name}"
+}
+
+__sm.packages.installed()
+{
+ versionedfs versions path "${packages_path}"
+}
+
+__sm.packages.active()
+{
+ local _name="${1:-}"
+ if [[ -n "${_name}" ]]
+ then
+ versionedfs active path "${packages_path}" name "${_name}"
+ else
+ versionedfs active path "${packages_path}"
+ fi
+}
+
+__sm.packages.available()
+{
+ __sm.extension.installed module "api/package" "$@"
+}
+
+__sm.packages.list()
+{
+ local _action="${1:-}" _args
+ shift || true
+ __sm.packages.${_action:-installed} "$@"
+}
+
+__sm.package.usage() {
+ log "
+ Usage:
+
+ $0 [options]
+
+ options:
+
+ --prefix - specify prefix path
+ --src) - specify source directory
+ --data) - specify data directory
+ --user) - specify user to install as
+ --version) - specify version to install
+ --licence) - view licence
+ --help) - view this usage information
+
+ "
+}
2  core/sm/shell/core/initialize
View
@@ -143,7 +143,7 @@ then
then
error "${call_action} is not a valid function name"
else
- __sm.actions.call "${call_action}" "${extension_args[@]}"
+ __sm.actions.call ${call_action} "${extension_args[@]}"
fi
elif set | grep '^extension_args=(' >/dev/null
then
Please sign in to comment.
Something went wrong with that request. Please try again.