---
  # Apply the FWD patches to both NCURSES and TERMINFO.
  
  - name: "Enabling source packages (needed before we try to patch ncurses)."
    replace:
       dest: /etc/apt/sources.list
       regexp: "# deb-src"
       replace: "deb-src"
       backup: yes
    notify: "run patching"

  - name: "Make sure that the package list is up to date."
    apt:
       update_cache: yes
    notify: "run patching"
       
  - name: "Ensure that libncurses5-dev is not installed."
    apt:
       name: libncurses5-dev
       state: absent
    notify: "run patching"
      
  - name: "Install the ncurses header patch."
    copy:
       src: ncurses_curses_h_in_20060828.patch
       dest: /root/ncurses_curses_h_in_20060828.patch
       owner: root
       group: root
       mode: 0400
    notify: "run patching"
       
  - name: "Install the ncurses getch patch."
    copy:
       src: ncurses_lib_getch_c_v5.7_20090512.patch
       dest: /root/ncurses_lib_getch_c_v5.7_20090512.patch
       owner: root
       group: root
       mode: 0400
    notify: "run patching"
      
  - name: "Install the master patching runner script."
    copy:
       src: manage_term_patches.sh
       dest: /root/manage_term_patches.sh
       owner: root
       group: root
       mode: 0550
    notify: "run patching"
      
  - name: "Install the ncurses patching script."
    copy:
       src: patch_ncurses.sh
       dest: /root/patch_ncurses.sh
       owner: root
       group: root
       mode: 0550
    notify: "run patching"

  - name: "Install the terminfo patching script."
    copy:
       src: patch_terminfo.sh
       dest: /root/patch_terminfo.sh
       owner: root
       group: root
       mode: 0550
    notify: "run patching"

  - name: "Install the apt hook that re-patches ncurses/terminfo when apt-get runs."
    copy:
       src: apt.conf.d_95patch-ncurses
       dest: /etc/apt/apt.conf.d/95patch-ncurses
       owner: root
       group: root
       mode: 0644
    notify: "run patching"
       