Added a patch by John R. Graham <john_r_graham@mindspring.com> from bug #169383 to improve the --symlink option fairly significantly. This is going to be 3.4.7_pre4 and while I haven't tested this yet, it looks good.

git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/genkernel/trunk@494 67a159dc-881f-0410-a524-ba9dfbe2cb84
cleanup-cruft
Chris Gianelloni 18 years ago
parent f06ba4e9e7
commit 89c7fbdde5

@ -2,6 +2,13 @@
# Copyright 2006-2007 Gentoo Foundation; Distributed under the GPL v2
# $Header: $
09 Mar 2007; Chris Gianelloni <wolf31o2@gentoo.org> gen_compile.sh,
gen_determineargs.sh, gen_funcs.sh, gen_initramfs.sh, gen_initrd.sh,
gen_package.sh, genkernel:
Added a patch by John R. Graham <john_r_graham@mindspring.com> from bug
#169383 to improve the --symlink option fairly significantly. This is going
to be 3.4.7_pre4 and while I haven't tested this yet, it looks good.
09 Mar 2007; Chris Gianelloni <wolf31o2@gentoo.org> gen_initramfs.sh:
Fixed lib64 link for bug #168664.

@ -183,6 +183,7 @@ reset_args()
fi
}
compile_generic() {
local RET
[ "$#" -lt '2' ] &&
@ -298,14 +299,19 @@ compile_kernel() {
fi
if ! isTrue "${CMD_NOINSTALL}"
then
cp "${KERNEL_BINARY}" "${BOOTDIR}/kernel-${KNAME}-${ARCH}-${KV}" ||
gen_die 'Could not copy the kernel binary to ${BOOTDIR}!'
cp "System.map" "${BOOTDIR}/System.map-${KNAME}-${ARCH}-${KV}" ||
gen_die 'Could not copy System.map to ${BOOTDIR}!'
copy_image_with_preserve "kernel" \
"${KERNEL_BINARY}" \
"kernel-${KNAME}-${ARCH}-${KV}"
copy_image_with_preserve "System.map" \
"System.map" \
"System.map-${KNAME}-${ARCH}-${KV}"
if [ "${KERNEL_BINARY_2}" != '' -a "${GENERATE_Z_IMAGE}" = '1' ]
then
cp "${KERNEL_BINARY_2}" "${BOOTDIR}/kernelz-${KV}" ||
gen_die 'Could not copy the kernelz binary to ${BOOTDIR}!'
copy_image_with_preserve "kernelz" \
"${KERNEL_BINARY_2}" \
"kernelz-${KV}"
fi
else
cp "${KERNEL_BINARY}" "${TMPDIR}/kernel-${KNAME}-${ARCH}-${KV}" ||

@ -363,7 +363,12 @@ determine_real_args() {
SAVE_CONFIG=0
fi
if isTrue "${CMD_SYMLINK}"
if [ "${CMD_SYMLINK}" != '' ]
then
SYMLINK="${CMD_SYMLINK}"
fi
if isTrue "${SYMLINK}"
then
SYMLINK=1
else

@ -290,3 +290,141 @@ then
done
fi
}
#
# Function to copy various kernel boot image products to the boot directory,
# preserve a generation of old images (just like the manual kernel build's
# "make install" does), and maintain the symlinks (if enabled).
#
# Arguments:
# $1 Symlink name. Symlink on the boot directory. Path not included.
# $2 Source image. Fully qualified path name of the source image.
# $3 Dest image. Name of the destination image in the boot directory,
# no path included. This script pushd's into ${BOOTDIR} in order to
# create relative symlinks just like the manual kernel build.
#
# - JRG
#
copy_image_with_preserve() {
local symlinkName=$1
local newSrceImage=$2
local fullDestName=$3
local currDestImage
local prevDestImage
local currDestImageExists=0
local prevDestImageExists=0
print_info 4 "Copying new ${symlinkName} image, " 0
# Old product might be a different version. If so, we need to read
# the symlink to see what it's name is, if there are symlinks.
if [ "${SYMLINK}" -eq '1' ]
then
print_info 4 "automatically managing symlinks and old images." 1 0
if [ -e "${BOOTDIR}/${symlinkName}" ]
then
# JRG: Do I need a special case here for when the standard symlink
# name is, in fact, not a symlink?
currDestImage=`readlink --no-newline ${BOOTDIR}/${symlinkName}`
print_info 5 " Current ${symlinkName} symlink exists:"
print_info 5 " ${currDestImage}"
else
currDestImage="${fullDestName}"
print_info 5 " Current ${symlinkName} symlink did not exist."
print_info 5 " Defaulted to: ${currDestImage}"
fi
if [ -e "${BOOTDIR}/${currDestImage}" ]
then
currDestImageExists=1
print_info 5 " Actual image file exists."
fi
if [ -e "${BOOTDIR}/${symlinkName}.old" ]
then
# JRG: Do I need a special case here for when the standard symlink
# name is, in fact, not a symlink?
prevDestImage=`readlink --no-newline ${BOOTDIR}/${symlinkName}.old`
print_info 5 " Old ${symlinkName} symlink exists:"
print_info 5 " ${prevDestImage}"
else
prevDestImage="${fullDestName}.old"
print_info 5 " Old ${symlinkName} symlink did not exist."
print_info 5 " Defaulted to: ${prevDestImage}"
fi
if [ -e "${BOOTDIR}/${prevDestImage}" ]
then
prevDestImageExists=1
print_info 5 " Actual old image file exists."
fi
else
print_info 4 "symlinks not being handled by genkernel." 1 0
currDestImage="${fullDestName}"
prevDestImage="${fullDestName}.old"
fi
# When symlinks are not being managed by genkernel, old symlinks might
# still be useful. Leave 'em alone unless managed.
if [ "${SYMLINK}" -eq '1' ]
then
print_info 5 " Deleting old symlinks, if any."
rm -f "${BOOTDIR}/${symlinkName}"
rm -f "${BOOTDIR}/${symlinkName}.old"
fi
# We only erase the old image when it is the exact same version as the
# current image. Different version old images are left behind. This is
# consistent with how "make install" of the manual kernel build works.
if [ "${currDestImage}.old" == "${prevDestImage}" ]
then
#
# Case for current / old of the same base version.
#
print_info 5 " Same base version. May have to delete old image to make room."
if [ "${prevDestImageExists}" -eq '1' ]
then
print_info 5 " Deleting old identical version ${symlinkName}."
rm -f "${BOOTDIR}/${prevDestImage}"
fi
if [ "${currDestImageExists}" -eq '1' ]
then
print_info 5 " Moving ${BOOTDIR}/${currDestImage}"
print_info 5 " to ${BOOTDIR}/${currDestImage}.old"
mv "${BOOTDIR}/${currDestImage}" "${BOOTDIR}/${currDestImage}.old" ||
gen_die "Could not rename the old ${symlinkName} image!"
fi
else
#
# Case for current / old not of the same base version.
#
print_info 5 " Different base version. Do not delete old iamges."
if [ "${currDestImageExists}" -eq 1 ]
then
prevDestImage="${currDestImage}"
currDestImage="${fullDestName}"
fi
fi
print_info 5 " Copying ${symlinkName}: ${newSrceImage}"
print_info 5 " to ${BOOTDIR}/${currDestImage}"
cp "${newSrceImage}" "${BOOTDIR}/${currDestImage}" ||
gen_die "Could not copy the ${symlinkName} image to ${BOOTDIR}!"
if [ "${SYMLINK}" -eq '1' ]
then
print_info 5 " Make new symlink(s) (from ${BOOTDIR}):"
print_info 5 " ${symlinkName} -> ${currDestImage}"
pushd ${BOOTDIR} >/dev/null
ln -s "${currDestImage}" "${symlinkName}" ||
gen_die "Could not create the ${symlinkName} symlink!"
if [ "${currDestImageExists}" -eq '1' ]
then
print_info 5 " ${symlinkName}.old -> ${prevDestImage}"
ln -s "${prevDestImage}" "${symlinkName}.old" ||
gen_die "Could not create the ${symlinkName}.old symlink!"
fi
popd >/dev/null
fi
}

@ -527,8 +527,9 @@ create_initramfs() {
then
if [ "${GENERATE_Z_IMAGE}" != '1' ]
then
cp ${TMPDIR}/initramfs-${KV} ${BOOTDIR}/initramfs-${KNAME}-${ARCH}-${KV} ||
gen_die 'Could not copy the initramfs to ${BOOTDIR}!'
copy_image_with_preserve "initramfs" \
"${TMPDIR}/initramfs-${KV}" \
"initramfs-${KNAME}-${ARCH}-${KV}"
fi
fi
}

@ -437,8 +437,9 @@ create_initrd() {
fi
if ! isTrue "${CMD_NOINSTALL}"
then
cp ${TMPDIR}/initrd-${KV} ${BOOTDIR}/initrd-${KNAME}-${ARCH}-${KV} ||
gen_die 'Could not copy the initrd to ${BOOTDIR}!'
copy_image_with_preserve "initrd" \
"${TMPDIR}/initrd-${KV}" \
"initrd-${KNAME}-${ARCH}-${KV}"
fi
# Pegasos hack for merging the initrd into the kernel at compile time

@ -88,13 +88,21 @@ gen_kerncache()
gen_kerncache_extract_kernel()
{
/bin/tar -f ${KERNCACHE} -C ${TEMP} -xj
cp "${TEMP}/kernel-${ARCH}-${KV}" "${BOOTDIR}/kernel-${KNAME}-${ARCH}-${KV}" || gen_die "Could not copy the kernel binary to ${BOOTDIR}!"
/bin/tar -f ${KERNCACHE} -C ${TEMP} -xj
copy_image_with_preserve "kernel" \
"${TEMP}/kernel-${ARCH}-${KV}" \
"kernel-${KNAME}-${ARCH}-${KV}"
if [ "${KERNEL_BINARY_2}" != '' -a "${GENERATE_Z_IMAGE}" = '1' ]
then
cp "${TEMP}/kernelz-${ARCH}-${KV}" "${BOOTDIR}/kernelz-${KNAME}-${ARCH}-${KV}" || gen_die "Could not copy the kernel binary to ${BOOTDIR}!"
fi
cp "${TEMP}/System.map-${ARCH}-${KV}" "${BOOTDIR}/System.map-${KNAME}-${ARCH}-${KV}" || gen_die "Could not copy System.map to ${BOOTDIR}!"
then
copy_image_with_preserve "kernelz" \
"${TEMP}/kernelz-${ARCH}-${KV}" \
"kernelz-${KNAME}-${ARCH}-${KV}"
fi
copy_image_with_preserve "System.map" \
"${TEMP}/System.map-${ARCH}-${KV}" \
"System.map-${KNAME}-${ARCH}-${KV}"
}
gen_kerncache_extract_modules()

@ -2,7 +2,7 @@
# Genkernel v3
PATH="/bin:/usr/bin:/sbin:/usr/sbin"
GK_V='3.4.7_pre3'
GK_V='3.4.7_pre4'
TMPDIR='/var/tmp/genkernel'
TEMP=${TMPDIR}/$RANDOM.$RANDOM.$RANDOM.$$
@ -398,60 +398,6 @@ then
[ "${UNIONFS}" -eq '1' ] && print_info 1 ' or "unionfs=<block_device>"'
fi
symlinker() {
local base=$1
local fullVer=${KNAME}-${ARCH}-${KV}
local newThing=${BOOTDIR}/${base}-${fullVer}
local newSym=${BOOTDIR}/${base}
local oldSym=${newSym}.old
local prevLink
local ret=0
print_info 1 " creating ${base} name symlink!"
if [ -e ${newThing} ] ; then
if [ -L ${newSym} ] ; then
prevLink=`readlink --no-newline ${newSym}`
if [ ${prevLink} != ${newThing} ] ; then
if [ -L ${oldSym} ] ; then
rm ${oldSym}
fi
ln -s ${prevLink} ${oldSym}
[ $((ret += $?)) ]
fi
rm ${newSym}
fi
ln -s ${newThing} ${newSym}
[ $((ret += $?)) ]
fi
if [[ ${ret} > 0 ]] ; then
print_error 1 " $base link failed: ${ret}"
fi
return ${ret}
}
if [ "${CMD_NOINSTALL}" != '1' -a "${SYMLINK}" = '1' ]
then
echo
print_info 1 'Creating symlinks'
symlinker kernel
symlinker System.map
if [ "${KERN_24}" != '1' -a "${CMD_BOOTSPLASH}" != '1' ] ; then
symlinker initramfs
else
symlinker initrd
fi
fi
[ "${BOOTRW}" != '' ] && mount -o remount,ro ${BOOTDIR}
echo

Loading…
Cancel
Save