5 print_info 1 'Creating minimal kernel package'
6 rm -rf "${TEMP}/minkernpackage" > /dev/null 2>&1
7 mkdir "${TEMP}/minkernpackage" || gen_die 'Could not make a directory for the kernel package!'
8 if [ "${KERNCACHE}" != "" ]
10 /bin/tar -xj -C ${TEMP}/minkernpackage -f ${KERNCACHE} kernel-${ARCH}-${KV}
11 /bin/tar -xj -C ${TEMP}/minkernpackage -f ${KERNCACHE} config-${ARCH}-${KV}
12 if isTrue "${GENZIMAGE}"
14 /bin/tar -xj -C ${TEMP}/minkernpackage -f ${KERNCACHE} kernelz-${ARCH}-${KV}
17 local tmp_kernel_binary=$(find_kernel_binary ${KERNEL_BINARY})
18 local tmp_kernel_binary2=$(find_kernel_binary ${KERNEL_BINARY_2})
19 if [ -z "${tmp_kernel_binary}" ]
21 gen_die "Cannot locate kernel binary"
23 cd "${KERNEL_OUTPUTDIR}"
24 cp "${tmp_kernel_binary}" "${TEMP}/minkernpackage/kernel-${KV}" || gen_die 'Could not the copy kernel for the min kernel package!'
25 cp ".config" "${TEMP}/minkernpackage/config-${ARCH}-${KV}" || gen_die 'Could not the copy kernel config for the min kernel package!'
26 if isTrue "${GENZIMAGE}"
28 cp "${tmp_kernel_binary2}" "${TEMP}/minkernpackage/kernelz-${KV}" || gen_die "Could not copy the kernelz for the min kernel package"
32 if ! isTrue "${INTEGRATED_INITRAMFS}"
34 [ "${BUILD_RAMDISK}" != '0' ] && { cp "${TMPDIR}/initramfs-${KV}" "${TEMP}/minkernpackage/initramfs-${ARCH}-${KV}" || gen_die 'Could not copy the initramfs for the kernel package!'; }
37 if [ "${KERNCACHE}" != "" ]
39 /bin/tar -xj -C ${TEMP}/minkernpackage -f ${KERNCACHE} System.map-${ARCH}-${KV}
41 cp "${KERNEL_OUTPUTDIR}/System.map" "${TEMP}/minkernpackage/System.map-${ARCH}-${KV}" || gen_die 'Could not copy System.map for the kernel package!';
44 cd "${TEMP}/minkernpackage"
45 /bin/tar -jcpf ${MINKERNPACKAGE} * || gen_die 'Could not compress the kernel package!'
46 cd "${TEMP}" && rm -rf "${TEMP}/minkernpackage" > /dev/null 2>&1
49 gen_modulespackage() {
50 print_info 1 'Creating modules package'
51 rm -rf "${TEMP}/modulespackage" > /dev/null 2>&1
52 mkdir "${TEMP}/modulespackage" || gen_die 'Could not make a directory for the kernel package!'
54 if [ -d ${INSTALL_MOD_PATH}/lib/modules/${KV} ]
56 mkdir -p ${TEMP}/modulespackage/lib/modules
57 cp -r "${INSTALL_MOD_PATH}/lib/modules/${KV}" "${TEMP}/modulespackage/lib/modules"
58 cd "${TEMP}/modulespackage"
59 /bin/tar -jcpf ${MODULESPACKAGE} * || gen_die 'Could not compress the modules package!'
61 print_info 1 "Could not create a modules package ${INSTALL_MOD_PATH}/lib/modules/${KV} was not found"
63 cd "${TEMP}" && rm -rf "${TEMP}/modulespackage" > /dev/null 2>&1
67 print_info 1 'Creating kernel cache'
68 rm -rf "${TEMP}/kerncache" > /dev/null 2>&1
69 mkdir "${TEMP}/kerncache" || gen_die 'Could not make a directory for the kernel cache!'
71 local tmp_kernel_binary=$(find_kernel_binary ${KERNEL_BINARY})
72 local tmp_kernel_binary2=$(find_kernel_binary ${KERNEL_BINARY_2})
73 if [ -z "${tmp_kernel_binary}" ]
75 gen_die "Cannot locate kernel binary"
78 cd "${KERNEL_OUTPUTDIR}"
79 cp "${tmp_kernel_binary}" "${TEMP}/kerncache/kernel-${ARCH}-${KV}" || gen_die 'Could not the copy kernel for the kernel package!'
80 cp "${KERNEL_OUTPUTDIR}/.config" "${TEMP}/kerncache/config-${ARCH}-${KV}"
82 if [[ "$(file --brief --mime-type "${KERNEL_CONFIG}")" == application/x-gzip ]]; then
83 # Support --kernel-config=/proc/config.gz, mainly
84 zcat "${KERNEL_CONFIG}" > "${TEMP}/kerncache/config-${ARCH}-${KV}.orig"
86 cp "${KERNEL_CONFIG}" "${TEMP}/kerncache/config-${ARCH}-${KV}.orig"
88 cp "${KERNEL_OUTPUTDIR}/System.map" "${TEMP}/kerncache/System.map-${ARCH}-${KV}"
89 if isTrue "${GENZIMAGE}"
91 cp "${tmp_kernel_binary2}" "${TEMP}/kerncache/kernelz-${ARCH}-${KV}" || gen_die "Could not copy the kernelz for the kernel package"
94 echo "VERSION = ${VER}" > "${TEMP}/kerncache/kerncache.config"
95 echo "PATCHLEVEL = ${PAT}" >> "${TEMP}/kerncache/kerncache.config"
96 echo "SUBLEVEL = ${SUB}" >> "${TEMP}/kerncache/kerncache.config"
97 echo "EXTRAVERSION = ${EXV}" >> "${TEMP}/kerncache/kerncache.config"
99 mkdir -p "${TEMP}/kerncache/lib/modules/"
101 if [ -d ${INSTALL_MOD_PATH}/lib/modules/${KV} ]
103 cp -r "${INSTALL_MOD_PATH}/lib/modules/${KV}" "${TEMP}/kerncache/lib/modules"
106 cd "${TEMP}/kerncache"
107 /bin/tar -jcpf ${KERNCACHE} * || gen_die 'Could not compress the kernel package!'
108 cd "${TEMP}" && rm -rf "${TEMP}/kerncache" > /dev/null 2>&1
111 gen_kerncache_extract_kernel()
113 /bin/tar -f ${KERNCACHE} -C ${TEMP} -xj
114 copy_image_with_preserve "kernel" \
115 "${TEMP}/kernel-${ARCH}-${KV}" \
116 "kernel-${KNAME}-${ARCH}-${KV}"
118 if isTrue "${GENZIMAGE}"
120 copy_image_with_preserve "kernelz" \
121 "${TEMP}/kernelz-${ARCH}-${KV}" \
122 "kernelz-${KNAME}-${ARCH}-${KV}"
125 copy_image_with_preserve "System.map" \
126 "${TEMP}/System.map-${ARCH}-${KV}" \
127 "System.map-${KNAME}-${ARCH}-${KV}"
130 gen_kerncache_extract_modules()
132 if [ -e "${KERNCACHE}" ]
134 print_info 1 'Extracting kerncache kernel modules'
135 if [ "${INSTALL_MOD_PATH}" != '' ]
137 /bin/tar -xjf ${KERNCACHE} -C ${INSTALL_MOD_PATH} lib
139 /bin/tar -xjf ${KERNCACHE} -C / lib
144 gen_kerncache_extract_config()
146 if [ -e "${KERNCACHE}" ]
148 print_info 1 'Extracting kerncache config to /etc/kernels'
149 mkdir -p /etc/kernels
150 /bin/tar -xjf ${KERNCACHE} -C /etc/kernels config-${ARCH}-${KV}
151 mv /etc/kernels/config-${ARCH}-${KV} /etc/kernels/kernel-config-${ARCH}-${KV}
155 gen_kerncache_is_valid()
158 if [ "${NO_KERNEL_SOURCES}" = '1' ]
162 # Can make this more secure ....
164 /bin/tar -xj -f ${KERNCACHE} -C ${TEMP}
165 if [ -e ${TEMP}/config-${ARCH}-${KV} -a -e ${TEMP}/kernel-${ARCH}-${KV} ]
167 print_info 1 'Valid kernel cache found; no sources will be used'
171 if [ -e "${KERNCACHE}" ]
173 KERNEL_CONFIG="/${KERNEL_OUTPUTDIR}/.config"
174 if [ "${CMD_KERNEL_CONFIG}" != '' ]
176 KERNEL_CONFIG="${CMD_KERNEL_CONFIG}"
179 /bin/tar -xj -f ${KERNCACHE} -C ${TEMP}
180 if [ -e ${TEMP}/config-${ARCH}-${KV} -a -e ${KERNEL_CONFIG} ]
183 if [ -e ${TEMP}/config-${ARCH}-${KV}.orig ]
185 test1=$(grep -v "^#" ${TEMP}/config-${ARCH}-${KV}.orig | md5sum | cut -d " " -f 1)
187 test1=$(grep -v "^#" ${TEMP}/config-${ARCH}-${KV} | md5sum | cut -d " " -f 1)
190 if [[ "$(file --brief --mime-type "${KERNEL_CONFIG}")" == application/x-gzip ]]; then
191 # Support --kernel-config=/proc/config.gz, mainly
196 test2=$("${CONFGREP}" -v "^#" ${KERNEL_CONFIG} | md5sum | cut -d " " -f 1)
199 if [ "${test1}" == "${test2}" ]
202 print_info 1 "No kernel configuration change, skipping kernel build..."
209 export KERNCACHE_IS_VALID