/[gentoo-x86]/eclass/kernel-2.eclass
Gentoo

Diff of /eclass/kernel-2.eclass

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

Revision 1.7 Revision 1.12
13# A Couple of env vars are available to effect usage of this eclass 13# A Couple of env vars are available to effect usage of this eclass
14# These are as follows: 14# These are as follows:
15# 15#
16# K_NOSETEXTRAVERSION - if this is set then EXTRAVERSION will not be automatically set within the kernel Makefile 16# K_NOSETEXTRAVERSION - if this is set then EXTRAVERSION will not be automatically set within the kernel Makefile
17# K_NOUSENAME - if this is set then EXTRAVERSION will not include the first part of ${PN} in EXTRAVERSION 17# K_NOUSENAME - if this is set then EXTRAVERSION will not include the first part of ${PN} in EXTRAVERSION
18# K_PREPATCHED - if the patchset is prepatched (ie: mm-sources, ck-sources, ac-sources) it will use PR (ie: -r5) as the patchset version for EXTRAVERSION
19# - and not use it as a true package revision
18# K_EXTRAEINFO - this is a new-line seperated list of einfo displays in postinst and can be used to carry additional postinst messages 20# K_EXTRAEINFO - this is a new-line seperated list of einfo displays in postinst and can be used to carry additional postinst messages
21# K_EXTRAEWARN - same as K_EXTRAEINFO except ewarn's instead of einfo's
22
23# H_SUPPORTEDARCH - this should be a space separated list of ARCH's which can be supported by the headers ebuild
24
19# UNIPATCH_LIST - space delimetered list of patches to be applied to the kernel 25# UNIPATCH_LIST - space delimetered list of patches to be applied to the kernel
20# UNIPATCH_DOCS - space delimemeted list of docs to be installed to the doc dir 26# UNIPATCH_DOCS - space delimemeted list of docs to be installed to the doc dir
21 27
22ECLASS="kernel-2" 28ECLASS="kernel-2"
23EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_preinst pkg_postinst 29EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_preinst pkg_postinst
126 chmod -R a+r-w+X,u+w * 132 chmod -R a+r-w+X,u+w *
127} 133}
128 134
129install_headers() { 135install_headers() {
130 [ $(kernel_is_2_4) $? == 0 ] && unpack_2_4 136 [ $(kernel_is_2_4) $? == 0 ] && unpack_2_4
137 [ $(kernel_is_2_6) $? == 0 ] && ln -sf ${S}/include/asm-${ARCH} ${S}/include/asm
131 138
132 cd ${S} 139 cd ${S}
133 dodir /usr/include/linux 140 dodir /usr/include/linux
134 cp -ax ${S}/include/linux/* ${D}/usr/include/linux 141 cp -ax ${S}/include/linux/* ${D}/usr/include/linux
135 rm -rf ${D}/usr/include/linux/modules 142 rm -rf ${D}/usr/include/linux/modules
136 dodir /usr/include/asm 143 dodir /usr/include/asm
137 cp -ax ${S}/include/asm/* ${D}/usr/include/asm 144 cp -ax ${S}/include/asm/* ${D}/usr/include/asm
145
146 if [ $(kernel_is_2_6) $? == 0 ]
147 then
148 dodir /usr/include/asm-generic
149 cp -ax ${S}/include/asm-generic/* ${D}/usr/include/asm-generic
150 fi
138} 151}
139 152
140install_sources() { 153install_sources() {
141 local doc 154 local doc
142 local docs 155 local docs
143 156
144 cd ${S} 157 cd ${S}
145 dodir /usr/src 158 dodir /usr/src
146 echo ">>> Copying sources..." 159 echo ">>> Copying sources..."
147 if [ -d "${WORKDIR}/${KV}/docs/" ] 160 if [ -d "${WORKDIR}/${KV}/docs/" ]
148 then 161 then
149 for file in $(ls -1 ${WORKDIR}/${KV}/docs/) 162 for file in $(ls -1 ${WORKDIR}/${KV}/docs/)
150 do
151 echo "XX_${file}*" >> ${S}/patches.txt
152 cat ${WORKDIR}/${KV}/docs/${file} >> ${S}/patches.txt
153 echo "" >> ${S}/patches.txt
154 done
155 fi
156
157 if [ ! -f ${S}/patches.txt ]
158 then
159 # patches.txt is empty so lets use our ChangeLog
160 [ -f ${FILESDIR}/../ChangeLog ] && echo "Please check the ebuild ChangeLog for more details." > ${S}/patches.txt
161 fi
162
163 for doc in ${UNIPATCH_DOCS}
164 do 163 do
165 [ -f ${doc} ] && docs="${docs} ${doc}" 164 echo "XX_${file}*" >> ${S}/patches.txt
165 cat ${WORKDIR}/${KV}/docs/${file} >> ${S}/patches.txt
166 echo "" >> ${S}/patches.txt
166 done 167 done
168 fi
167 169
170 if [ ! -f ${S}/patches.txt ]
171 then
172 # patches.txt is empty so lets use our ChangeLog
173 [ -f ${FILESDIR}/../ChangeLog ] && echo "Please check the ebuild ChangeLog for more details." > ${S}/patches.txt
174 fi
175
176 for doc in ${UNIPATCH_DOCS}
177 do
178 [ -f ${doc} ] && docs="${docs} ${doc}"
179 done
180
168 if [ -f ${S}/patches.txt ]; then 181 if [ -f ${S}/patches.txt ]; then
169 docs="${docs} ${S}/patches.txt" 182 docs="${docs} ${S}/patches.txt"
170 fi 183 fi
171 dodoc ${docs} 184 dodoc ${docs}
172 mv ${WORKDIR}/linux* ${D}/usr/src 185 mv ${WORKDIR}/linux* ${D}/usr/src
173} 186}
174 187
175# pkg_preinst functions 188# pkg_preinst functions
176#============================================================== 189#==============================================================
177preinst_headers() { 190preinst_headers() {
178 [ -L ${ROOT}usr/include/linux ] && rm ${ROOT}usr/include/linux 191 [ -L ${ROOT}usr/include/linux ] && rm ${ROOT}usr/include/linux
179 [ -L ${ROOT}usr/include/asm ] && rm ${ROOT}usr/include/asm 192 [ -L ${ROOT}usr/include/asm ] && rm ${ROOT}usr/include/asm
180} 193}
181 194
182# pkg_postinst functions 195# pkg_postinst functions
183#============================================================== 196#==============================================================
184postinst_sources() { 197postinst_sources() {
205 echo ${K_EXTRAEINFO} | fmt | 218 echo ${K_EXTRAEINFO} | fmt |
206 while read -s ELINE 219 while read -s ELINE
207 do 220 do
208 einfo "${ELINE}" 221 einfo "${ELINE}"
209 done 222 done
223
224 echo
210 fi 225 fi
211 226
212 # if K_EXTRAEWARN is set then lets display it now 227 # if K_EXTRAEWARN is set then lets display it now
213 if [ -n "${K_EXTRAEWARN}" ] 228 if [ -n "${K_EXTRAEWARN}" ]
214 then 229 then
215 echo ${K_EXTRAEWARN} | fmt | 230 echo ${K_EXTRAEWARN} | fmt |
216 while read -s ELINE 231 while read -s ELINE
217 do 232 do
218 einfo "${ELINE}" 233 ewarn "${ELINE}"
219 done 234 done
235
236 echo
237 fi
238}
239
240postinst_headers() {
241 echo
242 einfo "Kernel headers are usually only used when recompiling glibc."
243 einfo "Following the installation of newer headers it is advised that"
244 einfo "you re-merge glibc as follows:"
245 einfo "# emerge glibc"
246 einfo "Failure to do so will cause glibc to not make use of newer"
247 einfo "features present in the updated kernelheaders."
248 echo
249}
250
251# pkg_setup functions
252#==============================================================
253setup_headers() {
254 ARCH=$(uname -m | sed -e s/[i].86/i386/ -e s/x86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/ -e s/amd64/x86_64/)
255 [ "$ARCH" == "sparc" -a "$PROFILE_ARCH" == "sparc64" ] && ARCH="sparc64"
256
257 [ -z "${H_SUPPORTEDARCH}" ] && H_SUPPORTEDARCH="${PN/-*/}"
258 for i in ${H_SUPPORTEDARCH}
259 do
260 [ "${ARCH}" == "${i}" ] && H_ACCEPT_ARCH="yes"
261 done
262
263 if [ "${H_ACCEPT_ARCH}" != "yes" ]
264 then
265 echo
266 eerror "This version of ${PN} does not support ${ARCH}."
267 eerror "Please merge the appropriate sources, in most cases"
268 eerror "this will be ${ARCH}-headers."
269 die "incorrect headers"
220 fi 270 fi
221} 271}
222 272
223# unipatch 273# unipatch
224#============================================================== 274#==============================================================
240 [ -z "${UNIPATCH_LIST}" ] && UNIPATCH_LIST="${@}" 290 [ -z "${UNIPATCH_LIST}" ] && UNIPATCH_LIST="${@}"
241 291
242 #unpack any passed tarballs 292 #unpack any passed tarballs
243 for i in ${UNIPATCH_LIST} 293 for i in ${UNIPATCH_LIST}
244 do 294 do
245 if [ -n "$(echo ${i} | grep -e ".tar" -e ".tbz" -e ".tgz")" ] 295 if [ -n "$(echo ${i} | grep -e "\.tar" -e "\.tbz" -e "\.tgz")" ]
246 then 296 then
247 extention=${i/*./} 297 extention=${i/*./}
248 case ${extention} in 298 case ${extention} in
249 tbz2) PIPE_CMD="tar -xvjf";; 299 tbz2) PIPE_CMD="tar -xvjf";;
250 bz2) PIPE_CMD="tar -xvjf";; 300 bz2) PIPE_CMD="tar -xvjf";;
273 extention=${i/*./} 323 extention=${i/*./}
274 PIPE_CMD="" 324 PIPE_CMD=""
275 case ${extention} in 325 case ${extention} in
276 bz2) PIPE_CMD="bzip2 -dc";; 326 bz2) PIPE_CMD="bzip2 -dc";;
277 patch) PIPE_CMD="cat";; 327 patch) PIPE_CMD="cat";;
328 diff) PIPE_CMD="cat";;
278 gz|Z|z) PIPE_CMD="gzip -dc";; 329 gz|Z|z) PIPE_CMD="gzip -dc";;
279 ZIP|zip) PIPE_CMD="unzip -p";; 330 ZIP|zip) PIPE_CMD="unzip -p";;
280 *) UNIPATCH_EXCLUDE="${UNIPATCH_EXCLUDE} ${i}";; 331 *) UNIPATCH_EXCLUDE="${UNIPATCH_EXCLUDE} ${i}";;
281 esac 332 esac
333 x=${i/*\//}
334 x=${x/\.${extention}/}
282 [ -n "${PIPE_CMD}" ] && ${PIPE_CMD} ${i} > ${KPATCH_DIR}/${i/*\//}.patch 335 [ -n "${PIPE_CMD}" ] && ${PIPE_CMD} ${i} > ${KPATCH_DIR}/${x}.patch
283 done 336 done
284 337
285 #populate KPATCH_DIRS so we know where to look to remove the excludes 338 #populate KPATCH_DIRS so we know where to look to remove the excludes
286 x=${KPATCH_DIR} 339 x=${KPATCH_DIR}
287 KPATCH_DIR="" 340 KPATCH_DIR=""
305 done 358 done
306 359
307 # and now, finally, we patch it :) 360 # and now, finally, we patch it :)
308 for x in ${KPATCH_DIR} 361 for x in ${KPATCH_DIR}
309 do 362 do
310 for i in $(find ${x} -maxdepth 1 -iname "*.patch" | sort -u) 363 for i in $(find ${x} -maxdepth 1 -iname "*.patch" -or -iname "*.diff" | sort -u)
311 do 364 do
312 365
313 366
314 PATCH_DEPTH=0 367 PATCH_DEPTH=0
315 ebegin "Applying ${i/*\//}" 368 ebegin "Applying ${i/*\//}"
367 RELEASE=${RELEASE/_rc/-rc} 420 RELEASE=${RELEASE/_rc/-rc}
368 RELEASE=${RELEASE/_pre/-bk} 421 RELEASE=${RELEASE/_pre/-bk}
369 RELEASETYPE=${RELEASE//[0-9]/} 422 RELEASETYPE=${RELEASE//[0-9]/}
370 423
371 EXTRAVERSION="${RELEASE}" 424 EXTRAVERSION="${RELEASE}"
425
426 if [ -n "${K_PREPATCHED}" ]
427 then
428 KV="${OKV}-${PN/-*/}${PR/r/}"
429 else
372 [ -z "${K_NOUSENAME}" ] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}" 430 [ -z "${K_NOUSENAME}" ] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*/}"
373 [ ! "${PR}" == "r0" ] && EXTRAVERSION="${EXTRAVERSION}-${PR}" 431 [ ! "${PR}" == "r0" ] && EXTRAVERSION="${EXTRAVERSION}-${PR}"
374 432
375 KV=${OKV}${EXTRAVERSION} 433 KV=${OKV}${EXTRAVERSION}
434 fi
376 435
377 # -rcXX-bkXX pulls are *IMPOSSIBLE* to support within the portage naming convention 436 # -rcXX-bkXX pulls are *IMPOSSIBLE* to support within the portage naming convention
378 # these cannot be supported, but the code here can handle it up until this point 437 # these cannot be supported, but the code here can handle it up until this point
379 # and theoretically thereafter. 438 # and theoretically thereafter.
380 439
382 then 441 then
383 OKV="${KV_MAJOR}.${KV_MINOR}.$([ $((${KV_PATCH} - 1)) -lt 0 ] && echo ${KV_PATCH} || echo $((${KV_PATCH} - 1)))" 442 OKV="${KV_MAJOR}.${KV_MINOR}.$([ $((${KV_PATCH} - 1)) -lt 0 ] && echo ${KV_PATCH} || echo $((${KV_PATCH} - 1)))"
384 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/testing/patch-${PV//_/-}.bz2 443 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/testing/patch-${PV//_/-}.bz2
385 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2" 444 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
386 UNIPATCH_LIST="${DISTDIR}/patch-${PV//_/-}.bz2 ${UNIPATCH_LIST}" 445 UNIPATCH_LIST="${DISTDIR}/patch-${PV//_/-}.bz2 ${UNIPATCH_LIST}"
387 KV=${PV/[-_]*/}${EXTRAVERSION} 446 [ -n "${K_PREPATCHED}" ] && KV="${PV/[-_]*/}${EXTRAVERSION}-${PN/-*/}${PR/r/}" || KV=${PV/[-_]*/}${EXTRAVERSION}
388 fi 447 fi
389 448
390 if [ "${RELEASETYPE}" == "-bk" ] 449 if [ "${RELEASETYPE}" == "-bk" ]
391 then 450 then
392 OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}" 451 OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
393 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2 452 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2
394 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2" 453 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
395 UNIPATCH_LIST="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2 ${UNIPATCH_LIST}" 454 UNIPATCH_LIST="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2 ${UNIPATCH_LIST}"
396 KV=${PV/[-_]*/}${EXTRAVERSION} 455 [ -n "${K_PREPATCHED}" ] && KV="${PV/[-_]*/}${EXTRAVERSION}-${PN/-*/}${PR/r/}" || KV=${PV/[-_]*/}${EXTRAVERSION}
397 fi 456 fi
398 457
399 if [ "${RELEASETYPE}" == "-rc-bk" ] 458 if [ "${RELEASETYPE}" == "-rc-bk" ]
400 then 459 then
401 OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))-${RELEASE/-bk*}" 460 OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))-${RELEASE/-bk*}"
402 EXTRAVERSION="$([ -n "${RELEASE}" ] && echo ${RELEASE/*-bk/-bk})$([ -n "${K_USENAME}" ] && echo -${PN/-*/})$([ ! "${PR}" == "r0" ] && echo -${PR})" 461 EXTRAVERSION="$([ -n "${RELEASE}" ] && echo ${RELEASE/*-bk/-bk})$([ -n "${K_USENAME}" ] && echo -${PN/-*/})$([ ! "${PR}" == "r0" ] && echo -${PR})"
403 462
404 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2 463 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2
405 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2" 464 mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
406 UNIPATCH_LIST="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2 ${UNIPATCH_LIST}" 465 UNIPATCH_LIST="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2 ${UNIPATCH_LIST}"
407 KV=${PV/[-_]*/}${EXTRAVERSION} 466 [ -n "${K_PREPATCHED}" ] && KV="${PV/[-_]*/}${EXTRAVERSION}-${PN/-*/}${PR/r/}" || KV=${PV/[-_]*/}${EXTRAVERSION}
408 fi 467 fi
409 468
410 S=${WORKDIR}/linux-${KV} 469 S=${WORKDIR}/linux-${KV}
411} 470}
412 471
444 [ "${ETYPE}" == "headers" ] && install_headers 503 [ "${ETYPE}" == "headers" ] && install_headers
445 [ "${ETYPE}" == "sources" ] && install_sources 504 [ "${ETYPE}" == "sources" ] && install_sources
446} 505}
447 506
448pkg_postinst() { 507pkg_postinst() {
508 [ "${ETYPE}" == "headers" ] && postinst_headers
449 [ "${ETYPE}" == "sources" ] && postinst_sources 509 [ "${ETYPE}" == "sources" ] && postinst_sources
450} 510}
511
512pkg_setup() {
513 [ "${ETYPE}" == "headers" ] && setup_headers
514}

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.12

  ViewVC Help
Powered by ViewVC 1.1.20