Commit 45720dc3 authored by Clement Bois's avatar Clement Bois
Browse files

Merge branch 'fix/maybe-install-awk' into 'master'

fix: allow installation of missing package awk

Closes #9

See merge request to-be-continuous/cnb!39
parents 26a63b58 57e25aa5
Loading
Loading
Loading
Loading
+31 −4
Original line number Diff line number Diff line
@@ -217,6 +217,29 @@ stages:
    fi
  }

  function maybe_install_awk() {
    if ! command -v awk > /dev/null
    then
      if command -v apt-get > /dev/null
      then
        # Debian
        apt-get update
        apt-get install --no-install-recommends --yes --quiet awk
      elif command -v apk > /dev/null
      then
        # Alpine
        apk add --no-cache gawk
      elif command -v dnf > /dev/null
      then 
        # Fedora
        dnf install -y -q awk
      else
        log_error "... didn't find any supported package manager to install awk"
        exit 1
      fi
    fi
  }

  function unscope_variables() {
    _scoped_vars=$(env | awk -F '=' "/^scoped__[a-zA-Z0-9_]+=/ {print \$1}" | sort)
    if [[ -z "$_scoped_vars" ]]; then return; fi
@@ -409,9 +432,13 @@ stages:
    fi
  }

  function init_workspace() {
    install_ca_certs "${CUSTOM_CA_CERTS:-$DEFAULT_CA_CERTS}"
    maybe_install_awk
    unscope_variables
    eval_all_secrets
    configure_registries_auth
  }

  # ENDSCRIPT

@@ -424,7 +451,7 @@ stages:
      command: ["--service", "cnb", "4.0.0"]
  before_script:
    - !reference [.cnb-scripts]
    - install_ca_certs "${CUSTOM_CA_CERTS:-$DEFAULT_CA_CERTS}"
    - init_workspace

cnb-build:
  extends: .cnb-base