Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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