Skip to content
Newer
Older
100644 172 lines (161 sloc) 4.47 KB
1e2fea6 @wayneeseguin The shebangs in the modules and extensions are used solely for syntax…
wayneeseguin authored Aug 19, 2011
1 #!/bin/sh
f0c9b42 @wayneeseguin Cleaned up one of my poorly written commands.
wayneeseguin authored May 6, 2011
2
9c82b3d @wayneeseguin Added todos
wayneeseguin authored Aug 31, 2011
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 Sep 6, 2011
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 Aug 30, 2011
40 package()
32d3668 @mpapis fix package configure flags
mpapis authored Aug 26, 2011
41 {
e4e7311 @mpapis fix trace_filter
mpapis authored Sep 16, 2011
42 trace_filter package || set -o xtrace
6b43e56 @mpapis fix trace_filter
mpapis authored Sep 17, 2011
43 typeset -g package_name package_version package_base_url package_file \
9e993be @wayneeseguin Checksum refactorings.
wayneeseguin authored Mar 27, 2012
44 package_user archive_format package_checksum
6b43e56 @mpapis fix trace_filter
mpapis authored Sep 17, 2011
45
a4284f5 @mpapis package: remove code duplication, add deactivate
mpapis authored Oct 22, 2011
46 typeset _token _command _logfile _lines _key _log _message
47 typeset -a _params __package_commands
ea1d015 @mpapis variables split - api
mpapis authored Sep 16, 2011
48 _lines=50
ada33e3 @iande adding package_error
iande authored May 6, 2011
49
a4284f5 @mpapis package: remove code duplication, add deactivate
mpapis authored Oct 22, 2011
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 Aug 30, 2011
75 while (( $# ))
cbd4295 @wayneeseguin First package man work.
wayneeseguin authored Aug 12, 2011
76 do
2250602 @wayneeseguin Well now, that was silly. Bugfix: Infinite loop.
wayneeseguin authored Sep 7, 2011
77 _token="$1" && shift
966f245 @wayneeseguin More work on API.
wayneeseguin authored Aug 30, 2011
78 case "${_token}" in
79 (log)
80 _log="$1"
ddb249b @mpapis do not show warning on shift when nothing to shift
mpapis authored Sep 17, 2011
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 Mar 30, 2011
82 ;;
966f245 @wayneeseguin More work on API.
wayneeseguin authored Aug 30, 2011
83 (lines)
84 _lines="$1"
ddb249b @mpapis do not show warning on shift when nothing to shift
mpapis authored Sep 17, 2011
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 Mar 30, 2011
86 ;;
966f245 @wayneeseguin More work on API.
wayneeseguin authored Aug 30, 2011
87 (message)
88 _message="$1"
ddb249b @mpapis do not show warning on shift when nothing to shift
mpapis authored Sep 17, 2011
89 (( $# )) && shift || __sm.log.fail "Message must be given following keyword 'message'"
72a9bb0 @wayneeseguin API cleanup work.
wayneeseguin authored Sep 19, 2011
90 ;;
966f245 @wayneeseguin More work on API.
wayneeseguin authored Aug 30, 2011
91 (key)
92 _key="$1"
ddb249b @mpapis do not show warning on shift when nothing to shift
mpapis authored Sep 17, 2011
93 (( $# )) && shift || __sm.log.fail "Key name must follow keyword 'key'"
7d9618b @wayneeseguin Added target_path.
wayneeseguin authored Apr 2, 2011
94 ;;
09b84cd @wayneeseguin Adding more package() keys.
wayneeseguin authored Sep 6, 2011
95 (name)
96 package_name="$1"
ddb249b @mpapis do not show warning on shift when nothing to shift
mpapis authored Sep 17, 2011
97 (( $# )) && shift || __sm.log.fail "a package name must follow keyword 'name'"
11057d3 @wayneeseguin Fixed package install (case statement incorrect syntax); Removed api …
wayneeseguin authored Sep 7, 2011
98 ;;
09b84cd @wayneeseguin Adding more package() keys.
wayneeseguin authored Sep 6, 2011
99 (version)
100 package_version="$1"
ddb249b @mpapis do not show warning on shift when nothing to shift
mpapis authored Sep 17, 2011
101 (( $# )) && shift || __sm.log.fail "a package version must follow keyword 'version'"
11057d3 @wayneeseguin Fixed package install (case statement incorrect syntax); Removed api …
wayneeseguin authored Sep 7, 2011
102 ;;
09b84cd @wayneeseguin Adding more package() keys.
wayneeseguin authored Sep 6, 2011
103 (base_url)
104 package_base_url="$1"
ddb249b @mpapis do not show warning on shift when nothing to shift
mpapis authored Sep 17, 2011
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 …
wayneeseguin authored Sep 7, 2011
106 ;;
09b84cd @wayneeseguin Adding more package() keys.
wayneeseguin authored Sep 6, 2011
107 (file)
108 package_file="$1"
ddb249b @mpapis do not show warning on shift when nothing to shift
mpapis authored Sep 17, 2011
109 (( $# )) && shift || __sm.log.fail "a package file name must follow keyword 'file'"
11057d3 @wayneeseguin Fixed package install (case statement incorrect syntax); Removed api …
wayneeseguin authored Sep 7, 2011
110 ;;
09b84cd @wayneeseguin Adding more package() keys.
wayneeseguin authored Sep 6, 2011
111 (user)
112 package_user="$1"
ddb249b @mpapis do not show warning on shift when nothing to shift
mpapis authored Sep 17, 2011
113 (( $# )) && shift || __sm.log.fail "a package user name must follow keyword 'user'"
11057d3 @wayneeseguin Fixed package install (case statement incorrect syntax); Removed api …
wayneeseguin authored Sep 7, 2011
114 ;;
09b84cd @wayneeseguin Adding more package() keys.
wayneeseguin authored Sep 6, 2011
115 (archive_format)
116 archive_format="$1"
ddb249b @mpapis do not show warning on shift when nothing to shift
mpapis authored Sep 17, 2011
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 …
wayneeseguin authored Sep 7, 2011
118 ;;
9e993be @wayneeseguin Checksum refactorings.
wayneeseguin authored Mar 27, 2012
119 (checksum)
120 package_checksum="$1"
121 (( $# )) && shift || __sm.log.fail "a package checksum sum must follow keyword 'checksum'. Format: '{type},{checksum}'"
11057d3 @wayneeseguin Fixed package install (case statement incorrect syntax); Removed api …
wayneeseguin authored Sep 7, 2011
122 ;;
09b84cd @wayneeseguin Adding more package() keys.
wayneeseguin authored Sep 6, 2011
123 (sha256)
124 package_sha256="$1"
ddb249b @mpapis do not show warning on shift when nothing to shift
mpapis authored Sep 17, 2011
125 (( $# )) && shift || __sm.log.fail "a package sha256 key must follow keyword 'sha256'"
11057d3 @wayneeseguin Fixed package install (case statement incorrect syntax); Removed api …
wayneeseguin authored Sep 7, 2011
126 ;;
09b84cd @wayneeseguin Adding more package() keys.
wayneeseguin authored Sep 6, 2011
127 (sha512)
128 package_sha512="$1"
ddb249b @mpapis do not show warning on shift when nothing to shift
mpapis authored Sep 17, 2011
129 (( $# )) && shift || __sm.log.fail "a package sha512 key must follow keyword 'sha512'"
11057d3 @wayneeseguin Fixed package install (case statement incorrect syntax); Removed api …
wayneeseguin authored Sep 7, 2011
130 ;;
966f245 @wayneeseguin More work on API.
wayneeseguin authored Aug 30, 2011
131 (*)
31e9ef8 @wayneeseguin Adjusted for make install
wayneeseguin authored Sep 7, 2011
132 _params+=("${_token}")
e0f9b29 @wayneeseguin Added help module, updated package module.
wayneeseguin authored Mar 30, 2011
133 ;;
134 esac
135 done
136
e629231 @wayneeseguin Several minor bugfixes around package and variables.
wayneeseguin authored Sep 7, 2011
137 true ${package_name:=${extension}}
138
5323973 @wayneeseguin Began log api separation.
wayneeseguin authored Sep 13, 2011
139 [[ -n "${package_name}" ]] || __sm.log.fail "Package name must be set/given"
8f448e3 @wayneeseguin More package corrections.
wayneeseguin authored Sep 7, 2011
140
966f245 @wayneeseguin More work on API.
wayneeseguin authored Aug 30, 2011
141 case "${_command}" in
357488e @mpapis package reset for scripting
mpapis authored Apr 16, 2012
142 (cli|make|make.install|is.active|is.installed|install|uninstall|info|configure|configure.flags|reset)
cf1c56f @wayneeseguin Package installs now work again, properly sourcing new internal cli m…
wayneeseguin authored Sep 6, 2011
143 __sm.package.${_command} "${_params[@]}"
3fd1d6c @wayneeseguin More work on package api, currently working out spacing in actions map.
wayneeseguin authored Sep 6, 2011
144 ;;
a4284f5 @mpapis package: remove code duplication, add deactivate
mpapis authored Oct 22, 2011
145 (configure.flag)
146 __sm.package.configure.flag "${_key}" "${_params[@]}"
966f245 @wayneeseguin More work on API.
wayneeseguin authored Aug 30, 2011
147 ;;
148 (define)
5323973 @wayneeseguin Began log api separation.
wayneeseguin authored Sep 14, 2011
149 [[ -n "${_params}" ]] || __sm.log.fail "No '{key} {value}' pairs given."
966f245 @wayneeseguin More work on API.
wayneeseguin authored Aug 30, 2011
150 if array is even _params
151 then
152 __sm.package.define "${_params[@]}"
153 else
5323973 @wayneeseguin Began log api separation.
wayneeseguin authored Sep 14, 2011
154 __sm.log.fail "Every key must have an associated value."
966f245 @wayneeseguin More work on API.
wayneeseguin authored Aug 30, 2011
155 fi
156 ;;
a4284f5 @mpapis package: remove code duplication, add deactivate
mpapis authored Oct 22, 2011
157 (activate|activate.first|deactivate)
158 __sm.package.${_command} "${package_name}" "${package_version}"
8f448e3 @wayneeseguin More package corrections.
wayneeseguin authored Sep 7, 2011
159 ;;
966f245 @wayneeseguin More work on API.
wayneeseguin authored Aug 30, 2011
160 (initialize)
83b07f8 @wayneeseguin Feature: sm --verbose --trace {extension} {action}; very useful for d…
wayneeseguin authored Nov 17, 2011
161 typeset -a package_dependencies configure_flags
a45ea1e @wayneeseguin package initialize
wayneeseguin authored Sep 12, 2011
162 __sm.package.init
966f245 @wayneeseguin More work on API.
wayneeseguin authored Aug 30, 2011
163 ;;
164 (error)
5323973 @wayneeseguin Began log api separation.
wayneeseguin authored Sep 14, 2011
165 [[ -n "${_message}" ]] || __sm.log.fail "Message must be given for package error."
966f245 @wayneeseguin More work on API.
wayneeseguin authored Aug 30, 2011
166 __sm.package.error "${_params[@]}" "${_log}" "${_lines}"
167 ;;
168 (*)
5323973 @wayneeseguin Began log api separation.
wayneeseguin authored Sep 14, 2011
169 __sm.log.fail "Unknown package command '${_token}'"
966f245 @wayneeseguin More work on API.
wayneeseguin authored Aug 30, 2011
170 esac
32d3668 @mpapis fix package configure flags
mpapis authored Aug 26, 2011
171 }
Something went wrong with that request. Please try again.