# $Id: Portfile 92467 2012-04-29 12:27:34Z raimue@macports.org $

PortSystem      1.0

name            bash-completion-devel
conflicts       bash-completion
version         1.99
categories      sysutils
platforms       darwin
supported_archs noarch
license         GPL-2+
maintainers     raimue
description     Programmable bash completions
long_description \
    Programmable completion library for bash. Note that this port is meant to \
    be used with bash >=4.1 as provided by the bash port.

homepage        http://bash-completion.alioth.debian.org/
master_sites    http://bash-completion.alioth.debian.org/files/
distname        bash-completion-${version}
checksums       md5     3cf478b7f1065f424d3d6ec35f80e4f2 \
                rmd160  c5b4a926d8a7c1843c6bc85a6ba22b371baaf20e \
                sha256  a2baf5130fa015527f435e145949029c653f0106c89ccfd20ad8987f292ed314
use_bzip2 yes

patchfiles      patch-man.diff \
                patch-vpnc.diff

post-patch {
    reinplace "s:/etc/bash_completion:${prefix}/etc/bash_completion:g" \
        ${worksrcpath}/bash_completion
    reinplace "s:readlink -f:readlink:g" \
        ${worksrcpath}/bash_completion

    # Fix vpnc config location, #29281
    reinplace "s:@@PREFIX@@:${prefix}:g" \
        ${worksrcpath}/completions/vpnc
}

post-destroot {
    xinstall -m 644 -W ${filespath} port launchctl \
        ${destroot}${prefix}/share/bash-completion/completions/

    # Add a link for compatibility with older versions
    ln -s ${prefix}/etc/profile.d/bash_completion.sh ${destroot}${prefix}/etc/bash_completion
}

notes "
To use bash_completion, add the following lines at the end of your .bash_profile:
  if \[ -f ${prefix}/etc/profile.d/bash_completion.sh ]; then
      . ${prefix}/etc/profile.d/bash_completion.sh
  fi
"

livecheck.type      regex
livecheck.url       ${homepage}
livecheck.regex     "bash-completion-(\\d+(?:\\.\\d+)*)${extract.suffix}"
