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
+}
+
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()
# 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.$$
[ "${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