|
|
|
@ -40,6 +40,36 @@ The most common use is to run it like this, which build and install current kern
|
|
|
|
|
EOF
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Using: rm_link_with_file filename
|
|
|
|
|
rm_link_with_file() {
|
|
|
|
|
[[ -L $1 ]] && rm -f `readlink -f $1`
|
|
|
|
|
rm -f $1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Using: cp_link_with_file filename suffix
|
|
|
|
|
cp_link_with_file() {
|
|
|
|
|
if [[ -L $1 ]]
|
|
|
|
|
then
|
|
|
|
|
rm -f `readlink -f ${1}`$2
|
|
|
|
|
cp -aH ${1} `readlink -f ${1}`$2
|
|
|
|
|
ln -sf `readlink ${1}`${2} ${1}${2}
|
|
|
|
|
else
|
|
|
|
|
rm -f ${1}${2}
|
|
|
|
|
cp -aH ${1} ${1}${2}
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Using: make_old_file filename (result filename.old)
|
|
|
|
|
# Description: move filename to filename.old (support symlinking)
|
|
|
|
|
make_old_file() {
|
|
|
|
|
if [[ -e $1 ]]
|
|
|
|
|
then
|
|
|
|
|
rm_link_with_file $1.old
|
|
|
|
|
cp_link_with_file $1 .old
|
|
|
|
|
fi
|
|
|
|
|
rm_link_with_file $1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
parse_kernel_version() {
|
|
|
|
|
if [[ ${KERNEL_VERSION} =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)([-.].+)?$ ]]
|
|
|
|
|
then
|
|
|
|
@ -102,6 +132,7 @@ initramfs_clean() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
initramfs_pack() {
|
|
|
|
|
make_old_file ${BOOT_DIR}/initrd
|
|
|
|
|
# pack new initramfs
|
|
|
|
|
find * | cpio -o --quiet -H newc |
|
|
|
|
|
gzip -9 >${BOOT_DIR}/initramfs-${KERNEL_NAME}-${KERNEL_VERSION} ||
|
|
|
|
@ -122,29 +153,28 @@ rename_kernel_systemmap() {
|
|
|
|
|
die "Cann't rename System.map"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
install_kernel() {
|
|
|
|
|
make_old_file ${BOOT_DIR}/System.map
|
|
|
|
|
make_old_file ${BOOT_DIR}/vmlinuz
|
|
|
|
|
rename_kernel_systemmap
|
|
|
|
|
# change kernel (make symlink)
|
|
|
|
|
[[ -e ${BOOT_DIR}/vmlinuz ]] && rm -f ${BOOT_DIR}/vmlinuz.old &&
|
|
|
|
|
mv ${BOOT_DIR}/vmlinuz ${BOOT_DIR}/vmlinuz.old
|
|
|
|
|
ln -sf linux-${KERNEL_NAME}-${KERNEL_VERSION} ${BOOT_DIR}/vmlinuz ||
|
|
|
|
|
warning "Cann't make vmlinuz link"
|
|
|
|
|
# change System.map (make symlink)
|
|
|
|
|
ln -sf System.map-${KERNEL_NAME}-${KERNEL_VERSION} \
|
|
|
|
|
${BOOT_DIR}/System.map || warning "Cann't make System.map link"
|
|
|
|
|
# change initramfs (make symlink)
|
|
|
|
|
[[ -e ${BOOT_DIR}/initrd ]] && rm -f ${BOOT_DIR}/initrd.old &&
|
|
|
|
|
mv ${BOOT_DIR}/initrd ${BOOT_DIR}/initrd.old
|
|
|
|
|
ln -sf initramfs-${KERNEL_NAME}-${KERNEL_VERSION} ${BOOT_DIR}/initrd ||
|
|
|
|
|
warning "Cann't make initrd link"
|
|
|
|
|
# copy config
|
|
|
|
|
[[ -e ${BOOT_DIR}/config-${KERNEL_NAME}-${KERNEL_VERSION} ]] && \
|
|
|
|
|
rm -f ${BOOT_DIR}/config-${KERNEL_NAME}-${KERNEL_VERSION}.old &&
|
|
|
|
|
mv ${BOOT_DIR}/config-${KERNEL_NAME}-${KERNEL_VERSION} \
|
|
|
|
|
${BOOT_DIR}/config-${KERNEL_NAME}-${KERNEL_VERSION}.old
|
|
|
|
|
make_old_file ${BOOT_DIR}/config-${KERNEL_NAME}-${KERNEL_VERSION}
|
|
|
|
|
cp ${KERNEL_CONFIG} ${BOOT_DIR}/config-${KERNEL_NAME}-${KERNEL_VERSION}
|
|
|
|
|
# change System.map (make symlink)
|
|
|
|
|
[[ -e ${BOOT_DIR}/System.map ]] && rm -f ${BOOT_DIR}/System.map.old &&
|
|
|
|
|
mv ${BOOT_DIR}/System.map ${BOOT_DIR}/System.map.old
|
|
|
|
|
ln -sf System.map-${KERNEL_NAME}-${KERNEL_VERSION} \
|
|
|
|
|
${BOOT_DIR}/System.map ||
|
|
|
|
|
warning "Cann't make System.map link"
|
|
|
|
|
set_new_current_kernel
|
|
|
|
|
calculate --initrd
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set_new_current_kernel() {
|
|
|
|
|
# set new current kernel
|
|
|
|
|
if [[ ${KERNEL_DIR} != '/usr/src/linux' ]]
|
|
|
|
|
then
|
|
|
|
@ -162,10 +192,10 @@ install_kernel() {
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
calculate --initrd
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
make_tarball() {
|
|
|
|
|
rename_kernel_systemmap
|
|
|
|
|
# remove symlink for tarball
|
|
|
|
|
find lib -type l -delete ||
|
|
|
|
|
warning "Cann't delete symbolic links"
|
|
|
|
@ -340,6 +370,7 @@ fi
|
|
|
|
|
|
|
|
|
|
mkdir -p ${BOOT_DIR}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# run generating kernel
|
|
|
|
|
genkernel --splash=tty1 --unionfs --all-ramdisk-modules --disklabel \
|
|
|
|
|
--slowusb --kerneldir=${KERNEL_DIR} \
|
|
|
|
@ -352,6 +383,5 @@ pushd ${DESTINATION} &>/dev/null
|
|
|
|
|
initramfs_unpack
|
|
|
|
|
initramfs_clean
|
|
|
|
|
initramfs_pack
|
|
|
|
|
rename_kernel_systemmap
|
|
|
|
|
# if specified tarball then make archive else install kernel
|
|
|
|
|
[[ -n ${KERNEL_TARBALL} ]] && make_tarball || install_kernel
|
|
|
|
|