[Exherbo-dev] expatch and default_src_prepare

Bryan Østergaard bryan.ostergaard at gmail.com
Wed Feb 20 21:30:44 GMT 2008


On Mon, Feb 18, 2008 at 3:13 PM, Bo Ørsted Andresen <bo.andresen at zlin.dk> wrote:
> As discussed on irc a wrapper for patch that doesn't suck would be nice. I
>  hence propose we add the following expatch function to exheres-0 in
>  paludis/repositories/e/ebuild/exheres-0/build_functions.bash:
>
>  expatch()
>  {
>     if [[ "${EBUILD_PHASE}" != "prepare" ]] ; then
>         die "epatch called in EBUILD_PHASE ${EBUILD_PHASE}"
>     fi
>
>     local recognise= patchlevel= options=() cmd=
>
>     if [[ ${1} == "--recognised-suffixes" ]]; then
>         recognise=true
>         shift
>     fi
>
>     while [[ -n ${1} ]]; do
>         if [[ ${1} == -p[0-9]* ]]; then
>             patchlevel="${1}"
>         elif [[ ${1} == -* ]]; then
>             options+=("${1}")
>         elif [[ -d ${1} ]]; then
>             expatch --recognised-suffixes ${patchlevel} "${options[@]}" "${1}"/*
>         else
>             case "${1}" in
>                 *.bz2)
>                 cmd="bzip2 -dc"
>                 ;;
>                 *.gz|*.Z|*.z)
>                 cmd="gzip -dc"
>                 ;;
>                 *.zip|*.ZIP|*.jar)
>                 cmd="unzip -p"
>                 ;;
>                 *.diff|*.patch)
>                 cmd="cat"
>                 ;;
>                 *)
>                 if [[ -n ${recognise} ]]; then
>                     continue
>                 else
>                     cmd="cat"
>                 fi
>                 ;;
>             esac
>
>             einfo "Applying ${1##*/}"
>             ${cmd} "${1}" | patch -s ${patchlevel:--p1} "${options[@]}" || \
>                 die "patch -s ${options[@]} ${1} failed"
>         fi
>         shift
>     done
>  }
>
>  If further we use this default_src_prepare:
>
>  default_src_prepare()
>  {
>     if [[ -n "${DEFAULT_SRC_PREPARE_PATCHES[@]}" ]]; then
>         expatch "${DEFAULT_SRC_PREPARE_PATCHES[@]}"
>     fi
>  }
>
>  This will allow us to put things like e.g.:
>
>  DEFAULT_SRC_PREPARE_PATCHES=(-p0 "${FILESDIR}/foo.bleh" -p1 "${FILESDIR}/${PV}/")
>
>  in an exheres and thus have first foo.bleh applied with -p0 and then all *.diff
>  and *.patch files in the ${PV}/ directory applied with -p1...
>
Looks fine.

Regards,
Bryan Østergaard


More information about the Exherbo-dev mailing list