Skip to content
Newer
Older
100644 137 lines (132 sloc) 2.84 KB
1e2fea6 @wayneeseguin The shebangs in the modules and extensions are used solely for syntax…
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 {
966f245 @wayneeseguin More work on API.
wayneeseguin authored
42 local _token _command _logfile _lines=50 _params=()
ada33e3 @iande adding package_error
iande authored
43
966f245 @wayneeseguin More work on API.
wayneeseguin authored
44 while (( $# ))
cbd4295 @wayneeseguin First package man work.
wayneeseguin authored
45 do
966f245 @wayneeseguin More work on API.
wayneeseguin authored
46 _token="$1" && shift
47 case "${_token}" in
48 (log)
49 _log="$1"
50 shift || fail "Log file path/name must be given following keyword 'log'"
e0f9b29 @wayneeseguin Added help module, updated package module.
wayneeseguin authored
51 ;;
966f245 @wayneeseguin More work on API.
wayneeseguin authored
52 (lines)
53 _lines="$1"
54 shift || fail "Number of lines to show must be given following keyword 'lines'"
e0f9b29 @wayneeseguin Added help module, updated package module.
wayneeseguin authored
55 ;;
966f245 @wayneeseguin More work on API.
wayneeseguin authored
56 (message)
57 _message="$1"
58 shift || fail "Message must be given following keyword 'message'"
59 ;;
60 (configure)
61 _command=configure
62 case "$1" in
f41b078 @mpapis fix package api
mpapis authored
63 (flag|flags)
966f245 @wayneeseguin More work on API.
wayneeseguin authored
64 _subcommand="$1"
a2c7582 @mpapis fix package api
mpapis authored
65 shift
966f245 @wayneeseguin More work on API.
wayneeseguin authored
66 ;;
67 (*)
a2c7582 @mpapis fix package api
mpapis authored
68 fail "Unknown configure param '$1'."
966f245 @wayneeseguin More work on API.
wayneeseguin authored
69 continue
70 ;;
71 esac
e0f9b29 @wayneeseguin Added help module, updated package module.
wayneeseguin authored
72 ;;
966f245 @wayneeseguin More work on API.
wayneeseguin authored
73 (key)
74 _key="$1"
75 shift || fail "Key name must follow keyword 'key'"
7d9618b @wayneeseguin Added target_path.
wayneeseguin authored
76 ;;
966f245 @wayneeseguin More work on API.
wayneeseguin authored
77 (*)
78 if [[ -z "${_command}" ]]
79 then
80 _command="${_token}"
81 else
82 _params+=("${_token}")
83 fi
e0f9b29 @wayneeseguin Added help module, updated package module.
wayneeseguin authored
84 ;;
85 esac
86 done
87
966f245 @wayneeseguin More work on API.
wayneeseguin authored
88 case "${_command}" in
3fd1d6c @wayneeseguin More work on package api, currently working out spacing in actions map.
wayneeseguin authored
89 (install|uninstall)
90 case "${package_strategy:=gnu}" in
91 (gnu|binary|java)
92 __sm.package.${package_strategy}.${_command}
93 ;;
94 *)
95 fail "Unknown package strategy ${package_strategy}"
96 ;;
97 esac
98 ;;
966f245 @wayneeseguin More work on API.
wayneeseguin authored
99 (configure)
100 case "${_subcommand}" in
101 (flag)
102 __sm.package.configure.flag "${_key}" "${_params[@]}"
103 ;;
104 (flags)
105 __sm.package.configure.flags "${_params[@]}"
106 ;;
107 (*)
3fd1d6c @wayneeseguin More work on package api, currently working out spacing in actions map.
wayneeseguin authored
108 __sm.package.configure
966f245 @wayneeseguin More work on API.
wayneeseguin authored
109 ;;
110 esac
111 ;;
112 (define)
113 [[ -n "${_params}" ]] || fail "No '{key} {value}' pairs given."
114 if array is even _params
115 then
116 __sm.package.define "${_params[@]}"
117 else
118 fail "Every key must have an associated value."
119 fi
120 ;;
121 (initialize)
122 declare -a package_dependencies
123 declare -a configure_flags
124 ;;
125 (error)
126 [[ -n "${_message}" ]] || fail "Message must be given for package error."
127 __sm.package.error "${_params[@]}" "${_log}" "${_lines}"
128 ;;
5e339b5 @wayneeseguin More work on APIs, specifically service and variables.
wayneeseguin authored
129 (cli)
3fd1d6c @wayneeseguin More work on package api, currently working out spacing in actions map.
wayneeseguin authored
130 __sm.package.cli "${_params[@]}"
5e339b5 @wayneeseguin More work on APIs, specifically service and variables.
wayneeseguin authored
131 ;;
966f245 @wayneeseguin More work on API.
wayneeseguin authored
132 (*)
133 fail "Unknown package command '${_token}'"
134 esac
32d3668 @mpapis fix package configure flags
mpapis authored
135 }
136
Something went wrong with that request. Please try again.