aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Gianelloni <wolf31o2@gentoo.org>2007-03-09 20:24:09 +0000
committerChris Gianelloni <wolf31o2@gentoo.org>2007-03-09 20:24:09 +0000
commit89c7fbdde588c97a343a04e48f4e06d15dde08d9 (patch)
tree575b134d2b9fcbff5224e342118f1a55ae841822 /gen_funcs.sh
parentFixed lib64 link for bug #168664. (diff)
downloadgenkernel-89c7fbdde588c97a343a04e48f4e06d15dde08d9.tar.gz
genkernel-89c7fbdde588c97a343a04e48f4e06d15dde08d9.tar.bz2
genkernel-89c7fbdde588c97a343a04e48f4e06d15dde08d9.zip
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
Diffstat (limited to 'gen_funcs.sh')
-rwxr-xr-xgen_funcs.sh138
1 files changed, 138 insertions, 0 deletions
diff --git a/gen_funcs.sh b/gen_funcs.sh
index e0245ab..f869a78 100755
--- a/gen_funcs.sh
+++ b/gen_funcs.sh
@@ -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
+}
+