1 # Copyright 1999-2013 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # Author stlifey <stlifey@gmail.com>
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
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"
30 SUPPORTED_USE
="${SUPPORTED_USE/?experimental/}"
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"
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"
57 IUSE
="${IUSE} ${USE}" USE="${USE/+/}" USE="${USE/-/}"
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}"
67 aufs? ( >=sys-fs/aufs-util-3.8 )
73 if [ "${OVERRIDE_AUFS_PATCHES}" = 1 ]; then
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
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"
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"
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}"
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"
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}"
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"
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" ]]
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"
188 uksm? ( ${uksm_src} )
190 UKSM_PATCHES
="${DISTDIR}/${uksm_patch}:1"
197 for I
in ${SUPPORTED_USE}; do
203 PATCH
="${PATCH/+/}" PATCH
="${PATCH/-/}"
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}" ;;
215 features gentoo
&& REQUIRED_USE
=" experimental? ( gentoo ) "
223 UNIPATCH_STRICTORDER
="yes"
226 # never (directly or indirectly) call `use` in global scope
227 for I
in ${SUPPORTED_USE}; do
231 enable cjktty
&& UNIPATCH_EXCLUDE
="${UNIPATCH_EXCLUDE} *fbcondecor*"
235 enable aufs
&& unpack
${aufs_tarball}
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
250 enable ck
&& sed -i -e 's/\(^EXTRAVERSION :=.*$\)/# \1/' "Makefile"
253 cp -f "${WORKDIR}"/include
/uapi
/linux
/aufs_type.h include
/uapi
/linux
/aufs_type.h || die
254 cp -rf "${WORKDIR}"/{Documentation
,fs
} . || die