Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 231 lines (224 sloc) 5.311 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 {
73d1c1b @wayneeseguin Added package trace filter.
wayneeseguin authored
42 trace_filter package
5e256ec @wayneeseguin Added package is active|installed
wayneeseguin authored
43 local _token _subcommand _command _logfile _lines=50 _params=()
ada33e3 @iande adding package_error
iande authored
44
966f245 @wayneeseguin More work on API.
wayneeseguin authored
45 while (( $# ))
cbd4295 @wayneeseguin First package man work.
wayneeseguin authored
46 do
2250602 @wayneeseguin Well now, that was silly. Bugfix: Infinite loop.
wayneeseguin authored
47 _token="$1" && shift
966f245 @wayneeseguin More work on API.
wayneeseguin authored
48 case "${_token}" in
cf32d23 @wayneeseguin Ensure install|uninstall commands pass through.
wayneeseguin authored
49 (cli|install|uninstall)
50 _command="${_token}"
e629231 @wayneeseguin Several minor bugfixes around package and variables.
wayneeseguin authored
51 ;;
5e256ec @wayneeseguin Added package is active|installed
wayneeseguin authored
52 (is)
ba90d68 @wayneeseguin Back to setting command as part of args processing.
wayneeseguin authored
53 _command=is
5e256ec @wayneeseguin Added package is active|installed
wayneeseguin authored
54 case "$1" in
55 (active|installed)
56 _subcommand="$1"
57 shift
58 ;;
59 (*)
60 fail "A valid command must follow keyword is; {active|installed}"
61 ;;
62 esac
63 ;;
966f245 @wayneeseguin More work on API.
wayneeseguin authored
64 (log)
65 _log="$1"
66 shift || fail "Log file path/name must be given following keyword 'log'"
e0f9b29 @wayneeseguin Added help module, updated package module.
wayneeseguin authored
67 ;;
966f245 @wayneeseguin More work on API.
wayneeseguin authored
68 (lines)
69 _lines="$1"
70 shift || fail "Number of lines to show must be given following keyword 'lines'"
e0f9b29 @wayneeseguin Added help module, updated package module.
wayneeseguin authored
71 ;;
966f245 @wayneeseguin More work on API.
wayneeseguin authored
72 (message)
73 _message="$1"
74 shift || fail "Message must be given following keyword 'message'"
75 ;;
76 (configure)
ba90d68 @wayneeseguin Back to setting command as part of args processing.
wayneeseguin authored
77 _command=configure
966f245 @wayneeseguin More work on API.
wayneeseguin authored
78 case "$1" in
f41b078 @mpapis fix package api
mpapis authored
79 (flag|flags)
966f245 @wayneeseguin More work on API.
wayneeseguin authored
80 _subcommand="$1"
a2c7582 @mpapis fix package api
mpapis authored
81 shift
966f245 @wayneeseguin More work on API.
wayneeseguin authored
82 ;;
83 (*)
a2c7582 @mpapis fix package api
mpapis authored
84 fail "Unknown configure param '$1'."
966f245 @wayneeseguin More work on API.
wayneeseguin authored
85 continue
86 ;;
87 esac
e0f9b29 @wayneeseguin Added help module, updated package module.
wayneeseguin authored
88 ;;
31e9ef8 @wayneeseguin Adjusted for make install
wayneeseguin authored
89 (make)
ba90d68 @wayneeseguin Back to setting command as part of args processing.
wayneeseguin authored
90 _command=make
31e9ef8 @wayneeseguin Adjusted for make install
wayneeseguin authored
91 if [[ "$1" == install ]]
92 then
93 _subcommand="install"
94 shift
95 fi
96 ;;
4581fa5 @wayneeseguin Added package activate to package api.
wayneeseguin authored
97 (activate)
ba90d68 @wayneeseguin Back to setting command as part of args processing.
wayneeseguin authored
98 _command=activate
4581fa5 @wayneeseguin Added package activate to package api.
wayneeseguin authored
99 if [[ "$1" == first ]]
100 then
101 _subcommand=first
102 shift
103 fi
104 ;;
a45ea1e @wayneeseguin package initialize
wayneeseguin authored
105 (initialize)
106 _command=initialize
107 ;;
f4d381b @wayneeseguin Set define as a command
wayneeseguin authored
108 (define)
109 _command=define
a317e3e @wayneeseguin Set params and break when define is encountered.
wayneeseguin authored
110 _params+=("$@")
111 break
f4d381b @wayneeseguin Set define as a command
wayneeseguin authored
112 ;;
966f245 @wayneeseguin More work on API.
wayneeseguin authored
113 (key)
114 _key="$1"
115 shift || fail "Key name must follow keyword 'key'"
7d9618b @wayneeseguin Added target_path.
wayneeseguin authored
116 ;;
09b84cd @wayneeseguin Adding more package() keys.
wayneeseguin authored
117 (name)
118 package_name="$1"
119 shift || fail "a package name must follow keyword 'name'"
11057d3 @wayneeseguin Fixed package install (case statement incorrect syntax); Removed api dup...
wayneeseguin authored
120 ;;
09b84cd @wayneeseguin Adding more package() keys.
wayneeseguin authored
121 (version)
122 package_version="$1"
123 shift || fail "a package version must follow keyword 'version'"
11057d3 @wayneeseguin Fixed package install (case statement incorrect syntax); Removed api dup...
wayneeseguin authored
124 ;;
09b84cd @wayneeseguin Adding more package() keys.
wayneeseguin authored
125 (base_url)
126 package_base_url="$1"
127 shift || fail "a package base_url must follow keyword 'base_url'"
11057d3 @wayneeseguin Fixed package install (case statement incorrect syntax); Removed api dup...
wayneeseguin authored
128 ;;
09b84cd @wayneeseguin Adding more package() keys.
wayneeseguin authored
129 (file)
130 package_file="$1"
131 shift || fail "a package file name must follow keyword 'file'"
11057d3 @wayneeseguin Fixed package install (case statement incorrect syntax); Removed api dup...
wayneeseguin authored
132 ;;
09b84cd @wayneeseguin Adding more package() keys.
wayneeseguin authored
133 (user)
134 package_user="$1"
135 shift || fail "a package user name must follow keyword 'user'"
11057d3 @wayneeseguin Fixed package install (case statement incorrect syntax); Removed api dup...
wayneeseguin authored
136 ;;
09b84cd @wayneeseguin Adding more package() keys.
wayneeseguin authored
137 (archive_format)
138 archive_format="$1"
139 shift || fail "a package archive_format must follow keyword 'archive_format'"
11057d3 @wayneeseguin Fixed package install (case statement incorrect syntax); Removed api dup...
wayneeseguin authored
140 ;;
09b84cd @wayneeseguin Adding more package() keys.
wayneeseguin authored
141 (md5)
142 package_md5="$1"
143 shift || fail "a package md5 sum must follow keyword 'md5'"
11057d3 @wayneeseguin Fixed package install (case statement incorrect syntax); Removed api dup...
wayneeseguin authored
144 ;;
09b84cd @wayneeseguin Adding more package() keys.
wayneeseguin authored
145 (sha256)
146 package_sha256="$1"
147 shift || fail "a package sha256 key must follow keyword 'sha256'"
11057d3 @wayneeseguin Fixed package install (case statement incorrect syntax); Removed api dup...
wayneeseguin authored
148 ;;
09b84cd @wayneeseguin Adding more package() keys.
wayneeseguin authored
149 (sha512)
150 package_sha512="$1"
151 shift || fail "a package sha512 key must follow keyword 'sha512'"
11057d3 @wayneeseguin Fixed package install (case statement incorrect syntax); Removed api dup...
wayneeseguin authored
152 ;;
966f245 @wayneeseguin More work on API.
wayneeseguin authored
153 (*)
31e9ef8 @wayneeseguin Adjusted for make install
wayneeseguin authored
154 _params+=("${_token}")
e0f9b29 @wayneeseguin Added help module, updated package module.
wayneeseguin authored
155 ;;
156 esac
157 done
158
e629231 @wayneeseguin Several minor bugfixes around package and variables.
wayneeseguin authored
159 true ${package_name:=${extension}}
160
8f448e3 @wayneeseguin More package corrections.
wayneeseguin authored
161 [[ -n "${package_name}" ]] || fail "Package name must be set/given"
162
966f245 @wayneeseguin More work on API.
wayneeseguin authored
163 case "${_command}" in
bf5efd0 @wayneeseguin file(), path() wrappers for files(), paths().
wayneeseguin authored
164 (make)
165 case "$_subcommand" in
166 (install)
167 __sm.package.make.install
168 ;;
169 (*)
170 __sm.package.make "${_params[@]}"
171 ;;
172 esac
8f448e3 @wayneeseguin More package corrections.
wayneeseguin authored
173 ;;
5e256ec @wayneeseguin Added package is active|installed
wayneeseguin authored
174 (is)
bf5efd0 @wayneeseguin file(), path() wrappers for files(), paths().
wayneeseguin authored
175 case "$_subcommand" in
5e256ec @wayneeseguin Added package is active|installed
wayneeseguin authored
176 (active|installed)
e629231 @wayneeseguin Several minor bugfixes around package and variables.
wayneeseguin authored
177 __sm.package.is.${_subcommand} "${_params[@]}"
5e256ec @wayneeseguin Added package is active|installed
wayneeseguin authored
178 ;;
179 esac
180 ;;
3fd1d6c @wayneeseguin More work on package api, currently working out spacing in actions map.
wayneeseguin authored
181 (install|uninstall)
cf1c56f @wayneeseguin Package installs now work again, properly sourcing new internal cli meth...
wayneeseguin authored
182 __sm.package.${_command} "${_params[@]}"
3fd1d6c @wayneeseguin More work on package api, currently working out spacing in actions map.
wayneeseguin authored
183 ;;
966f245 @wayneeseguin More work on API.
wayneeseguin authored
184 (configure)
185 case "${_subcommand}" in
186 (flag)
187 __sm.package.configure.flag "${_key}" "${_params[@]}"
188 ;;
189 (flags)
190 __sm.package.configure.flags "${_params[@]}"
191 ;;
192 (*)
3fd1d6c @wayneeseguin More work on package api, currently working out spacing in actions map.
wayneeseguin authored
193 __sm.package.configure
966f245 @wayneeseguin More work on API.
wayneeseguin authored
194 ;;
195 esac
196 ;;
197 (define)
198 [[ -n "${_params}" ]] || fail "No '{key} {value}' pairs given."
199 if array is even _params
200 then
201 __sm.package.define "${_params[@]}"
202 else
203 fail "Every key must have an associated value."
204 fi
205 ;;
4581fa5 @wayneeseguin Added package activate to package api.
wayneeseguin authored
206 (activate)
207 if [[ "${_subcommand}" == "first" ]]
208 then
209 __sm.package.activate.first "${package_name}" "${package_version}"
210 else
211 __sm.package.activate "${package_name}" "${package_version}"
212 fi
8f448e3 @wayneeseguin More package corrections.
wayneeseguin authored
213 ;;
966f245 @wayneeseguin More work on API.
wayneeseguin authored
214 (initialize)
215 declare -a package_dependencies
216 declare -a configure_flags
a45ea1e @wayneeseguin package initialize
wayneeseguin authored
217 __sm.package.init
966f245 @wayneeseguin More work on API.
wayneeseguin authored
218 ;;
219 (error)
220 [[ -n "${_message}" ]] || fail "Message must be given for package error."
221 __sm.package.error "${_params[@]}" "${_log}" "${_lines}"
222 ;;
5e339b5 @wayneeseguin More work on APIs, specifically service and variables.
wayneeseguin authored
223 (cli)
3fd1d6c @wayneeseguin More work on package api, currently working out spacing in actions map.
wayneeseguin authored
224 __sm.package.cli "${_params[@]}"
5e339b5 @wayneeseguin More work on APIs, specifically service and variables.
wayneeseguin authored
225 ;;
966f245 @wayneeseguin More work on API.
wayneeseguin authored
226 (*)
227 fail "Unknown package command '${_token}'"
228 esac
32d3668 @mpapis fix package configure flags
mpapis authored
229 }
230
Something went wrong with that request. Please try again.