diff --git a/roles/common/files/pip_check_requirements_upgrades.sh b/roles/common/files/pip_check_requirements_upgrades.sh index 9d721287bebd8400ec0b811d2f31ee871a399b81..965b4034b5777e9ee32a39f15746fdde0c63bf37 100755 --- a/roles/common/files/pip_check_requirements_upgrades.sh +++ b/roles/common/files/pip_check_requirements_upgrades.sh @@ -122,24 +122,24 @@ fi # Set-up functions for printing coloured messages. function debug() { if [[ $debug != 0 ]]; then - echo "${_text_bold}${_text_blue}[DEBUG]${_text_reset}" "$@" + echo -e "${_text_bold}${_text_blue}[DEBUG]${_text_reset}" "$@" fi } function info() { - echo "${_text_bold}${_text_white}[INFO] ${_text_reset}" "$@" + echo -e "${_text_bold}${_text_white}[INFO] ${_text_reset}" "$@" } function success() { - echo "${_text_bold}${_text_green}[OK] ${_text_reset}" "$@" + echo -e "${_text_bold}${_text_green}[OK] ${_text_reset}" "$@" } function warning() { - echo "${_text_bold}${_text_yellow}[WARN] ${_text_reset}" "$@" + echo -e "${_text_bold}${_text_yellow}[WARN] ${_text_reset}" "$@" } function error() { - echo "${_text_bold}${_text_red}[ERROR]${_text_reset}" "$@" >&2 + echo -e "${_text_bold}${_text_red}[ERROR]${_text_reset}" "$@" >&2 } # Clean-up command for temporary files. @@ -147,7 +147,7 @@ function on_exit() { debug "Cleaning-up temporary file: $tmp_current" [[ -f $tmp_current ]] && rm "$tmp_current" - debug "Cleaning-up temporayr file: $tmp_new" + debug "Cleaning-up temporary file: $tmp_new" [[ -f $tmp_new ]] && rm "$tmp_new" } trap on_exit EXIT @@ -247,11 +247,16 @@ for environment in "$config_dir"/*; do # Deploy the existing requirements file and the new one. sed -e 's/[[:blank:]]*#.*//' "$req_txt" | grep -v "^$" | sort -u > "$tmp_current" - if ! pip-compile --no-header --no-annotate --no-index --output-file "$tmp_new" "$req_in" > /dev/null; then + if ! pip-compile --upgrade --dry-run --no-header --no-annotate --no-index "$req_in" 2>&1 | \ + grep -v 'Dry-run' | sed -e 's/[[:blank:]]*#.*//' | grep -v "^$" | \ + sort -u > "$tmp_new" ; then error "Failed while running pip-compile command against (see error stack trace above): $req_in" continue fi + debug "Current requirements:\n$(cat "$tmp_current")" + debug "New requirements:\n$(cat "$tmp_new")" + # Run diff, storing the output and result. diff=$(diff -u "$tmp_current" "$tmp_new") result="$?"