4 print_info 1 'Creating minimal kernel package'
5 rm -rf "${TEMP}/minkernpackage" > /dev/null 2>&1
6 mkdir "${TEMP}/minkernpackage" || gen_die 'Could not make a directory for the kernel package!'
7 if [ "${KERNCACHE}" != "" ]
9 /bin/tar -xj -C ${TEMP}/minkernpackage -f ${KERNCACHE} kernel-${ARCH}-${KV}
10 /bin/tar -xj -C ${TEMP}/minkernpackage -f ${KERNCACHE} config-${ARCH}-${KV}
11 if isTrue "${GENZIMAGE}"
13 /bin/tar -xj -C ${TEMP}/minkernpackage -f ${KERNCACHE} kernelz-${ARCH}-${KV}
16 local tmp_kernel_binary=$(find_kernel_binary ${KERNEL_BINARY})
17 local tmp_kernel_binary2=$(find_kernel_binary ${KERNEL_BINARY_2})
18 if [ -z "${tmp_kernel_binary}" ]
20 gen_die "Cannot locate kernel binary"
23 cp "${tmp_kernel_binary}" "${TEMP}/minkernpackage/kernel-${KV}" || gen_die 'Could not the copy kernel for the min kernel package!'
24 cp ".config" "${TEMP}/minkernpackage/config-${ARCH}-${KV}" || gen_die 'Could not the copy kernel config for the min kernel package!'
25 if isTrue "${GENZIMAGE}"
27 cp "${tmp_kernel_binary2}" "${TEMP}/minkernpackage/kernelz-${KV}" || gen_die "Could not copy the kernelz for the min kernel package"
31 if ! isTrue "${INTEGRATED_INITRAMFS}"
33 [ "${BUILD_RAMDISK}" -ne 0 ] && { cp "${TMPDIR}/initramfs-${KV}" "${TEMP}/minkernpackage/initramfs-${ARCH}-${KV}" || gen_die 'Could not copy the initramfs for the kernel package!'; }
36 if [ "${KERNCACHE}" != "" ]
38 /bin/tar -xj -C ${TEMP}/minkernpackage -f ${KERNCACHE} System.map-${ARCH}-${KV}
40 cp "${KERNEL_DIR}/System.map" "${TEMP}/minkernpackage/System.map-${ARCH}-${KV}" || gen_die 'Could not copy System.map for the kernel package!';
43 cd "${TEMP}/minkernpackage"
44 /bin/tar -jcpf ${MINKERNPACKAGE} * || gen_die 'Could not compress the kernel package!'
45 cd "${TEMP}" && rm -rf "${TEMP}/minkernpackage" > /dev/null 2>&1
48 gen_modulespackage() {
49 print_info 1 'Creating modules package'
50 rm -rf "${TEMP}/modulespackage" > /dev/null 2>&1
51 mkdir "${TEMP}/modulespackage" || gen_die 'Could not make a directory for the kernel package!'
53 if [ -d ${INSTALL_MOD_PATH}/lib/modules/${KV} ]
55 mkdir -p ${TEMP}/modulespackage/lib/modules
56 cp -r "${INSTALL_MOD_PATH}/lib/modules/${KV}" "${TEMP}/modulespackage/lib/modules"
57 cd "${TEMP}/modulespackage"
58 /bin/tar -jcpf ${MODULESPACKAGE} * || gen_die 'Could not compress the modules package!'
60 print_info 1 "Could not create a modules package ${INSTALL_MOD_PATH}/lib/modules/${KV} was not found"
62 cd "${TEMP}" && rm -rf "${TEMP}/modulespackage" > /dev/null 2>&1
66 print_info 1 'Creating kernel cache'
67 rm -rf "${TEMP}/kerncache" > /dev/null 2>&1
68 mkdir "${TEMP}/kerncache" || gen_die 'Could not make a directory for the kernel cache!'
70 local tmp_kernel_binary=$(find_kernel_binary ${KERNEL_BINARY})
71 local tmp_kernel_binary2=$(find_kernel_binary ${KERNEL_BINARY_2})
72 if [ -z "${tmp_kernel_binary}" ]
74 gen_die "Cannot locate kernel binary"
78 cp "${tmp_kernel_binary}" "${TEMP}/kerncache/kernel-${ARCH}-${KV}" || gen_die 'Could not the copy kernel for the kernel package!'
79 cp "${KERNEL_DIR}/.config" "${TEMP}/kerncache/config-${ARCH}-${KV}"
80 cp "${KERNEL_CONFIG}" "${TEMP}/kerncache/config-${ARCH}-${KV}.orig"
81 cp "${KERNEL_DIR}/System.map" "${TEMP}/kerncache/System.map-${ARCH}-${KV}"
82 if isTrue "${GENZIMAGE}"
84 cp "${tmp_kernel_binary2}" "${TEMP}/kerncache/kernelz-${ARCH}-${KV}" || gen_die "Could not copy the kernelz for the kernel package"
87 echo "VERSION = ${VER}" > "${TEMP}/kerncache/kerncache.config"
88 echo "PATCHLEVEL = ${PAT}" >> "${TEMP}/kerncache/kerncache.config"
89 echo "SUBLEVEL = ${SUB}" >> "${TEMP}/kerncache/kerncache.config"
90 echo "EXTRAVERSION = ${EXV}" >> "${TEMP}/kerncache/kerncache.config"
92 mkdir -p "${TEMP}/kerncache/lib/modules/"
94 if [ -d ${INSTALL_MOD_PATH}/lib/modules/${KV} ]
96 cp -r "${INSTALL_MOD_PATH}/lib/modules/${KV}" "${TEMP}/kerncache/lib/modules"
99 cd "${TEMP}/kerncache"
100 /bin/tar -jcpf ${KERNCACHE} * || gen_die 'Could not compress the kernel package!'
101 cd "${TEMP}" && rm -rf "${TEMP}/kerncache" > /dev/null 2>&1
104 gen_kerncache_extract_kernel()
106 /bin/tar -f ${KERNCACHE} -C ${TEMP} -xj
107 copy_image_with_preserve "kernel" \
108 "${TEMP}/kernel-${ARCH}-${KV}" \
109 "kernel-${KNAME}-${ARCH}-${KV}"
111 if isTrue "${GENZIMAGE}"
113 copy_image_with_preserve "kernelz" \
114 "${TEMP}/kernelz-${ARCH}-${KV}" \
115 "kernelz-${KNAME}-${ARCH}-${KV}"
118 copy_image_with_preserve "System.map" \
119 "${TEMP}/System.map-${ARCH}-${KV}" \
120 "System.map-${KNAME}-${ARCH}-${KV}"
123 gen_kerncache_extract_modules()
125 if [ -e "${KERNCACHE}" ]
127 print_info 1 'Extracting kerncache kernel modules'
128 if [ "${INSTALL_MOD_PATH}" != '' ]
130 /bin/tar -xjf ${KERNCACHE} -C ${INSTALL_MOD_PATH} lib
132 /bin/tar -xjf ${KERNCACHE} -C / lib
137 gen_kerncache_extract_config()
139 if [ -e "${KERNCACHE}" ]
141 print_info 1 'Extracting kerncache config to /etc/kernels'
142 mkdir -p /etc/kernels
143 /bin/tar -xjf ${KERNCACHE} -C /etc/kernels config-${ARCH}-${KV}
144 mv /etc/kernels/config-${ARCH}-${KV} /etc/kernels/kernel-config-${ARCH}-${KV}
148 gen_kerncache_is_valid()
151 if [ "${NO_KERNEL_SOURCES}" = '1' ]
155 # Can make this more secure ....
157 /bin/tar -xj -f ${KERNCACHE} -C ${TEMP}
158 if [ -e ${TEMP}/config-${ARCH}-${KV} -a -e ${TEMP}/kernel-${ARCH}-${KV} ]
160 print_info 1 'Valid kernel cache found; no sources will be used'
164 if [ -e "${KERNCACHE}" ]
166 KERNEL_CONFIG="/${KERNEL_DIR}/.config"
167 if [ "${CMD_KERNEL_CONFIG}" != '' ]
169 KERNEL_CONFIG="${CMD_KERNEL_CONFIG}"
172 /bin/tar -xj -f ${KERNCACHE} -C ${TEMP}
173 if [ -e ${TEMP}/config-${ARCH}-${KV} -a -e ${KERNEL_CONFIG} ]
176 if [ -e ${TEMP}/config-${ARCH}-${KV}.orig ]
178 test1=$(grep -v "^#" ${TEMP}/config-${ARCH}-${KV}.orig | md5sum | cut -d " " -f 1)
180 test1=$(grep -v "^#" ${TEMP}/config-${ARCH}-${KV} | md5sum | cut -d " " -f 1)
182 test2=$(grep -v "^#" ${KERNEL_CONFIG} | md5sum | cut -d " " -f 1)
183 if [ "${test1}" == "${test2}" ]
187 print_info 1 "No kernel configuration change, skipping kernel build..."
194 export KERNCACHE_IS_VALID