net-fs/openafs-kernel: remove vulnerable versions
[gentoo.git] / eclass / dotnet.eclass
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 # @ECLASS: dotnet.eclass
6 # @MAINTAINER: cynede@gentoo.org
7 # @BLURB: common settings and functions for mono and dotnet related packages
8 # @DESCRIPTION:
9 # The dotnet eclass contains common environment settings that are useful for
10 # dotnet packages.  Currently, it provides no functions, just exports
11 # MONO_SHARED_DIR and sets LC_ALL in order to prevent errors during compilation
12 # of dotnet packages.
13
14 case ${EAPI:-0} in
15         0) die "this eclass doesn't support EAPI 0" ;;
16         1|2|3) ;;
17         *) ;; #if [[ ${USE_DOTNET} ]]; then REQUIRED_USE="|| (${USE_DOTNET})"; fi;;
18 esac
19
20 inherit eutils versionator mono-env
21
22 # @ECLASS-VARIABLE: USE_DOTNET
23 # @DESCRIPTION:
24 # Use flags added to IUSE
25
26 DEPEND+=" dev-lang/mono"
27
28 # SET default use flags according on DOTNET_TARGETS
29 for x in ${USE_DOTNET}; do
30         case ${x} in
31                 net45) if [[ ${DOTNET_TARGETS} == *net45* ]]; then IUSE+=" +net45"; else IUSE+=" net45"; fi;;
32                 net40) if [[ ${DOTNET_TARGETS} == *net40* ]]; then IUSE+=" +net40"; else IUSE+=" net40"; fi;;
33                 net35) if [[ ${DOTNET_TARGETS} == *net35* ]]; then IUSE+=" +net35"; else IUSE+=" net35"; fi;;
34                 net20) if [[ ${DOTNET_TARGETS} == *net20* ]]; then IUSE+=" +net20"; else IUSE+=" net20"; fi;;
35         esac
36 done
37
38 # @FUNCTION: dotnet_pkg_setup
39 # @DESCRIPTION:
40 # This function set FRAMEWORK.
41 dotnet_pkg_setup() {
42         for x in ${USE_DOTNET} ; do
43                 case ${x} in
44                         net45) if use net45; then F="4.5"; fi;;
45                         net40) if use net40; then F="4.0"; fi;;
46                         net35) if use net35; then F="3.5"; fi;;
47                         net20) if use net20; then F="2.0"; fi;;
48                 esac
49                 if [[ -z ${FRAMEWORK} ]]; then
50                         if [[ ${F} ]]; then
51                                 FRAMEWORK="${F}";
52                         fi
53                 else
54                         version_is_at_least "${F}" "${FRAMEWORK}" || FRAMEWORK="${F}"
55                 fi
56         done
57         if [[ -z ${FRAMEWORK} ]]; then
58                 FRAMEWORK="4.0"
59         fi
60         einfo " -- USING .NET ${FRAMEWORK} FRAMEWORK -- "
61 }
62
63 # >=mono-0.92 versions using mcs -pkg:foo-sharp require shared memory, so we set the
64 # shared dir to ${T} so that ${T}/.wapi can be used during the install process.
65 export MONO_SHARED_DIR="${T}"
66
67 # Building mono, nant and many other dotnet packages is known to fail if LC_ALL
68 # variable is not set to C. To prevent this all mono related packages will be
69 # build with LC_ALL=C (see bugs #146424, #149817)
70 export LC_ALL=C
71
72 # Monodevelop-using applications need this to be set or they will try to create config
73 # files in the user's ~ dir.
74
75 export XDG_CONFIG_HOME="${T}"
76
77 # Fix bug 83020:
78 # "Access Violations Arise When Emerging Mono-Related Packages with MONO_AOT_CACHE"
79
80 unset MONO_AOT_CACHE
81
82 # @FUNCTION: exbuild
83 # @DESCRIPTION:
84 # Run xbuild with Release configuration and configurated FRAMEWORK.
85 exbuild() {
86         elog "xbuild ""$@"" /p:Configuration=Release /tv:4.0 /p:TargetFrameworkVersion=v""${FRAMEWORK}"" || die"
87         xbuild "$@" /p:Configuration=Release /tv:4.0 /p:TargetFrameworkVersion=v"${FRAMEWORK}" || die
88 }
89
90 # @FUNCTION: egacinstall
91 # @DESCRIPTION:
92 # Install package to GAC.
93 egacinstall() {
94         use !prefix && has "${EAPI:-0}" 0 1 2 && ED="${D}"
95         gacutil -i "${1}" \
96                 -root "${ED}"/usr/$(get_libdir) \
97                 -gacdir /usr/$(get_libdir) \
98                 -package ${2:-${GACPN:-${PN}}} \
99                 || die "installing ${1} into the Global Assembly Cache failed"
100 }
101
102 # @FUNCTION: dotnet_multilib_comply
103 # @DESCRIPTION:
104 # multilib comply
105 dotnet_multilib_comply() {
106         use !prefix && has "${EAPI:-0}" 0 1 2 && ED="${D}"
107         local dir finddirs=() mv_command=${mv_command:-mv}
108         if [[ -d "${ED}/usr/lib" && "$(get_libdir)" != "lib" ]]
109         then
110                 if ! [[ -d "${ED}"/usr/"$(get_libdir)" ]]
111                 then
112                         mkdir "${ED}"/usr/"$(get_libdir)" || die "Couldn't mkdir ${ED}/usr/$(get_libdir)"
113                 fi
114                 ${mv_command} "${ED}"/usr/lib/* "${ED}"/usr/"$(get_libdir)"/ || die "Moving files into correct libdir failed"
115                 rm -rf "${ED}"/usr/lib
116                 for dir in "${ED}"/usr/"$(get_libdir)"/pkgconfig "${ED}"/usr/share/pkgconfig
117                 do
118
119                         if [[ -d "${dir}" && "$(find "${dir}" -name '*.pc')" != "" ]]
120                         then
121                                 pushd "${dir}" &> /dev/null
122                                 sed  -i -r -e 's:/(lib)([^a-zA-Z0-9]|$):/'"$(get_libdir)"'\2:g' \
123                                         *.pc \
124                                         || die "Sedding some sense into pkgconfig files failed."
125                                 popd "${dir}" &> /dev/null
126                         fi
127                 done
128                 if [[ -d "${ED}/usr/bin" ]]
129                 then
130                         for exe in "${ED}/usr/bin"/*
131                         do
132                                 if [[ "$(file "${exe}")" == *"shell script text"* ]]
133                                 then
134                                         sed -r -i -e ":/lib(/|$): s:/lib(/|$):/$(get_libdir)\1:" \
135                                                 "${exe}" || die "Sedding some sense into ${exe} failed"
136                                 fi
137                         done
138                 fi
139
140         fi
141 }
142
143 EXPORT_FUNCTIONS pkg_setup