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 [ "${CMD_KERNCACHE}" != "" ]
10 /bin/tar -xj -C ${TEMP}/minkernpackage -f ${CMD_KERNCACHE} kernel-${ARCH}-${KV}
11 /bin/tar -xj -C ${TEMP}/minkernpackage -f ${CMD_KERNCACHE} config-${ARCH}-${KV}
12 if [ "${KERNEL_BINARY_2}" != '' -a "${GENERATE_Z_IMAGE}" = '1' ]
14 /bin/tar -xj -C ${TEMP}/minkernpackage -f ${CMD_KERNCACHE} kernelz-${ARCH}-${KV}
18 cp "${KERNEL_BINARY}" "${TEMP}/minkernpackage/kernel-${KV}" || gen_die 'Could not the copy kernel for the min kernel package!'
19 cp ".config" "${TEMP}/minkernpackage/config-${ARCH}-${KV}" || gen_die 'Could not the copy kernel config for the min kernel package!'
20 if [ "${KERNEL_BINARY_2}" != '' -a "${GENERATE_Z_IMAGE}" = '1' ]
22 cp "${KERNEL_BINARY_2}" "${TEMP}/minkernpackage/kernelz-${KV}" || gen_die "Could not copy the kernelz for the min kernel package"
27 if [ "${GENERATE_Z_IMAGE}" != '1' ]
29 if [ "${KERN_24}" != '1' -a "${CMD_BOOTSPLASH}" != '1' ]
31 [ "${BUILD_INITRD}" -ne 0 ] && { cp "${TMPDIR}/initramfs-${KV}" "${TEMP}/minkernpackage/initramfs-${ARCH}-${KV}" || gen_die 'Could not copy the initramfs for the kernel package!'; }
33 [ "${BUILD_INITRD}" -ne 0 ] && { cp "${TMPDIR}/initrd-${KV}" "${TEMP}/minkernpackage/initrd-${ARCH}-${KV}" || gen_die 'Could not copy the initrd 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
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_DIR}/System.map" "${TEMP}/kerncache/System.map-${ARCH}-${KV}"
67 if [ "${KERNEL_BINARY_2}" != '' -a "${GENERATE_Z_IMAGE}" = '1' ]
69 cp "${KERNEL_BINARY_2}" "${TEMP}/kerncache/kernelz-${ARCH}-${KV}" || gen_die "Could not copy the kernelz for the kernel package"
72 echo "VERSION = ${VER}" > "${TEMP}/kerncache/kerncache.config"
73 echo "PATCHLEVEL = ${PAT}" >> "${TEMP}/kerncache/kerncache.config"
74 echo "SUBLEVEL = ${SUB}" >> "${TEMP}/kerncache/kerncache.config"
75 echo "EXTRAVERSION = ${EXV}" >> "${TEMP}/kerncache/kerncache.config"
77 mkdir -p "${TEMP}/kerncache/lib/modules/"
79 if [ -d ${INSTALL_MOD_PATH}/lib/modules/${KV} ]
81 cp -r "${INSTALL_MOD_PATH}/lib/modules/${KV}" "${TEMP}/kerncache/lib/modules"
84 cd "${TEMP}/kerncache"
85 /bin/tar -jcpf ${KERNCACHE} * || gen_die 'Could not compress the kernel package!'
86 cd "${TEMP}" && rm -rf "${TEMP}/kerncache" > /dev/null 2>&1
89 gen_kerncache_extract_kernel()
91 /bin/tar -f ${KERNCACHE} -C ${TEMP} -xj
92 cp "${TEMP}/kernel-${ARCH}-${KV}" "${BOOTDIR}/kernel-${KNAME}-${ARCH}-${KV}" || gen_die "Could not copy the kernel binary to ${BOOTDIR}!"
93 if [ "${KERNEL_BINARY_2}" != '' -a "${GENERATE_Z_IMAGE}" = '1' ]
95 cp "${TEMP}/kernelz-${ARCH}-${KV}" "${BOOTDIR}/kernelz-${KNAME}-${ARCH}-${KV}" || gen_die "Could not copy the kernel binary to ${BOOTDIR}!"
97 cp "${TEMP}/System.map-${ARCH}-${KV}" "${BOOTDIR}/System.map-${KNAME}-${ARCH}-${KV}" || gen_die "Could not copy System.map to ${BOOTDIR}!"
100 gen_kerncache_extract_modules()
102 if [ -e "${KERNCACHE}" ]
104 print_info 1 'Extracting kerncache kernel modules'
105 if [ "${INSTALL_MOD_PATH}" != '' ]
107 /bin/tar -xjf ${KERNCACHE} -C ${INSTALL_MOD_PATH} lib
109 /bin/tar -xjf ${KERNCACHE} -C / lib
114 gen_kerncache_extract_config()
116 if [ -e "${KERNCACHE}" ]
118 print_info 1 'Extracting kerncache config to /etc/kernels'
119 mkdir -p /etc/kernels
120 /bin/tar -xjf ${KERNCACHE} -C /etc/kernels config-${ARCH}-${KV}
121 mv /etc/kernels/config-${ARCH}-${KV} /etc/kernels/kernel-config-${ARCH}-${KV}
125 gen_kerncache_is_valid()
128 if [ "${CMD_NO_KERNEL_SOURCES}" = '1' ]
132 # Can make this more secure ....
134 /bin/tar -xj -f ${KERNCACHE} -C ${TEMP}
135 if [ -e ${TEMP}/config-${ARCH}-${KV} -a -e ${TEMP}/kernel-${ARCH}-${KV} ]
137 print_info 1 'Valid kernel cache found; no sources will be used'
141 if [ -e "${KERNCACHE}" ]
143 /bin/tar -xj -f ${KERNCACHE} -C ${TEMP}
144 if [ -e ${TEMP}/config-${ARCH}-${KV} -a -e /${KERNEL_DIR}/.config ]
147 test1=$(md5sum ${TEMP}/config-${ARCH}-${KV} | cut -d " " -f 1)
148 test2=$(md5sum /${KERNEL_DIR}/.config | cut -d " " -f 1)
149 if [ "${test1}" == "${test2}" ]
153 print_info 1 "No kernel configuration change, skipping kernel build..."
160 export KERNCACHE_IS_VALID