Nuking git-alsa-utils per reports of segfaulting. (initscript vs alsactl init?)
[gentoo-diskmaster-overlay.git] / eclass / zen-sources.eclass
blobf53ad2a8f0bc65aa26ecdee5ab7905c75193a865
1 inherit versionator
2 EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_postinst
4 RESTRICT="binchecks strip primaryuri mirror"
6 DESCRIPTION="Bad ass kernel"
8 KEYWORDS="~x86 ~amd64"
10 LICENSE="GPL-2"
12 HOMEPAGE="http://www.zen-sources.org"
14 #Eclass functions only from here onwards ...
15 #==============================================================
16 detect_version() {
17         if [[ -n ${KV_FULL} ]]; then
18                 # we will set this for backwards compatibility.
19                 KV=${KV_FULL}
21                 # we know KV_FULL so lets stop here. but not without resetting S
22                 S=${WORKDIR}/linux-${KV_FULL}
23                 return
24         fi
25         CKV=${CKV:-${PV}}
26         OKV=${OKV:-${CKV}}
27         OKV=${OKV/_rc/-rc}
28         OKV=${OKV/-r*}
30         KV_MAJOR=$(get_version_component_range 1 ${OKV})
31         KV_MINOR=$(get_version_component_range 2 ${OKV})
32         KV_PATCH=$(get_version_component_range 3- ${OKV})
34         KV_PATCH=${KV_PATCH/[-_]*}
36         KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
38         RELEASE=${CKV/${OKV}}
39         RELEASE=${RELEASE/_rc/-rc}
40         RELEASETYPE=${RELEASE//[0-9]}
42         ZEN_REV=$(echo ${PR} | cut -b2)
43         ZEN_HOTFIX_REV=$(echo ${PR} | cut -b3)
45         #hackish, but should be obvious as to why this has been changed.
46         if [ "${PN}" == "zendisk-sources" ]; then
47         PATCHSET="-zendisk"
48         COMPRESSTYPE=".lzma"
49         else
50                 if [ "${PN}" == "zenrt-sources" ]; then
51                         PATCHSET="-zenrt"
52                         COMPRESSTYPE=".bz2"
53                 else
54                         if [ "${PN}" == "zenmm-sources" ]; then
55                                 PATCHSET="-zenmm"
56                                 COMPRESSTYPE=".bz2"
57                         else
58                                 PATCHSET="-zen"
59                                 COMPRESSTYPE=".bz2"
60                         fi
61                 fi
62         fi
63         EXTRAVERSION="${RELEASE}${PATCHSET}${ZEN_REV}.${ZEN_HOTFIX_REV}"
65         KV_FULL=${OKV}${EXTRAVERSION}
67         S=${WORKDIR}/linux-${KV_FULL}
68         KV=${KV_FULL}
70         if [[ ${RELEASETYPE} == -rc ]]; then
71                 OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))"
72                 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/testing/patch-${CKV//_/-}.bz2
73                                         mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${OKV}.tar.bz2"
74                 PREPATCH="patch-${CKV//_/-}"
75         else
76                 KERNEL_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}/linux-${CKV//_/-}.tar.bz2"
77         fi
78         ZEN_PATCH="${PV/_rc/-rc}${PATCHSET}${ZEN_REV}.patch${COMPRESSTYPE}"
79         if [ "${PN}" == "zendisk-sources" ]; then
80         ZEN_PATCH_URI="http://disktech.net/kernel/${ZEN_PATCH}"
81         else
82         ZEN_PATCH_URI="http://zen-sources.org/files/${ZEN_PATCH}"
83         fi
84         KERNEL_URI="${KERNEL_URI} ${ZEN_PATCH_URI}"
85         if [[ ${ZEN_HOTFIX_REV} > 0 ]]; then
86                 for ((i=1;i<=${ZEN_HOTFIX_REV};i+=1)); do
87                         ZEN_HOTFIX_PATCH="${PV/_rc/-rc}${PATCHSET}${ZEN_REV}-hotfix${i}.patch${COMPRESSTYPE}"
88                         if [ "${PN}" == "zendisk-sources" ]; then
89                         ZEN_HOTFIX_URI="http://disktech.net/kernel/${ZEN_HOTFIX_PATCH}"
90                         else
91                         ZEN_HOTFIX_URI="http://zen-sources.org/files/${ZEN_HOTFIX_PATCH}"
92                         fi
93                         KERNEL_URI="${KERNEL_URI} ${ZEN_HOTFIX_URI}"
94                 done
95         fi              
96         SRC_URI="${KERNEL_URI}"
99 PROVIDE="virtual/linux-sources virtual/alsa"
101 SLOT="${PVR}"
102 IUSE="symlink"
104 # Unpack functions
105 #==============================================================
106 universal_unpack() {
107         cd ${WORKDIR}
108         unpack linux-${OKV}.tar.bz2
109         [[ -n ${PREPATCH} ]] && unpack ${PREPATCH}.bz2
110         unpack ${ZEN_PATCH}
111         if [[ ${ZEN_HOTFIX_REV} > 0 ]]; then
112                 for ((i=1;i<=${ZEN_HOTFIX_REV};i+=1)); do
113                         HOTFIX_PATCH="${PV/_rc/-rc}${PATCHSET}${ZEN_REV}-hotfix${i}.patch${COMPRESSTYPE}"
114                         unpack ${HOTFIX_PATCH}
115                 done
116         fi
117         if [[ -d "linux" ]]; then
118                 mv linux linux-${KV_FULL} \
119                         || die "Unable to move source tree to ${KV_FULL}."
120         elif [[ "${OKV}" != "${KV_FULL}" ]]; then
121                 mv linux-${OKV} linux-${KV_FULL} \
122                         || die "Unable to move source tree to ${KV_FULL}."
123         fi
124         cd "${S}"
126         # remove all backup files
127         find . -iname "*~" -exec rm {} \; 2> /dev/null
129         # fix a problem on ppc where TOUT writes to /usr/src/linux breaking sandbox
130         # Failed patch my ass.
131 #       sed -i \
132 #               -e 's|TOUT      := .tmp_gas_check|TOUT  := $(T).tmp_gas_check|' \
133 #               "${S}"/arch/ppc/Makefile
136 unpack_set_extraversion() {
137         cd "${S}"
138         sed -i -e "s:^\(EXTRAVERSION =\).*:\1 ${EXTRAVERSION}:" Makefile
139         cd "${OLDPWD}"
142 # Should be done after patches have been applied
143 # Otherwise patches that modify the same area of Makefile will fail
144 unpack_fix_install_path() {
145         cd "${S}"
146         sed     -i -e 's:#export\tINSTALL_PATH:export\tINSTALL_PATH:' Makefile
149 # install functions
150 #==============================================================
151 install_universal() {
152         #fix silly permissions in tarball
153         cd ${WORKDIR}
154         chown -R root:0 *
155         chmod -R a+r-w+X,u+w *
156         cd ${OLDPWD}
159 install_sources() {
160         local file
162         cd "${S}"
163         dodir /usr/src
164         echo ">>> Copying sources ..."
166         mv ${WORKDIR}/linux* ${D}/usr/src
169 # pkg_postinst functions
170 #==============================================================
171 postinst_sources() {
172         local MAKELINK=0
174         # if we have USE=symlink, then force K_SYMLINK=1
175         use symlink && K_SYMLINK=1
177         # if we are to forcably symlink, delete it if it already exists first.
178         if [[ ${K_SYMLINK} > 0 ]]; then
179                 [[ -h ${ROOT}usr/src/linux ]] && rm ${ROOT}usr/src/linux
180                 MAKELINK=1
181         fi
183         # if the link doesnt exist, lets create it
184         [[ ! -h ${ROOT}usr/src/linux ]] && MAKELINK=1
186         if [[ ${MAKELINK} == 1 ]]; then
187                 cd ${ROOT}usr/src
188                 ln -sf linux-${KV_FULL} linux
189                 cd ${OLDPWD}
190         fi
192         # Don't forget to make directory for sysfs
193         [[ ! -d ${ROOT}sys ]] && kernel_is 2 6 && mkdir ${ROOT}sys
195         # if K_EXTRAEINFO is set then lets display it now
196         if [[ -n ${K_EXTRAEINFO} ]]; then
197                 echo ${K_EXTRAEINFO} | fmt |
198                 while read -s ELINE; do einfo "${ELINE}"; done
199         fi
201         # if K_EXTRAEWARN is set then lets display it now
202         if [[ -n ${K_EXTRAEWARN} ]]; then
203                 echo ${K_EXTRAEWARN} | fmt |
204                 while read -s ELINE; do ewarn "${ELINE}"; done
205         fi
208 # zenpatch
209 #==============================================================
210 zenpatch() {
211         cd ${S}
212         if [[ -n ${PREPATCH} ]]; then
213                 echo ">>> Applying -rc prepatch ... "
214                 patch -p1 -s < ${WORKDIR}/${PREPATCH}
215         fi
216         echo ">>> Applying ${PATCHSET} patch ... "
217         patch -p1 -s < ${WORKDIR}/${ZEN_PATCH/${COMPRESSTYPE}/}
218         if [[ ${ZEN_HOTFIX_REV} > 0 ]]; then
219                 for ((i=1;i<=${ZEN_HOTFIX_REV};i+=1)); do
220                         HOTFIX_PATCH="${PV/_rc/-rc}${PATCHSET}${ZEN_REV}-hotfix${i}.patch${COMPRESSTYPE}"
221                         echo ">>> Applying -hotfix${i} ... "
222                         patch -p1 -s < ${WORKDIR}/${HOTFIX_PATCH/${COMPRESSTYPE}/}
223                 done
224         fi
227 # common functions
228 #==============================================================
229 zen-sources_src_unpack() {
230         universal_unpack
232         zenpatch
234         unpack_set_extraversion
235         unpack_fix_install_path
237         cd "${S}"
240 zen-sources_src_compile() {
241         cd "${S}"
244 zen-sources_src_install() {
245         install_universal
246         install_sources
249 zen-sources_pkg_postinst() {
250         postinst_sources
253 zen-sources_pkg_setup() {
254         ABI="${KERNEL_ABI}"
255         echo ">>> Preparing to unpack ..."