Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

239 lines (231 sloc) 5.916 kB
#!/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()
{
trace_filter package || set -o xtrace
typeset -g package_name package_version package_base_url package_file \
package_user archive_format package_md5 package_sha256 package_sha512
typeset _token _subcommand _command _logfile _lines _key _log _message
typeset -a _params
_lines=50
while (( $# ))
do
_token="$1" && shift
case "${_token}" in
(cli|install|uninstall)
_command="${_token}"
;;
(is)
_command=is
case "$1" in
(active|installed)
_subcommand="$1"
shift
;;
(*)
__sm.log.fail "A valid command must follow keyword is; {active|installed}"
;;
esac
;;
(log)
_log="$1"
(( $# )) && shift || __sm.log.fail "Log file path/name must be given following keyword 'log'"
;;
(lines)
_lines="$1"
(( $# )) && shift || __sm.log.fail "Number of lines to show must be given following keyword 'lines'"
;;
(message)
_message="$1"
(( $# )) && shift || __sm.log.fail "Message must be given following keyword 'message'"
;;
(configure)
_command=configure
case "$1" in
(flag|flags)
_subcommand="$1"
shift
;;
(*)
if [[ -n "$1" ]]
then
__sm.log.fail "Unknown configure param '$1'."
fi
continue
;;
esac
;;
(make)
_command=make
if [[ "$1" == install ]]
then
_subcommand="install"
shift
fi
;;
(activate)
_command=activate
if [[ "$1" == first ]]
then
_subcommand=first
shift
fi
;;
(initialize)
_command=initialize
;;
(define)
_command=define
_params+=("$@")
break
;;
(key)
_key="$1"
(( $# )) && shift || __sm.log.fail "Key name must follow keyword 'key'"
;;
(name)
package_name="$1"
(( $# )) && shift || __sm.log.fail "a package name must follow keyword 'name'"
;;
(version)
package_version="$1"
(( $# )) && shift || __sm.log.fail "a package version must follow keyword 'version'"
;;
(base_url)
package_base_url="$1"
(( $# )) && shift || __sm.log.fail "a package base_url must follow keyword 'base_url'"
;;
(file)
package_file="$1"
(( $# )) && shift || __sm.log.fail "a package file name must follow keyword 'file'"
;;
(user)
package_user="$1"
(( $# )) && shift || __sm.log.fail "a package user name must follow keyword 'user'"
;;
(archive_format)
archive_format="$1"
(( $# )) && shift || __sm.log.fail "a package archive_format must follow keyword 'archive_format'"
;;
(md5)
package_md5="$1"
(( $# )) && shift || __sm.log.fail "a package md5 sum must follow keyword 'md5'"
;;
(sha256)
package_sha256="$1"
(( $# )) && shift || __sm.log.fail "a package sha256 key must follow keyword 'sha256'"
;;
(sha512)
package_sha512="$1"
(( $# )) && shift || __sm.log.fail "a package sha512 key must follow keyword 'sha512'"
;;
(*)
_params+=("${_token}")
;;
esac
done
true ${package_name:=${extension}}
[[ -n "${package_name}" ]] || __sm.log.fail "Package name must be set/given"
case "${_command}" in
(make)
case "$_subcommand" in
(install)
__sm.package.make.install
;;
(*)
__sm.package.make "${_params[@]}"
;;
esac
;;
(is)
case "$_subcommand" in
(active|installed)
__sm.package.is.${_subcommand} "${_params[@]}"
;;
esac
;;
(install|uninstall)
__sm.package.${_command} "${_params[@]}"
;;
(configure)
case "${_subcommand}" in
(flag)
__sm.package.configure.flag "${_key}" "${_params[@]}"
;;
(flags)
__sm.package.configure.flags "${_params[@]}"
;;
(*)
__sm.package.configure
;;
esac
;;
(define)
[[ -n "${_params}" ]] || __sm.log.fail "No '{key} {value}' pairs given."
if array is even _params
then
__sm.package.define "${_params[@]}"
else
__sm.log.fail "Every key must have an associated value."
fi
;;
(activate)
if [[ "${_subcommand}" == "first" ]]
then
__sm.package.activate.first "${package_name}" "${package_version}"
else
__sm.package.activate "${package_name}" "${package_version}"
fi
;;
(initialize)
declare -a package_dependencies
declare -a configure_flags
__sm.package.init
;;
(error)
[[ -n "${_message}" ]] || __sm.log.fail "Message must be given for package error."
__sm.package.error "${_params[@]}" "${_log}" "${_lines}"
;;
(cli)
__sm.package.cli "${_params[@]}"
;;
(*)
__sm.log.fail "Unknown package command '${_token}'"
esac
}
Jump to Line
Something went wrong with that request. Please try again.