Change initrd_clean. Bugfix in cl-kernel

master 1.3.3
Mike Hiretsky 15 years ago
parent 209be49ea3
commit 26667cd1ac

@ -6472,9 +6472,42 @@ sub initrd_clean{
`$data{path} mkdir $tmpdir`;
chdir($tmpdir);
if(!-e "$chroot/boot/initrd-install"){
`$data{path} cp -a $chroot/boot/initrd $chroot/boot/initrd-install`;
my $initrd = "$chroot/boot/initrd";
# переименуем initrd-install в initrd-install.old
if(-e "${initrd}-install") {
# удалим initrd-install.old и файл на который он ссылается
my $initrd_install_old = "${initrd}-install.old";
if( -l $initrd_install_old ) {
my $real_initrd_install_old = "$chroot/boot/".readlink($initrd_install_old);
system("rm -f $real_initrd_install_old")
}
system("rm -f $initrd_install_old");
# если initrd-install ссылка
if( -l "${initrd}-install" ) {
# перемещаем ссылку и файл, добавляя суффикс .old
my $real_initrd_install_old = "$chroot/boot/".readlink("${initrd}-install").".old";
system("rm -f ".$real_initrd_install_old);
system("cp -aH ${initrd}-install $real_initrd_install_old");
system("ln -sf ".readlink("${initrd}-install").".old ${initrd}-install.old");
}
# если initrd регулярный файл
else {
system("cp -aH ${initrd}-install ${initrd}-install.old");
}
# удалим предыдущий initrd-install
system("rm -f $chroot/boot/".readlink("${initrd}-install")) if -l "${initrd}_install";
system("rm -f ${initrd}-install");
}
# скопируем текущий initrd в initrd-install
my $real_initrd_install = "${initrd}-install";
if( -l $initrd ) {
system("ln -sf ".readlink("${initrd}")."-install ${initrd}-install");
$real_initrd_install = "$chroot/boot/".readlink("${initrd}")."-install";
}
system("cp -aH ${initrd} $real_initrd_install");
# подберем утилиту для распаковки
my $archcmd;
if(!system("which lzma &>/dev/null")

@ -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

Loading…
Cancel
Save