net-misc/baidunetdisk: Fix missed RDEPEND
[gentoo-zh.git] / eclass / e-sources.eclass
blob9c05988e53a895dc34daca022a53de1515240c8f
1 # Copyright 1999-2013 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # Author stlifey <stlifey@gmail.com>
4 # $Header: $
6 # e-sources.eclass - Eclass for building sys-kernel/e-sources-* packages , provide patches including :
8 # additional - misc kernel patch
9 # aufs - advanced multi layered unification filesystem
10 # cjktty - cjk font support for tty
11 # ck - con kolivas's high performance patchset
12 # gentoo - gentoo linux kernel patches called genpatches
13 # reiser4 - reiser4 filesystem support
14 # thinkpad - a set of lenovo thinkpad patches
15 # tuxonice - tuxonice support - another linux hibernate system
16 # uksm - ultra kernel samepage merging support
19 features() {
20 if [ "${SUPPORTED_USE/$1/}" != "$SUPPORTED_USE" ]; then
21 return 0; else return 1; fi
24 enable() { if features $1 && use $1; then return 0; else return 1; fi }
26 if features gentoo; then
27 K_GENPATCHES_VER="$gentoo_version"
28 K_WANT_GENPATCHES="base extras experimental"
29 else
30 SUPPORTED_USE="${SUPPORTED_USE/?experimental/}"
33 ETYPE="sources"
34 inherit kernel-2 versionator
36 K_SECURITY_UNSUPPORTED="1"
38 KMV="$(get_version_component_range 1-2)"
39 KMMV="$(get_version_component_range 1)"
40 KMINOR="$(get_version_component_range 2)"
41 KMSV="$(get_version_component_range 1).0"
43 SLOT="${KMV}"
45 features optimization && \
46 RDEPEND="optimization? ( >=sys-devel/gcc-4.8 )"
48 if features gentoo; then
49 HOMEPAGE="http://dev.gentoo.org/~mpagano/genpatches"
50 SRC_URI="${GENPATCHES_URI}"
53 DESCRIPTION="Full sources for the Linux kernel including: gentoo, ck and other patches"
55 USE_ENABLE() {
56 local USE=$1
57 IUSE="${IUSE} ${USE}" USE="${USE/+/}" USE="${USE/-/}"
59 case ${USE} in
61 aufs) aufs_url="http://aufs.sourceforge.net"
62 aufs_tarball="aufs-sources-${aufs_kernel_version}.tar.xz"
63 aufs_src="http://dev.gentoo.org/~jlec/distfiles/aufs-sources-${aufs_kernel_version}.tar.xz"
64 HOMEPAGE="${HOMEPAGE} ${aufs_url}"
65 RDEPEND="
66 ${RDEPEND}
67 aufs? ( >=sys-fs/aufs-util-3.8 )
69 SRC_URI="
70 ${SRC_URI}
71 aufs? ( ${aufs_src} )
73 if [ "${OVERRIDE_AUFS_PATCHES}" = 1 ]; then
74 AUFS_PATCHES="
75 ${FILESDIR}/${KMV}/aufs/aufs${KMMV}-kbuild.patch
76 ${FILESDIR}/${KMV}/aufs/aufs${KMMV}-base.patch
77 ${FILESDIR}/${KMV}/aufs/aufs${KMMV}-mmap.patch
78 ${FILESDIR}/${KMV}/aufs/aufs${KMMV}-standalone.patch
80 else
81 AUFS_PATCHES="
82 ${WORKDIR}/aufs${KMMV}-kbuild.patch
83 ${WORKDIR}/aufs${KMMV}-base.patch
84 ${WORKDIR}/aufs${KMMV}-mmap.patch
85 ${WORKDIR}/aufs${KMMV}-standalone.patch
90 cjktty) cjktty_url="http://sourceforge.net/projects/cjktty"
91 CJKKMV="$(get_version_component_range 1-2 $cjktty_kernel_version)"
92 if [[ "${cjktty_kernel_version/$CJKKMV./}" = "0" ]]
93 then cjktty_patch="${CJKKMV}-utf8.diff"
94 else cjktty_patch="${cjktty_kernel_version}-utf8.diff"
96 cjktty_src="https://github.com/gentoo-zh/linux-cjktty/compare/${cjktty_patch}"
97 HOMEPAGE="${HOMEPAGE} ${cjktty_url}"
98 if [ "${OVERRIDE_CJKTTY_PATCHES}" = 1 ]; then
99 CJKTTY_PATCHES="${FILESDIR}/${KMV}/${cjktty_patch}:1"
100 else
101 SRC_URI="
102 ${SRC_URI}
103 cjktty? ( ${cjktty_src} )
105 CJKTTY_PATCHES="${DISTDIR}/${cjktty_patch}:1"
109 ck) ck_url="http://ck.kolivas.org/patches"
110 if [[ "${KMMV}" < "4" || "${KMINOR}" < "2" ]]; then
111 ck_patch="${KMV}-ck${ck_version}-broken-out.tar.bz2"
112 else
113 ck_patch="${KMV}-ck${ck_version}-broken-out.tar.xz"
115 ck_src="${ck_url}/${KMSV}/${KMV}/${KMV}-ck${ck_version}/${ck_patch}"
116 HOMEPAGE="${HOMEPAGE} ${ck_url}"
117 if [ "${OVERRIDE_CK_PATCHES}" = 1 ]; then
118 CK_PATCHES="${FILESDIR}/${KMV}/${ck_patch}"
119 else
120 SRC_URI="
121 ${SRC_URI}
122 ck? ( ${ck_src} )
124 CK_PATCHES="${DISTDIR}/${ck_patch}"
129 reiser4) reiser4_url="http://sourceforge.net/projects/reiser4"
130 reiser4_patch="reiser4-for-${reiser4_kernel_version}.patch.gz"
131 reiser4_src="${reiser4_url}/files/reiser4-for-linux-${KMMV}.x/${reiser4_patch}"
132 HOMEPAGE="${HOMEPAGE} ${reiser4_url}"
133 if [ "${OVERRIDE_REISER4_PATCHES}" = 1 ]; then
134 REISER4_PATCHES="${FILESDIR}/${KMV}/${reiser4_patch}:1"
135 else
136 SRC_URI="
137 ${SRC_URI}
138 reiser4? ( ${reiser4_src} )
140 REISER4_PATCHES="${DISTDIR}/${reiser4_patch}:1"
144 tuxonice) tuxonice_url="http://tuxonice.net"
145 ICEKMV="$(get_version_component_range 1-2 $tuxonice_kernel_version)"
146 if [[ "${tuxonice_kernel_version/$ICEKMV./}" = "0" ]]
147 then tuxonice_patch="tuxonice-for-linux-head-${tuxonice_kernel_version}-${tuxonice_version//./-}.patch.bz2"
148 else tuxonice_patch="tuxonice-for-linux-${tuxonice_kernel_version}-${tuxonice_version//./-}.patch.bz2"
150 tuxonice_src="${tuxonice_url}/downloads/all/${tuxonice_patch}"
151 HOMEPAGE="${HOMEPAGE} ${tuxonice_url}"
152 RDEPEND="
153 ${RDEPEND}
154 tuxonice? ( >=sys-apps/tuxonice-userui-1.0 ( || ( >=sys-power/hibernate-script-2.0 sys-power/pm-utils ) ) )
156 if [ "${OVERRIDE_TUXONICE_PATCHES}" = 1 ]; then
157 TUXONICE_PATCHES="${FILESDIR}/${KMV}/${tuxonice_patch}:1"
158 else
159 SRC_URI="
160 ${SRC_URI}
161 tuxonice? ( ${tuxonice_src} )
163 TUXONICE_PATCHES="${DISTDIR}/${tuxonice_patch}:1"
167 uksm) uksm_url="http://kerneldedup.org"
168 UKSMKMV=${uksm_kernel_version:0:4}
169 UKSMKMV="$(get_version_component_range 1-2 $uksm_kernel_version)"
170 if [[ "${uksm_kernel_version/$UKSMKMV./}" = "0" ]]
171 then
172 if [[ $uksm_version == *beta* ]]
173 then uksm_patch="uksm-${uksm_version}-for-linux-v${UKSMKMV}.patch"
174 else uksm_patch="uksm-${uksm_version}-for-v${UKSMKMV}.patch"
176 else uksm_patch="uksm-${uksm_version}-for-v${UKSMKMV}.ge.${uksm_kernel_version/$UKSMKMV./}.patch"
178 if [[ $uksm_version == *beta* ]]
179 then uksm_src="${uksm_url}/download/uksm/beta/${uksm_patch}"
180 else uksm_src="${uksm_url}/download/uksm/${uksm_version}/${uksm_patch}"
182 HOMEPAGE="${HOMEPAGE} ${uksm_url}"
183 if [ "${OVERRIDE_UKSM_PATCHES}" = 1 ]; then
184 UKSM_PATCHES="${FILESDIR}/${KMV}/${uksm_patch}:1"
185 else
186 SRC_URI="
187 ${SRC_URI}
188 uksm? ( ${uksm_src} )
190 UKSM_PATCHES="${DISTDIR}/${uksm_patch}:1"
194 esac
197 for I in ${SUPPORTED_USE}; do
198 USE_ENABLE "${I}"
199 done
201 PATCH_APPEND() {
202 local PATCH=$1
203 PATCH="${PATCH/+/}" PATCH="${PATCH/-/}"
205 case ${PATCH} in
206 aufs) use aufs && UNIPATCH_LIST="${UNIPATCH_LIST} ${AUFS_PATCHES}" ;;
207 cjktty) use cjktty && UNIPATCH_LIST="${UNIPATCH_LIST} ${CJKTTY_PATCHES}" ;;
208 ck) use ck && UNIPATCH_LIST="${UNIPATCH_LIST} ${CK_PATCHES}" ;;
209 reiser4) use reiser4 && UNIPATCH_LIST="${UNIPATCH_LIST} ${REISER4_PATCHES}" ;;
210 tuxonice) use tuxonice && UNIPATCH_LIST="${UNIPATCH_LIST} ${TUXONICE_PATCHES}" ;;
211 uksm) use uksm && UNIPATCH_LIST="${UNIPATCH_LIST} ${UKSM_PATCHES}" ;;
212 esac
215 features gentoo && REQUIRED_USE=" experimental? ( gentoo ) "
217 SRC_URI="
218 ${SRC_URI}
219 ${ARCH_URI}
220 ${KERNEL_URI}
223 UNIPATCH_STRICTORDER="yes"
225 pkg_setup() {
226 # never (directly or indirectly) call `use` in global scope
227 for I in ${SUPPORTED_USE}; do
228 PATCH_APPEND "${I}"
229 done
231 enable cjktty && UNIPATCH_EXCLUDE="${UNIPATCH_EXCLUDE} *fbcondecor*"
234 src_unpack() {
235 enable aufs && unpack ${aufs_tarball}
236 kernel-2_src_unpack
238 local patch
239 for patch in additional ck thinkpad tuxonice ; do
240 if enable ${patch}; then
241 EPATCH_SOURCE="${FILESDIR}/${KMV}/${patch}" EPATCH_FORCE="yes" \
242 EPATCH_SUFFIX="diff" epatch
243 EPATCH_SOURCE="${FILESDIR}/${KMV}/${patch}" EPATCH_FORCE="yes" \
244 EPATCH_SUFFIX="patch" epatch
246 done
249 src_prepare() {
250 enable ck && sed -i -e 's/\(^EXTRAVERSION :=.*$\)/# \1/' "Makefile"
252 if enable aufs; then
253 cp -f "${WORKDIR}"/include/uapi/linux/aufs_type.h include/uapi/linux/aufs_type.h || die
254 cp -rf "${WORKDIR}"/{Documentation,fs} . || die