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 tar -xj -C ${TEMP}/minkernpackage -f ${CMD_KERNCACHE} kernel-${ARCH}-${KV}
11 tar -xj -C ${TEMP}/minkernpackage -f ${CMD_KERNCACHE} config-${ARCH}-${KV}
14 cp "${KERNEL_BINARY}" "${TEMP}/minkernpackage/kernel-${KV}" || gen_die 'Could not the copy kernel for the min kernel package!'
15 cp ".config" "${TEMP}/kerncache/config-${ARCH}-${KV}" || gen_die 'Could not the copy kernel config for the min kernel package!'
17 if [ "${PAT}" -gt '4' -a "${CMD_BOOTSPLASH}" != '1' ]
19 [ "${BUILD_INITRD}" -ne 0 ] && { cp "${TEMP}/initramfs-${KV}" "${TEMP}/minkernpackage/initramfs-${ARCH}-${KV}" || gen_die 'Could not copy the initramfs for the kernel package!'; }
21 [ "${BUILD_INITRD}" -ne 0 ] && { cp "${TEMP}/initrd-${KV}" "${TEMP}/minkernpackage/initrd-${ARCH}-${KV}" || gen_die 'Could not copy the initrd for the kernel package!'; }
23 cd "${TEMP}/minkernpackage"
24 tar -jcpf ${MINKERNPACKAGE} * || gen_die 'Could not compress the kernel package!'
25 cd "${TEMP}" && rm -rf "${TEMP}/minkernpackage" > /dev/null 2>&1
29 print_info 1 'Creating modules package'
30 rm -rf "${TEMP}/modulespackage" > /dev/null 2>&1
31 mkdir "${TEMP}/modulespackage" || gen_die 'Could not make a directory for the kernel package!'
33 if [ -d ${INSTALL_MOD_PATH}/lib/modules/${KV} ]
35 mkdir -p ${TEMP}/modulespackage/lib/modules
36 cp -r "${INSTALL_MOD_PATH}/lib/modules/${KV}" "${TEMP}/modulespackage/lib/modules"
37 cd "${TEMP}/modulespackage"
38 tar -jcpf ${MODULESPACKAGE} * || gen_die 'Could not compress the modules package!'
40 print_info 1 "Could not create a modules package ${INSTALL_MOD_PATH}/lib/modules/${KV} was not found"
42 cd "${TEMP}" && rm -rf "${TEMP}/modulespackage" > /dev/null 2>&1
46 print_info 1 'Creating kernel cache'
47 rm -rf "${TEMP}/kerncache" > /dev/null 2>&1
48 mkdir "${TEMP}/kerncache" || gen_die 'Could not make a directory for the kernel cache!'
50 cp "${KERNEL_BINARY}" "${TEMP}/kerncache/kernel-${ARCH}-${KV}" || gen_die 'Could not the copy kernel for the kernel package!'
51 cp "${KERNEL_DIR}/.config" "${TEMP}/kerncache/config-${ARCH}-${KV}"
52 cp "${KERNEL_DIR}/System.map" "${TEMP}/kerncache/System.map-${ARCH}-${KV}"
54 echo "VERSION = ${VER}" > "${TEMP}/kerncache/kerncache.config"
55 echo "PATCHLEVEL = ${PAT}" >> "${TEMP}/kerncache/kerncache.config"
56 echo "SUBLEVEL = ${SUB}" >> "${TEMP}/kerncache/kerncache.config"
57 echo "EXTRAVERSION = ${EXV}" >> "${TEMP}/kerncache/kerncache.config"
59 mkdir -p "${TEMP}/kerncache/lib/modules/"
61 if [ -d ${INSTALL_MOD_PATH}/lib/modules/${KV} ]
63 cp -r "${INSTALL_MOD_PATH}/lib/modules/${KV}" "${TEMP}/kerncache/lib/modules"
66 cd "${TEMP}/kerncache"
67 tar -jcpf ${KERNCACHE} * || gen_die 'Could not compress the kernel package!'
68 cd "${TEMP}" && rm -rf "${TEMP}/kerncache" > /dev/null 2>&1
71 gen_kerncache_extract_kernel()
73 [ -d ${tmp} ] && gen_die "temporary directory already exists! Exiting."
74 (umask 077 && mkdir ${tmp}) || {
75 gen_die "Could not create temporary directory! Exiting."
77 tar -f ${KERNCACHE} -C ${tmp} -xj
78 cp "${tmp}/kernel-${ARCH}-${KV}" "/boot/kernel-${KNAME}-${ARCH}-${KV}" || {
80 gen_die 'Could not copy the kernel binary to /boot!'
82 cp "${tmp}/System.map-${ARCH}-${KV}" "/boot/System.map-${KNAME}-${ARCH}-${KV}" || {
84 gen_die 'Could not copy System.map to /boot!'
89 gen_kerncache_extract_modules()
91 if [ -e "${KERNCACHE}" ]
93 print_info 1 'Extracting kerncache kernel modules'
94 if [ "${INSTALL_MOD_PATH}" != '' ]
96 tar xjf ${KERNCACHE} -C ${INSTALL_MOD_PATH} lib
98 tar xjf ${KERNCACHE} -C / lib
103 gen_kerncache_is_valid()
106 if [ "${CMD_NO_KERNEL_SOURCES}" = '1' ]
110 # Can make this more secure ....
111 [ -d ${tmp} ] && gen_die "temporary directory already exists! Exiting."
112 (umask 077 && mkdir ${tmp}) || {
113 gen_die "Could not create temporary directory! Exiting."
116 tar -xj -f ${KERNCACHE} -C ${tmp}
117 if [ -e ${tmp}/config-${ARCH}-${KV} -a -e ${tmp}/kernel-${ARCH}-${KV} ]
119 print_info 1 'Valid kernel cache found; no sources will be used'
124 if [ -e "${KERNCACHE}" ]
126 [ -d ${tmp} ] && gen_die "temporary directory already exists! Exiting."
127 (umask 077 && mkdir ${tmp}) || {
128 gen_die "Could not create temporary directory! Exiting."
132 tar -xj -f ${KERNCACHE} -C ${tmp}
133 if [ -e ${tmp}/config-${ARCH}-${KV} -a -e /${KERNEL_DIR}/.config ]
136 test1=$(md5sum ${tmp}/config-${ARCH}-${KV} | cut -d " " -f 1)
137 test2=$(md5sum /${KERNEL_DIR}/.config | cut -d " " -f 1)
138 if [ "${test1}" == "${test2}" ]
142 print_info 1 "No kernel configuration change, skipping kernel build..."
150 export KERNCACHE_IS_VALID