/[gentoo-x86]/eclass/haskell-cabal.eclass
Gentoo

Diff of /eclass/haskell-cabal.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.35 Revision 1.36
1# Copyright 1999-2012 Gentoo Foundation 1# Copyright 1999-2012 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/haskell-cabal.eclass,v 1.35 2012/11/16 15:47:17 slyfox Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/haskell-cabal.eclass,v 1.36 2012/11/19 20:35:16 slyfox Exp $
4 4
5# @ECLASS: haskell-cabal.eclass 5# @ECLASS: haskell-cabal.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Haskell herd <haskell@gentoo.org> 7# Haskell herd <haskell@gentoo.org>
8# @AUTHOR: 8# @AUTHOR:
52# User-specified additional parameters for ghc when building 52# User-specified additional parameters for ghc when building
53# _only_ 'setup' binary bootstrap. 53# _only_ 'setup' binary bootstrap.
54# example: /etc/make.conf: GHC_BOOTSTRAP_FLAGS=-dynamic to make 54# example: /etc/make.conf: GHC_BOOTSTRAP_FLAGS=-dynamic to make
55# linking 'setup' faster. 55# linking 'setup' faster.
56: ${GHC_BOOTSTRAP_FLAGS:=} 56: ${GHC_BOOTSTRAP_FLAGS:=}
57
58# @ECLASS-VARIABLE: CABAL_DEBUG_LOOSENING
59# @DESCRIPTION:
60# Show debug output for 'cabal_chdeps' function if set.
61# Needs working 'diff'.
62: ${CABAL_DEBUG_LOOSENING:=}
57 63
58HASKELL_CABAL_EXPF="pkg_setup src_compile src_test src_install" 64HASKELL_CABAL_EXPF="pkg_setup src_compile src_test src_install"
59 65
60case "${EAPI:-0}" in 66case "${EAPI:-0}" in
61 2|3|4|5) HASKELL_CABAL_EXPF+=" src_configure" ;; 67 2|3|4|5) HASKELL_CABAL_EXPF+=" src_configure" ;;
533 echo "--flags=-${UWORD}" 539 echo "--flags=-${UWORD}"
534 fi 540 fi
535 541
536 return 0 542 return 0
537} 543}
544
545# @FUNCTION: cabal_chdeps
546# @DESCRIPTION:
547# Allows easier patching of $CABAL_FILE (${S}/${PN}.cabal by default)
548# depends
549#
550# Accepts argument list as pairs of substitutions: <from-string> <to-string>...
551#
552# Dies on error.
553#
554# Usage examples:
555#
556# src_prepare() {
557# cabal_chdeps \
558# 'base >= 4.2 && < 4.6' 'base >= 4.2 && < 4.7' \
559# 'containers ==0.4.*' 'containers >= 0.4 && < 0.6'
560#}
561# or
562# src_prepare() {
563# CABAL_FILE=${S}/${MY_PN}.cabal cabal_chdeps \
564# 'base >= 4.2 && < 4.6' 'base >= 4.2 && < 4.7'
565# CABAL_FILE=${S}/${MY_PN}-tools.cabal cabal_chdeps \
566# 'base == 3.*' 'base >= 4.2 && < 4.7'
567#}
568#
569cabal_chdeps() {
570 local cf=${CABAL_FILE:-${S}/${PN}.cabal}
571 local from_ss # ss - substring
572 local to_ss
573 local orig_c # c - contents
574 local new_c
575
576 [[ -f $cf ]] || die "cabal file '$cf' does not exist"
577
578 orig_c=$(< "$cf")
579
580 while :; do
581 from_pat=$1
582 to_str=$2
583 einfo "CHDEP: '${from_pat}' -> '${to_str}'"
584
585 [[ -n ${from_pat} ]] || break
586 [[ -n ${to_str} ]] || die "'${from_str}' does not have 'to' part"
587
588 # escape pattern-like symbols
589 from_pat=${from_pat//\*/\\*}
590 from_pat=${from_pat//\[/\\[}
591
592 new_c=${orig_c//${from_pat}/${to_str}}
593
594 if [[ -n $CABAL_DEBUG_LOOSENING ]]; then
595 echo "${orig_c}" >"${T}/${cf}".pre
596 echo "${new_c}" >"${T}/${cf}".post
597 diff -u "${T}/${cf}".{pre,post}
598 fi
599
600 [[ "${orig_c}" == "${new_c}" ]] && die "no trigger for '${from_ss}'"
601 orig_c=${new_c}
602 shift
603 shift
604 done
605
606 echo "${new_c}" > "$cf" ||
607 die "failed to update"
608}

Legend:
Removed from v.1.35  
changed lines
  Added in v.1.36

  ViewVC Help
Powered by ViewVC 1.1.20