77# SINGLE_VERSION - Specifies the image version - (must match with subdirectory in repo)
88# VERSIONS - Must be set to a list with possible versions (subdirectories)
99
10- set -eE
10+ set -E
1111[ -n " ${DEBUG:- } " ] && set -x
1212
1313# shellcheck shell=bash
@@ -22,53 +22,6 @@ error() { echo "ERROR: $*" ; false ; }
2222trap ' echo "errexit on line $LINENO, $0" >&2' ERR
2323
2424
25- # _parse_output_inner
26- # -------------------
27- # Helper function for 'parse_output'.
28- # We need to avoid case statements in $() for older Bash versions (per issue
29- # postgresql-container#35, mac ships with 3.2).
30- # Example of problematic statement: echo $(case i in i) echo i;; esac)
31- _parse_output_inner ()
32- {
33- set -o pipefail
34- {
35- case $stream in
36- stdout|1|" " )
37- eval " $command " | tee >( cat - >& " $stdout_fd " )
38- ;;
39- stderr|2)
40- set +x # avoid stderr pollution
41- eval " $command " {free_fd}>&1 1>& " $stdout_fd " 2>& " $free_fd " | tee >( cat - >& " $stderr_fd " )
42- ;;
43- esac
44- # Inherit correct exit status.
45- (exit " ${PIPESTATUS[0]} " )
46- } | eval " $filter "
47- }
48-
49-
50- # parse_output COMMAND FILTER_COMMAND OUTVAR [STREAM={stderr|stdout}]
51- # -------------------------------------------------------------------
52- # Parse standard (error) output of COMMAND with FILTER_COMMAND and store the
53- # output into variable named OUTVAR. STREAM might be 'stdout' or 'stderr',
54- # defaults to 'stdout'. The filtered output stays (live) printed to terminal.
55- # This method doesn't create any explicit temporary files.
56- # Defines:
57- # ${$OUTVAR}: Set to FILTER_COMMAND output.
58- parse_output ()
59- {
60- local command=$1 filter=$2 var=$3 stream=$4
61- echo " -> building using $command "
62- local raw_output=' ' rc=0
63- {
64- # shellcheck disable=SC2034
65- raw_output=$( _parse_output_inner)
66- } {stdout_fd}>&1 {stderr_fd}>&2
67- rc=$?
68- eval " $var =\$ raw_output"
69- (exit $rc )
70- }
71-
7225# "best-effort" cleanup of image
7326function clean_image {
7427 for id_file in .image-id .image-id-from; do
@@ -209,9 +162,7 @@ function docker_build_with_version {
209162 if [[ $ret_code != " 0" ]]; then
210163 if [[ " ${OS} " == " rhel8" ]] || [[ " ${OS} " == " rhel9" ]] || [[ " ${OS} " == " rhel10" ]]; then
211164 # Do not fail in case of sending log to pastebin or logdetective fails.
212- set +e
213165 analyze_logs_by_logdetective " ${tmp_file} "
214- set -e
215166 fi
216167 else
217168 # Structure of log build is as follows:
@@ -226,12 +177,6 @@ function docker_build_with_version {
226177
227178 rm -f " $tmp_file "
228179
229- # shellcheck disable=SC2016
230-
231- # parse_output 'docker build '"$BUILD_OPTIONS"' -f "$dockerfile" "${DOCKER_BUILD_CONTEXT}"' \
232- # "tail -n 1 | awk '/Successfully built|(^--> )?(Using cache )?[a-fA-F0-9]+$/{print \$NF}'" \
233- # IMAGE_ID
234- # analyze_logs_by_logdetective "$?" "${tmp_file}"
235180 echo " $IMAGE_ID " > .image-id
236181 tag_image
237182}
0 commit comments