From f4fa6d9baae702ab36333bd07f5b46b1baa32d53 Mon Sep 17 00:00:00 2001 From: Mike Hiretsky Date: Tue, 7 Sep 2010 15:33:22 +0400 Subject: [PATCH] Change cl-kernel and initrd optimization for new kernel names --- Change.log | 3 ++- install/calculate | 5 +++++ install/cl-kernel | 31 +++++++++++++++++++++++++++++-- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/Change.log b/Change.log index 1afd0fd..5bd1024 100644 --- a/Change.log +++ b/Change.log @@ -8,7 +8,8 @@ CHANGE LOG * Added the mounting of /var/calculate/remote by cl-builder. * Changed isolinux template for CSS. * Changed output kernel file names for cl-kernel. -* Add bulgarian language. +* Added bulgarian language. +* Added grub.conf changing to cl-kernel. 1.3.12 * Fix creating format a digest file. diff --git a/install/calculate b/install/calculate index 4afc839..d7f7a84 100755 --- a/install/calculate +++ b/install/calculate @@ -6531,6 +6531,11 @@ sub initrd_clean{ # получим имя файла конфигурации текущего ядра my $config=`file -L $chroot$data{scratch_ws}/boot/vmlinuz`; $config =~ s/^.*version ([^ ]+) .*$/$chroot$data{scratch_ws}\/boot\/config-\1/; + if(!-e $config ) { + $config=`file -L $chroot$data{scratch_ws}/boot/vmlinuz`; + $config =~ s/^.*version ([^ ]+) .*$/$chroot$data{scratch_ws}\/boot\/config-\1-$data{march}-$data{calculate}/; + $config =~ s/-calculate//; + } # получим список внешних модулей в ядре в chroot my @list_chroot_m=get_kernel_config(scalar `cat $config`,"m"); diff --git a/install/cl-kernel b/install/cl-kernel index 0e1a974..dd1efe1 100755 --- a/install/cl-kernel +++ b/install/cl-kernel @@ -84,6 +84,32 @@ set_kernel_version() { set_param EXTRAVERSION $KV_TYPE ${KERNEL_DIR}/Makefile } +get_stdin_value() { + sed -rn "s/^(.*\s+)?+$1=\"?([^\" ]*)\"?(\s+.*|$)/\2/p" +} + +change_kernel_in_grub() { + local ROOTDEV=$( get_stdin_value root < /proc/cmdline ) + local NAMESUFFIX=$1 + [[ -f /boot/vmlinuz-${NAMESUFFIX} ]] && + [[ -f /boot/initramfs-${NAMESUFFIX} ]] && + [[ -f /boot/initramfs-${NAMESUFFIX}-install ]] && + [[ -f /boot/grub/grub.conf ]] && + sed -ri "/^title/{ #find title in grub.conf + :readnextline;N; #read next line + s/\ninitrd/&/; #if pattern not contents initrd + Treadnextline; #goto read next line + :changemenuitem; #else try change menuitem + s|root=${ROOTDEV}|&|; #if menuitem not for the system + Tskipmenuitem; #then skip menuitem + s|(/boot/vmlinuz)[^ ]+|\1-${NAMESUFFIX}|; #else change vmlinuz + s|initrd (.*)-install$|initrd \1/install|; #hide '-install' + s|(/boot/initramfs)[^ /]+|\1-${NAMESUFFIX}|; #change initramfs + s|/install$|-install|; #show '-install' + :skipmenuitem; + }" /boot/grub/grub.conf +} + initramfs_unpack() { mkdir -p tmp/initramfs || die "Catn't create temporary directory for initramfs" @@ -186,6 +212,7 @@ install_kernel() { ${BOOT_DIR}/initramfs-${NEW_KERNEL_VERSION}-install ln -sf initramfs-${NEW_KERNEL_VERSION}-install ${BOOT_DIR}/initrd-install cp ${KERNEL_DIR}/.config ${BOOT_DIR}/config-${NEW_KERNEL_VERSION} + change_kernel_in_grub ${NEW_KERNEL_VERSION} } KERNEL_DIR=/usr/src/linux @@ -342,11 +369,11 @@ initramfs_clean initramfs_pack install_kernel set_new_current_kernel -calculate --initrd +/usr/calculate/install/calculate --initrd if [[ "$(md5sum /boot/initrd | awk '{print $1}')" == \ "$(md5sum /boot/initrd-install | awk '{print $1}')" ]] then echo echo "Perform command after reboot for optimization initramfs:" - echo " calculate --initrd" + echo " /usr/calculate/install/calculate --initrd" fi