Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 166 lines (161 sloc) 3.857 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 {
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 ;;
09b84cd @wayneeseguin Adding more package() keys.
wayneeseguin authored
77 (name)
78 package_name="$1"
79 shift || fail "a package name must follow keyword 'name'"
11057d3 @wayneeseguin Fixed package install (case statement incorrect syntax); Removed api dup...
wayneeseguin authored
80 ;;
09b84cd @wayneeseguin Adding more package() keys.
wayneeseguin authored
81 (version)
82 package_version="$1"
83 shift || fail "a package version must follow keyword 'version'"
11057d3 @wayneeseguin Fixed package install (case statement incorrect syntax); Removed api dup...
wayneeseguin authored
84 ;;
09b84cd @wayneeseguin Adding more package() keys.
wayneeseguin authored
85 (base_url)
86 package_base_url="$1"
87 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
88 ;;
09b84cd @wayneeseguin Adding more package() keys.
wayneeseguin authored
89 (file)
90 package_file="$1"
91 shift || fail "a package file name must follow keyword 'file'"
11057d3 @wayneeseguin Fixed package install (case statement incorrect syntax); Removed api dup...
wayneeseguin authored
92 ;;
09b84cd @wayneeseguin Adding more package() keys.
wayneeseguin authored
93 (user)
94 package_user="$1"
95 shift || fail "a package user name must follow keyword 'user'"
11057d3 @wayneeseguin Fixed package install (case statement incorrect syntax); Removed api dup...
wayneeseguin authored
96 ;;
09b84cd @wayneeseguin Adding more package() keys.
wayneeseguin authored
97 (archive_format)
98 archive_format="$1"
99 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
100 ;;
09b84cd @wayneeseguin Adding more package() keys.
wayneeseguin authored
101 (md5)
102 package_md5="$1"
103 shift || fail "a package md5 sum must follow keyword 'md5'"
11057d3 @wayneeseguin Fixed package install (case statement incorrect syntax); Removed api dup...
wayneeseguin authored
104 ;;
09b84cd @wayneeseguin Adding more package() keys.
wayneeseguin authored
105 (sha256)
106 package_sha256="$1"
107 shift || fail "a package sha256 key must follow keyword 'sha256'"
11057d3 @wayneeseguin Fixed package install (case statement incorrect syntax); Removed api dup...
wayneeseguin authored
108 ;;
09b84cd @wayneeseguin Adding more package() keys.
wayneeseguin authored
109 (sha512)
110 package_sha512="$1"
111 shift || fail "a package sha512 key must follow keyword 'sha512'"
11057d3 @wayneeseguin Fixed package install (case statement incorrect syntax); Removed api dup...
wayneeseguin authored
112 ;;
966f245 @wayneeseguin More work on API.
wayneeseguin authored
113 (*)
114 if [[ -z "${_command}" ]]
115 then
116 _command="${_token}"
117 else
118 _params+=("${_token}")
119 fi
e0f9b29 @wayneeseguin Added help module, updated package module.
wayneeseguin authored
120 ;;
121 esac
122 done
123
966f245 @wayneeseguin More work on API.
wayneeseguin authored
124 case "${_command}" in
3fd1d6c @wayneeseguin More work on package api, currently working out spacing in actions map.
wayneeseguin authored
125 (install|uninstall)
cf1c56f @wayneeseguin Package installs now work again, properly sourcing new internal cli meth...
wayneeseguin authored
126 __sm.package.${_command} "${_params[@]}"
3fd1d6c @wayneeseguin More work on package api, currently working out spacing in actions map.
wayneeseguin authored
127 ;;
966f245 @wayneeseguin More work on API.
wayneeseguin authored
128 (configure)
129 case "${_subcommand}" in
130 (flag)
131 __sm.package.configure.flag "${_key}" "${_params[@]}"
132 ;;
133 (flags)
134 __sm.package.configure.flags "${_params[@]}"
135 ;;
136 (*)
3fd1d6c @wayneeseguin More work on package api, currently working out spacing in actions map.
wayneeseguin authored
137 __sm.package.configure
966f245 @wayneeseguin More work on API.
wayneeseguin authored
138 ;;
139 esac
140 ;;
141 (define)
142 [[ -n "${_params}" ]] || fail "No '{key} {value}' pairs given."
143 if array is even _params
144 then
145 __sm.package.define "${_params[@]}"
146 else
147 fail "Every key must have an associated value."
148 fi
149 ;;
150 (initialize)
151 declare -a package_dependencies
152 declare -a configure_flags
153 ;;
154 (error)
155 [[ -n "${_message}" ]] || fail "Message must be given for package error."
156 __sm.package.error "${_params[@]}" "${_log}" "${_lines}"
157 ;;
5e339b5 @wayneeseguin More work on APIs, specifically service and variables.
wayneeseguin authored
158 (cli)
3fd1d6c @wayneeseguin More work on package api, currently working out spacing in actions map.
wayneeseguin authored
159 __sm.package.cli "${_params[@]}"
5e339b5 @wayneeseguin More work on APIs, specifically service and variables.
wayneeseguin authored
160 ;;
966f245 @wayneeseguin More work on API.
wayneeseguin authored
161 (*)
162 fail "Unknown package command '${_token}'"
163 esac
32d3668 @mpapis fix package configure flags
mpapis authored
164 }
165
Something went wrong with that request. Please try again.