@@ -61,7 +61,7 @@ set_platform() {
6161 full_version=$( bash " ${facts} " release)
6262 assigned ' full_version'
6363 else
64- fail " Unable to find the puppetlabs-facts bash task to determine platform."
64+ fail " Unable to find the puppetlabs-facts bash task to determine platform at ' ${facts} ' ."
6565 fi
6666}
6767
@@ -140,21 +140,37 @@ set_collection_url() {
140140 else
141141 package_name=" ${collection} -release-${family}${full_version} .${package_file_suffix} "
142142 fi
143- package_url=" https:// ${repository} /${package_name} "
143+ package_url=" ${repository} /${package_name} "
144144
145145 assigned ' package_name'
146146 assigned ' package_url'
147147}
148148
149+ exec_and_capture () {
150+ local _cmd=" $* "
151+
152+ info " Executing: ${_cmd} "
153+ local _result
154+
155+ set +e
156+ result=$( ${_cmd} 2>&1 )
157+ local _status=$?
158+ set -e
159+
160+ echo " ${result} "
161+ info " Status: ${_status} "
162+ return $_status
163+ }
164+
149165# Download the given url to the given local file path.
150166download () {
151167 local _url=" $1 "
152168 local _file=" $2 "
153169
154170 if exists ' wget' ; then
155- wget -O " ${_file} " " ${_url} "
171+ exec_and_capture wget -O " ${_file} " " ${_url} "
156172 elif exists ' curl' ; then
157- curl -sSL -o " ${_file} " " ${_url} "
173+ exec_and_capture curl -sSL -o " ${_file} " " ${_url} "
158174 else
159175 fail " Unable to download ${_url} . Neither wget nor curl are installed."
160176 fi
@@ -180,13 +196,14 @@ install_release_package() {
180196 local _package_type=" $1 "
181197 local _package_file=" $2 "
182198
199+ info " Installing release package: ${_package_file} "
183200 case $_package_type in
184201 rpm)
185- rpm -Uvh " $_package_file "
202+ exec_and_capture rpm -Uvh " $_package_file "
186203 ;;
187204 deb)
188- dpkg -i " $_package_file "
189- apt update
205+ exec_and_capture dpkg -i " $_package_file "
206+ exec_and_capture apt update
190207 ;;
191208 * )
192209 fail " Unhandled package type: '${package_type} '"
@@ -197,14 +214,15 @@ install_release_package() {
197214install_package () {
198215 local _package=" $1 "
199216
217+ info " Installing ${_package} "
200218 if exists ' dnf' ; then
201- dnf install -y " $_package "
219+ exec_and_capture dnf install -y " $_package "
202220 elif exists ' yum' ; then
203- yum install -y " $_package "
221+ exec_and_capture yum install -y " $_package "
204222 elif exists ' zypper' ; then
205- zypper install -y " $_package "
223+ exec_and_capture zypper install -y " $_package "
206224 elif exists ' apt' ; then
207- apt install -y " $_package "
225+ exec_and_capture apt install -y " $_package "
208226 else
209227 fail " Unable to install ${_package} . Neither dnf, yum, zypper, nor apt are installed."
210228 fi
0 commit comments