Magellan Linux

Annotation of /smage/trunk/include/kernel.sminc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1661 - (hide annotations) (download)
Sat Jan 22 23:14:38 2011 UTC (13 years, 4 months ago) by niro
Original Path: smage/branches/alx-0_6_0/include/kernel26.sminc
File size: 5513 byte(s)
added includes
1 niro 1661 # kernel26 global smage functions
2     # $Header: /alx-cvs/smage/include/kernel26.sminc,v 1.4 2006/04/03 20:08:07 niro Exp $
3    
4     # needed extra vars:
5     # ${KERNEL_TYPE}: needed, 'sources' or 'image'
6     # ${BRANCH}: needed, style branch of the kernel
7     # ${KERNEL_CONFIG}: optional, needed if you want to override the default
8     # searchpath ${SOURCEDIR}/${PNAME}/config-${PVER}-${BRANCH}-${PBUILD}
9     #
10     # ${PSUBVER}: optional, only needed for 2.6.x.x naming scheme
11     # ${EXTRAVERSION}: optinal, extra version for the kernel name
12     # default setting is ${PSUBVER}-${BRANCH}-${PBUILD}
13    
14     EXTRAVERSION="${PSUBVER}-${BRANCH}-${PBUILD}"
15     KERNEL_CONFIG="${SOURCEDIR}/${PNAME}/config-${PVER}-${BRANCH}-${PBUILD}-${ARCH}"
16    
17     kernel26_src_prepare()
18     {
19     munpack ${SRCFILE} || die
20     mv ${BUILDDIR}/linux-${PVER/${PSUBVER}/} ${SRCDIR} || die
21    
22     # fix permissions
23     chown -R 0:0 ${SRCDIR} || die
24     chmod -R a+r-w+X,u+w ${SRCDIR} || die
25    
26     cd ${SRCDIR}
27    
28     # fixes INSTALL_PATH to /boot and EXTRAVERSION
29     sed -i -e 's:#export\tINSTALL_PATH:export\tINSTALL_PATH:' \
30     -e "s:^\(EXTRAVERSION =\).*:\1 ${EXTRAVERSION}:" Makefile || die
31     }
32    
33     kernel26_src_compile()
34     {
35     cd ${SRCDIR}
36    
37     make mrproper || die
38    
39     # inject our kernel config
40     cp ${KERNEL_CONFIG} ${SRCDIR}/.config || die
41     make oldconfig || die
42    
43     case ${KERNEL_TYPE} in
44     image)
45     mmake || die
46     ;;
47    
48     sources)
49     make clean || die
50    
51     # needed to compile other programs like iptables
52     make prepare || die
53     # needed to cover >=2.6.14 builds
54     make prepare-all || die
55     make scripts || die
56    
57     # at least alsa-drivers needs this one ...
58     touch include/linux/autoconf.h || die
59     ;;
60     esac
61     }
62    
63     kernel26_image_src_install()
64     {
65     cd ${SRCDIR}
66    
67     # needed directories
68     install -d ${BINDIR}/boot || die
69    
70     # install modules
71     make INSTALL_MOD_PATH=${BINDIR} modules_install || die
72    
73     # install kernelimage
74     local my_arch="${ARCH}"
75     [[ ${my_arch} = i*86 ]] && my_arch=i386
76     install -m 0644 -o root -g root \
77     arch/${my_arch}/boot/bzImage \
78     ${BINDIR}/boot/kernel-${PVER}-${BRANCH}-${PBUILD} \
79     || die
80    
81     # install System.map
82     install -m 0644 -o root -g root \
83     System.map \
84     ${BINDIR}/boot/System.map-${PVER}-${BRANCH}-${PBUILD} \
85     || die
86    
87     # install kernel description
88     echo "
89     KRNVER=${BRANCH}-${PVER}-${ARCH}-${PBUILD}
90     KRNLIB=${PVER}-${BRANCH}-${PBUILD}
91     KRNIMG=kernel-${PVER}-${BRANCH}-${PBUILD}
92     KRNINITRD=
93     " > ${BINDIR}/boot/kernelversion || die
94    
95     # install kernel-config from srcdir
96     install -m 0644 -o root -g root \
97     .config \
98     ${BINDIR}/boot/config-${PVER}-${BRANCH}-${PBUILD} \
99     || die
100    
101     # fix build symlink
102     if [ -L ${BINDIR}/lib/modules/${PVER}-${BRANCH}-${PBUILD}/build ]
103     then
104     echo "fixing build symlink"
105     rm ${BINDIR}/lib/modules/${PVER}-${BRANCH}-${PBUILD}/build || die
106     ln -snf /usr/src/linux-${PVER}-${BRANCH}-${PBUILD} \
107     ${BINDIR}/lib/modules/${PVER}-${BRANCH}-${PBUILD}/build \
108     || die
109     fi
110    
111     # and fixing source symlink
112     if [ -L ${BINDIR}/lib/modules/${PVER}-${BRANCH}-${PBUILD}/source ]
113     then
114     echo "fixing source symlink"
115     rm ${BINDIR}/lib/modules/${PVER}-${BRANCH}-${PBUILD}/source || die
116     ln -snf /usr/src/linux-${PVER}-${BRANCH}-${PBUILD} \
117     ${BINDIR}/lib/modules/${PVER}-${BRANCH}-${PBUILD}/source \
118     || die
119     fi
120     }
121    
122     kernel26_sources_src_install()
123     {
124     cd ${BUILDDIR}
125    
126     echo "Creating linux-${PVER}-${BRANCH}-${PBUILD} sources tarball ... "
127     tar cvjf ${BUILDDIR}/linux-${PVER}-${BRANCH}-${PBUILD}.tar.bz2 $(basename ${SRCDIR}) || die
128    
129     echo "Moving linux-${PVER}-${BRANCH}-${PBUILD} tarball to \${BINDIR}/usr/src ... "
130     install -d ${BINDIR}/usr/src || die
131     mv ${BUILDDIR}/linux-${PVER}-${BRANCH}-${PBUILD}.tar.bz2 ${BINDIR}/usr/src || die
132     }
133    
134     # installs module-sources path/to/SRCDIR to MODDIR/MODNAME
135     # kernel26_external_modules_install path/to/SRCDIR DESTDIRNAME
136     kernel26_external_modules_install()
137     {
138     cd ${BUILDDIR}
139    
140     local modsrc="$1"
141     local moddest="$2"
142     local moddir="${BUILDDIR}/kernel-modules-${PVER}-${BRANCH}-${PBUILD}"
143    
144     echo "Installing ${modsrc} to ${moddir}/${moddest} ..."
145     install -d ${moddir} || die
146     mv ${modsrc} ${moddir}/${moddest} || die
147     }
148    
149     kernel26_external_modules_tarball()
150     {
151     cd ${BUILDDIR}
152    
153     echo "Creating kernel-modules-${PVER}-${BRANCH}-${PBUILD} sources tarball ... "
154     tar cvjf ${BUILDDIR}/kernel-modules-${PVER}-${BRANCH}-${PBUILD}.tar.bz2 \
155     kernel-modules-${PVER}-${BRANCH}-${PBUILD} || die
156    
157     echo "Moving kernel-modules-${PVER}-${BRANCH}-${PBUILD} tarball to \${BINDIR}/usr/src ... "
158     install -d ${BINDIR}/usr/src || die
159     mv ${BUILDDIR}/kernel-modules-${PVER}-${BRANCH}-${PBUILD}.tar.bz2 ${BINDIR}/usr/src || die
160     }
161    
162     kernel26_src_install()
163     {
164     case ${KERNEL_TYPE} in
165     image)
166     kernel26_image_src_install || die
167     ;;
168    
169     sources)
170     kernel26_sources_src_install || die
171     ;;
172     esac
173     }
174    
175     kernel_major_version()
176     {
177     local ksrc="$@"
178     local kv
179    
180     if [[ -z ${ksrc} ]]
181     then
182     kv="$(uname -r|cut -d. -f1-2)"
183     else
184     local version
185     local patchlevel
186    
187     # get version from makefile
188     version=$(grep "^VERSION[[:space:]]*=[[:space:]]*[[:digit:]]" ${ksrc}/Makefile | sed "s/^.*=[[:space:]]*\([[:digit:]]\+\)/\1/g")
189     # get patchlevel from makefile
190     patchlevel=$(grep "^PATCHLEVEL[[:space:]]*=[[:space:]]*[[:digit:]]" ${ksrc}/Makefile | sed "s/^.*=[[:space:]]*\([[:digit:]]\+\)/\1/g")
191     # kernelversion
192     kv="${version}.${patchlevel}"
193     fi
194    
195     echo "${kv}"
196     }
197    
198     mod_suffix()
199     {
200     local ksrc="$@"
201     local mod_suffix
202    
203     if [[ $(kernel_major_version ${ksrc}) = 2.6 ]]
204     then
205     mod_suffix="ko"
206     else
207     mod_suffix="o"
208     fi
209    
210     echo ${mod_suffix}
211     }
212    
213     export_inherits kernel26 src_prepare src_compile src_install