kind: autotools

depends:
- filename: gnu-toolchain.bst
  type: build

sources:
- kind: git
  url: upstream:bash
  track: baserock/bash-4.3-patch-27
  ref: 3590145af6f1c9fa321dff231f69ae696e7e740b

config:
  configure-commands:
  - |
    export CFLAGS="${CFLAGS}  -DSYS_BASHRC='\"/etc/bash.bashrc\"'";
    ./configure --prefix="%{prefix}" \
                --without-bash-malloc \
                --with-installed-readline \
                --enable-readline
  install-commands:
    (>):
    - |
      cat <<'EOF' >> bash.bashrc
      #
      # /etc/bash.bashrc
      #

      # If not running interactively, don't do anything
      [[ $- != *i* ]] && return

      # Configure prompt for different terminals
      case ${TERM} in
        xterm*|rxvt*|Eterm|aterm|kterm|gnome*)
          PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"'

          ;;
        screen)
          PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033_%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"'
          ;;
      esac

      # Enable bash completion if present
      [ -r /usr/share/bash-completion/bash_completion   ] && . /usr/share/bash-completion/bash_completion
      EOF
    - mkdir -p "%{install-root}"/etc
    - install -m 644 bash.bashrc "%{install-root}"/etc/bash.bashrc
