Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 172 lines (161 sloc) 4.551 kb
1e2fea6 @wayneeseguin The shebangs in the modules and extensions are used solely for syntax hi...
wayneeseguin authored
1 #!/bin/sh
f0c9b42 @wayneeseguin Cleaned up one of my poorly written commands.
wayneeseguin authored
2
9c82b3d @wayneeseguin Added todos
wayneeseguin authored
3 # TODO: Rework this into a 1.0.0 module API
3fd1d6c @wayneeseguin More work on package api, currently working out spacing in actions map.
wayneeseguin authored
4 #
5 # ## package install
6 #
7 # Performs all package installation steps based on selected strategy:
8 # preinstall
9 #
10 # if gnu:
11 # prefetch
12 # fetch
13 # preextract
14 # extract
15 # prepatch
16 # patch
17 # preconfigure
18 # configure
19 # prebuild
20 # build
21 # preinstall
22 # install
23 # preactivate
24 # activate
25 # service setup, if service module is loaded
26 #
27 # if binary:
28 # prefetch
29 # fetch
30 # preextract
31 # extract
32 # preinstall
33 # install
34 # preactivate
35 # activate
36 # service setup, if service module is loaded
37 #
38 # postinstall
39 #
966f245 @wayneeseguin More work on API.
wayneeseguin authored
40 package()
32d3668 @mpapis fix package configure flags
mpapis authored
41 {
e4e7311 @mpapis fix trace_filter
mpapis authored
42 trace_filter package || set -o xtrace
6b43e56 @mpapis fix trace_filter
mpapis authored
43 typeset -g package_name package_version package_base_url package_file \
44 package_user archive_format package_md5 package_sha256 package_sha512
45
a4284f5 @mpapis package: remove code duplication, add deactivate
mpapis authored
46 typeset _token _command _logfile _lines _key _log _message
47 typeset -a _params __package_commands
ea1d015 @mpapis variables split - api
mpapis authored
48 _lines=50
ada33e3 @iande adding package_error
iande authored
49
a4284f5 @mpapis package: remove code duplication, add deactivate
mpapis authored
50 __package_commands=(
51 "is active"
52 "is installed"
53 "configure flag"
54 "configure flags"
55 "make install"
56 "acvtivate first"
57 )
58
59 if __sm.command.detect "$*" "${__package_commands[@]}"
60 then
61 _command="${__sm_command_dotted}"
62 shift "${__sm_command_words}"
63 else
64 __sm.log.fail "No command given.\nUsage: \nfiles <command> ..."
65 fi
66
67 case "${_command}" in
68 (define)
69 _params+=( "$@" )
70 shift $#
71 ;;
72 esac
73
74
966f245 @wayneeseguin More work on API.
wayneeseguin authored
75 while (( $# ))
cbd4295 @wayneeseguin First package man work.
wayneeseguin authored
76 do
2250602 @wayneeseguin Well now, that was silly. Bugfix: Infinite loop.
wayneeseguin authored
77 _token="$1" && shift
966f245 @wayneeseguin More work on API.
wayneeseguin authored
78 case "${_token}" in
79 (log)
80 _log="$1"
ddb249b @mpapis do not show warning on shift when nothing to shift
mpapis authored
81 (( $# )) && shift || __sm.log.fail "Log file path/name must be given following keyword 'log'"
e0f9b29 @wayneeseguin Added help module, updated package module.
wayneeseguin authored
82 ;;
966f245 @wayneeseguin More work on API.
wayneeseguin authored
83 (lines)
84 _lines="$1"
ddb249b @mpapis do not show warning on shift when nothing to shift
mpapis authored
85 (( $# )) && shift || __sm.log.fail "Number of lines to show must be given following keyword 'lines'"
e0f9b29 @wayneeseguin Added help module, updated package module.
wayneeseguin authored
86 ;;
966f245 @wayneeseguin More work on API.
wayneeseguin authored
87 (message)
88 _message="$1"
ddb249b @mpapis do not show warning on shift when nothing to shift
mpapis authored
89 (( $# )) && shift || __sm.log.fail "Message must be given following keyword 'message'"
72a9bb0 @wayneeseguin API cleanup work.
wayneeseguin authored
90 ;;
966f245 @wayneeseguin More work on API.
wayneeseguin authored
91 (key)
92 _key="$1"
ddb249b @mpapis do not show warning on shift when nothing to shift
mpapis authored
93 (( $# )) && shift || __sm.log.fail "Key name must follow keyword 'key'"
7d9618b @wayneeseguin Added target_path.
wayneeseguin authored
94 ;;
09b84cd @wayneeseguin Adding more package() keys.
wayneeseguin authored
95 (name)
96 package_name="$1"
ddb249b @mpapis do not show warning on shift when nothing to shift
mpapis authored
97 (( $# )) && shift || __sm.log.fail "a package name must follow keyword 'name'"
11057d3 @wayneeseguin Fixed package install (case statement incorrect syntax); Removed api dup...
wayneeseguin authored
98 ;;
09b84cd @wayneeseguin Adding more package() keys.
wayneeseguin authored
99 (version)
100 package_version="$1"
ddb249b @mpapis do not show warning on shift when nothing to shift
mpapis authored
101 (( $# )) && shift || __sm.log.fail "a package version must follow keyword 'version'"
11057d3 @wayneeseguin Fixed package install (case statement incorrect syntax); Removed api dup...
wayneeseguin authored
102 ;;
09b84cd @wayneeseguin Adding more package() keys.
wayneeseguin authored
103 (base_url)
104 package_base_url="$1"
ddb249b @mpapis do not show warning on shift when nothing to shift
mpapis authored
105 (( $# )) && shift || __sm.log.fail "a package base_url must follow keyword 'base_url'"
11057d3 @wayneeseguin Fixed package install (case statement incorrect syntax); Removed api dup...
wayneeseguin authored
106 ;;
09b84cd @wayneeseguin Adding more package() keys.
wayneeseguin authored
107 (file)
108 package_file="$1"
ddb249b @mpapis do not show warning on shift when nothing to shift
mpapis authored
109 (( $# )) && shift || __sm.log.fail "a package file name must follow keyword 'file'"
11057d3 @wayneeseguin Fixed package install (case statement incorrect syntax); Removed api dup...
wayneeseguin authored
110 ;;
09b84cd @wayneeseguin Adding more package() keys.
wayneeseguin authored
111 (user)
112 package_user="$1"
ddb249b @mpapis do not show warning on shift when nothing to shift
mpapis authored
113 (( $# )) && shift || __sm.log.fail "a package user name must follow keyword 'user'"
11057d3 @wayneeseguin Fixed package install (case statement incorrect syntax); Removed api dup...
wayneeseguin authored
114 ;;
09b84cd @wayneeseguin Adding more package() keys.
wayneeseguin authored
115 (archive_format)
116 archive_format="$1"
ddb249b @mpapis do not show warning on shift when nothing to shift
mpapis authored
117 (( $# )) && shift || __sm.log.fail "a package archive_format must follow keyword 'archive_format'"
11057d3 @wayneeseguin Fixed package install (case statement incorrect syntax); Removed api dup...
wayneeseguin authored
118 ;;
09b84cd @wayneeseguin Adding more package() keys.
wayneeseguin authored
119 (md5)
120 package_md5="$1"
ddb249b @mpapis do not show warning on shift when nothing to shift
mpapis authored
121 (( $# )) && shift || __sm.log.fail "a package md5 sum must follow keyword 'md5'"
11057d3 @wayneeseguin Fixed package install (case statement incorrect syntax); Removed api dup...
wayneeseguin authored
122 ;;
09b84cd @wayneeseguin Adding more package() keys.
wayneeseguin authored
123 (sha256)
124 package_sha256="$1"
ddb249b @mpapis do not show warning on shift when nothing to shift
mpapis authored
125 (( $# )) && shift || __sm.log.fail "a package sha256 key must follow keyword 'sha256'"
11057d3 @wayneeseguin Fixed package install (case statement incorrect syntax); Removed api dup...
wayneeseguin authored
126 ;;
09b84cd @wayneeseguin Adding more package() keys.
wayneeseguin authored
127 (sha512)
128 package_sha512="$1"
ddb249b @mpapis do not show warning on shift when nothing to shift
mpapis authored
129 (( $# )) && shift || __sm.log.fail "a package sha512 key must follow keyword 'sha512'"
11057d3 @wayneeseguin Fixed package install (case statement incorrect syntax); Removed api dup...
wayneeseguin authored
130 ;;
966f245 @wayneeseguin More work on API.
wayneeseguin authored
131 (*)
31e9ef8 @wayneeseguin Adjusted for make install
wayneeseguin authored
132 _params+=("${_token}")
e0f9b29 @wayneeseguin Added help module, updated package module.
wayneeseguin authored
133 ;;
134 esac
135 done
136
e629231 @wayneeseguin Several minor bugfixes around package and variables.
wayneeseguin authored
137 true ${package_name:=${extension}}
138
5323973 @wayneeseguin Began log api separation.
wayneeseguin authored
139 [[ -n "${package_name}" ]] || __sm.log.fail "Package name must be set/given"
8f448e3 @wayneeseguin More package corrections.
wayneeseguin authored
140
966f245 @wayneeseguin More work on API.
wayneeseguin authored
141 case "${_command}" in
a4284f5 @mpapis package: remove code duplication, add deactivate
mpapis authored
142 (cli|make|make.install|is.active|is.installed|install|uninstall|info|configure|configure.flags)
cf1c56f @wayneeseguin Package installs now work again, properly sourcing new internal cli meth...
wayneeseguin authored
143 __sm.package.${_command} "${_params[@]}"
3fd1d6c @wayneeseguin More work on package api, currently working out spacing in actions map.
wayneeseguin authored
144 ;;
a4284f5 @mpapis package: remove code duplication, add deactivate
mpapis authored
145 (configure.flag)
146 __sm.package.configure.flag "${_key}" "${_params[@]}"
966f245 @wayneeseguin More work on API.
wayneeseguin authored
147 ;;
148 (define)
5323973 @wayneeseguin Began log api separation.
wayneeseguin authored
149 [[ -n "${_params}" ]] || __sm.log.fail "No '{key} {value}' pairs given."
966f245 @wayneeseguin More work on API.
wayneeseguin authored
150 if array is even _params
151 then
152 __sm.package.define "${_params[@]}"
153 else
5323973 @wayneeseguin Began log api separation.
wayneeseguin authored
154 __sm.log.fail "Every key must have an associated value."
966f245 @wayneeseguin More work on API.
wayneeseguin authored
155 fi
156 ;;
a4284f5 @mpapis package: remove code duplication, add deactivate
mpapis authored
157 (activate|activate.first|deactivate)
158 __sm.package.${_command} "${package_name}" "${package_version}"
8f448e3 @wayneeseguin More package corrections.
wayneeseguin authored
159 ;;
966f245 @wayneeseguin More work on API.
wayneeseguin authored
160 (initialize)
83b07f8 @wayneeseguin Feature: sm --verbose --trace {extension} {action}; very useful for debu...
wayneeseguin authored
161 typeset -a package_dependencies configure_flags
a45ea1e @wayneeseguin package initialize
wayneeseguin authored
162 __sm.package.init
966f245 @wayneeseguin More work on API.
wayneeseguin authored
163 ;;
164 (error)
5323973 @wayneeseguin Began log api separation.
wayneeseguin authored
165 [[ -n "${_message}" ]] || __sm.log.fail "Message must be given for package error."
966f245 @wayneeseguin More work on API.
wayneeseguin authored
166 __sm.package.error "${_params[@]}" "${_log}" "${_lines}"
167 ;;
168 (*)
5323973 @wayneeseguin Began log api separation.
wayneeseguin authored
169 __sm.log.fail "Unknown package command '${_token}'"
966f245 @wayneeseguin More work on API.
wayneeseguin authored
170 esac
32d3668 @mpapis fix package configure flags
mpapis authored
171 }
Something went wrong with that request. Please try again.