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}
17 cp "${KERNEL_BINARY}" "${TEMP}/minkernpackage/kernel-${KV}" || gen_die 'Could not the copy kernel for the min kernel package!'
18 cp ".config" "${TEMP}/minkernpackage/config-${ARCH}-${KV}" || gen_die 'Could not the copy kernel config for the min kernel package!'
19 if isTrue "${GENZIMAGE}"
21 cp "${KERNEL_BINARY_2}" "${TEMP}/minkernpackage/kernelz-${KV}" || gen_die "Could not copy the kernelz for the min kernel package"
25 if ! isTrue "${INTEGRATED_INITRAMFS}"
27 [ "${BUILD_RAMDISK}" -ne 0 ] && { cp "${TMPDIR}/initramfs-${KV}" "${TEMP}/minkernpackage/initramfs-${ARCH}-${KV}" || gen_die 'Could not copy the initramfs for the kernel package!'; }
30 if [ "${KERNCACHE}" != "" ]
32 /bin/tar -xj -C ${TEMP}/minkernpackage -f ${KERNCACHE} System.map-${ARCH}-${KV}
34 cp "${KERNEL_DIR}/System.map" "${TEMP}/minkernpackage/System.map-${ARCH}-${KV}" || gen_die 'Could not copy System.map for the kernel package!';
37 cd "${TEMP}/minkernpackage"
38 /bin/tar -jcpf ${MINKERNPACKAGE} * || gen_die 'Could not compress the kernel package!'
39 cd "${TEMP}" && rm -rf "${TEMP}/minkernpackage" > /dev/null 2>&1
42 gen_modulespackage() {
43 print_info 1 'Creating modules package'
44 rm -rf "${TEMP}/modulespackage" > /dev/null 2>&1
45 mkdir "${TEMP}/modulespackage" || gen_die 'Could not make a directory for the kernel package!'
47 if [ -d ${INSTALL_MOD_PATH}/lib/modules/${KV} ]
49 mkdir -p ${TEMP}/modulespackage/lib/modules
50 cp -r "${INSTALL_MOD_PATH}/lib/modules/${KV}" "${TEMP}/modulespackage/lib/modules"
51 cd "${TEMP}/modulespackage"
52 /bin/tar -jcpf ${MODULESPACKAGE} * || gen_die 'Could not compress the modules package!'
54 print_info 1 "Could not create a modules package ${INSTALL_MOD_PATH}/lib/modules/${KV} was not found"
56 cd "${TEMP}" && rm -rf "${TEMP}/modulespackage" > /dev/null 2>&1
60 print_info 1 'Creating kernel cache'
61 rm -rf "${TEMP}/kerncache" > /dev/null 2>&1
62 mkdir "${TEMP}/kerncache" || gen_die 'Could not make a directory for the kernel cache!'
64 cp "${KERNEL_BINARY}" "${TEMP}/kerncache/kernel-${ARCH}-${KV}" || gen_die 'Could not the copy kernel for the kernel package!'
65 cp "${KERNEL_DIR}/.config" "${TEMP}/kerncache/config-${ARCH}-${KV}"
66 cp "${KERNEL_CONFIG}" "${TEMP}/kerncache/config-${ARCH}-${KV}.orig"
67 cp "${KERNEL_DIR}/System.map" "${TEMP}/kerncache/System.map-${ARCH}-${KV}"
68 if isTrue "${GENZIMAGE}"
70 cp "${KERNEL_BINARY_2}" "${TEMP}/kerncache/kernelz-${ARCH}-${KV}" || gen_die "Could not copy the kernelz for the kernel package"
73 echo "VERSION = ${VER}" > "${TEMP}/kerncache/kerncache.config"
74 echo "PATCHLEVEL = ${PAT}" >> "${TEMP}/kerncache/kerncache.config"
75 echo "SUBLEVEL = ${SUB}" >> "${TEMP}/kerncache/kerncache.config"
76 echo "EXTRAVERSION = ${EXV}" >> "${TEMP}/kerncache/kerncache.config"
78 mkdir -p "${TEMP}/kerncache/lib/modules/"
80 if [ -d ${INSTALL_MOD_PATH}/lib/modules/${KV} ]
82 cp -r "${INSTALL_MOD_PATH}/lib/modules/${KV}" "${TEMP}/kerncache/lib/modules"
85 cd "${TEMP}/kerncache"
86 /bin/tar -jcpf ${KERNCACHE} * || gen_die 'Could not compress the kernel package!'
87 cd "${TEMP}" && rm -rf "${TEMP}/kerncache" > /dev/null 2>&1
90 gen_kerncache_extract_kernel()
92 /bin/tar -f ${KERNCACHE} -C ${TEMP} -xj
93 copy_image_with_preserve "kernel" \
94 "${TEMP}/kernel-${ARCH}-${KV}" \
95 "kernel-${KNAME}-${ARCH}-${KV}"
97 if isTrue "${GENZIMAGE}"
99 copy_image_with_preserve "kernelz" \
100 "${TEMP}/kernelz-${ARCH}-${KV}" \
101 "kernelz-${KNAME}-${ARCH}-${KV}"
104 copy_image_with_preserve "System.map" \
105 "${TEMP}/System.map-${ARCH}-${KV}" \
106 "System.map-${KNAME}-${ARCH}-${KV}"
109 gen_kerncache_extract_modules()
111 if [ -e "${KERNCACHE}" ]
113 print_info 1 'Extracting kerncache kernel modules'
114 if [ "${INSTALL_MOD_PATH}" != '' ]
116 /bin/tar -xjf ${KERNCACHE} -C ${INSTALL_MOD_PATH} lib
118 /bin/tar -xjf ${KERNCACHE} -C / lib
123 gen_kerncache_extract_config()
125 if [ -e "${KERNCACHE}" ]
127 print_info 1 'Extracting kerncache config to /etc/kernels'
128 mkdir -p /etc/kernels
129 /bin/tar -xjf ${KERNCACHE} -C /etc/kernels config-${ARCH}-${KV}
130 mv /etc/kernels/config-${ARCH}-${KV} /etc/kernels/kernel-config-${ARCH}-${KV}
134 gen_kerncache_is_valid()
137 if [ "${NO_KERNEL_SOURCES}" = '1' ]
141 # Can make this more secure ....
143 /bin/tar -xj -f ${KERNCACHE} -C ${TEMP}
144 if [ -e ${TEMP}/config-${ARCH}-${KV} -a -e ${TEMP}/kernel-${ARCH}-${KV} ]
146 print_info 1 'Valid kernel cache found; no sources will be used'
150 if [ -e "${KERNCACHE}" ]
152 KERNEL_CONFIG="/${KERNEL_DIR}/.config"
153 if [ "${CMD_KERNEL_CONFIG}" != '' ]
155 KERNEL_CONFIG="${CMD_KERNEL_CONFIG}"
158 /bin/tar -xj -f ${KERNCACHE} -C ${TEMP}
159 if [ -e ${TEMP}/config-${ARCH}-${KV} -a -e ${KERNEL_CONFIG} ]
162 if [ -e ${TEMP}/config-${ARCH}-${KV}.orig ]
164 test1=$(grep -v "^#" ${TEMP}/config-${ARCH}-${KV}.orig | md5sum | cut -d " " -f 1)
166 test1=$(grep -v "^#" ${TEMP}/config-${ARCH}-${KV} | md5sum | cut -d " " -f 1)
168 test2=$(grep -v "^#" ${KERNEL_CONFIG} | md5sum | cut -d " " -f 1)
169 if [ "${test1}" == "${test2}" ]
173 print_info 1 "No kernel configuration change, skipping kernel build..."
180 export KERNCACHE_IS_VALID