Differences between version 5 and previous revision of CyberLeo/sbin/installkernel.
Other diffs: Previous Major Revision, Previous Author
| Newer page: | version 5 | Last edited on Monday, 15 October 2012 7:58:34 | by CyberLeo | Revert |
| Older page: | version 4 | Last edited on Sunday, 19 April 2009 13:34:27 | by CyberLeo | Revert |
@@ -1,4 +1,49 @@
+!This is deprecated! New /sbin/installkernel script uses run-parts(8) to invoke the scripts in /etc/kernel/postinst.d/
+
+I now use a script to perform the necessary transformations, in /etc/kernel/postinst.d/10-re-rename:
+<code brush="bash">
+#!/bin/sh -e
+
+# Arguments: <version> <image>
+version="${1}"
+image="${2}"
+
+src_image="${image}"
+src_config="$(dirname "${image}")/config-${version}.xz"
+src_sysmap="$(dirname "${image}")/System.map-${version}.xz"
+
+tgt_image="/boot/kernel/kernel-${version}"
+tgt_config="/boot/kernel/config-${version}.xz"
+tgt_sysmap="/boot/kernel/System.map-${version}.xz"
+
+bkp_image="/boot/kernel/backups/kernel-${version}"
+bkp_config="/boot/kernel/backups/config-${version}.xz"
+bkp_sysmap="/boot/kernel/backups/System.map-${version}.xz"
+
+# Compress config and System.map if not already compressed
+[ ! -f "${src_config}" -a -f "${src_config%%.xz}" ] && xz -9ev "${src_config%%.xz}"
+[ ! -f "${src_sysmap}" -a -f "${src_sysmap%%.xz}" ] && xz -9ev "${src_sysmap%%.xz}"
+
+mkdir -p "$(dirname "${bkp_image}")"
+
+# Archive old copy into backups/
+if [ -f "${tgt_image}" ]
+then
+ echo "Backup of old kernel is in '${bkp_image}'"
+ mv -f "${tgt_image}" "${bkp_image}" || true
+ mv -f "${tgt_config}" "${bkp_config}" || true
+ mv -f "${tgt_sysmap}" "${bkp_sysmap}" || true
+fi
+
+# Install new copy
+mv -f "${src_image}" "${tgt_image}"
+mv -f "${src_config}" "${tgt_config}"
+mv -f "${src_sysmap}" "${tgt_sysmap}"
+</code>
+
+Legacy version follows...
+----
<code bash>
#!/bin/sh
#
# Copyright (C) 1995 - 1998, Ian A. Murdock <imurdock@debian.org>
version 5
This is deprecated! New /sbin/installkernel script uses run-parts(8) to invoke the scripts in /etc/kernel/postinst.d/
I now use a script to perform the necessary transformations, in /etc/kernel/postinst.d/10-re-rename:
#!/bin/sh -e
# Arguments: <version> <image>
version="${1}"
image="${2}"
src_image="${image}"
src_config="$(dirname "${image}")/config-${version}.xz"
src_sysmap="$(dirname "${image}")/System.map-${version}.xz"
tgt_image="/boot/kernel/kernel-${version}"
tgt_config="/boot/kernel/config-${version}.xz"
tgt_sysmap="/boot/kernel/System.map-${version}.xz"
bkp_image="/boot/kernel/backups/kernel-${version}"
bkp_config="/boot/kernel/backups/config-${version}.xz"
bkp_sysmap="/boot/kernel/backups/System.map-${version}.xz"
# Compress config and System.map if not already compressed
[ ! -f "${src_config}" -a -f "${src_config%%.xz}" ] && xz -9ev "${src_config%%.xz}"
[ ! -f "${src_sysmap}" -a -f "${src_sysmap%%.xz}" ] && xz -9ev "${src_sysmap%%.xz}"
mkdir -p "$(dirname "${bkp_image}")"
# Archive old copy into backups/
if [ -f "${tgt_image}" ]
then
echo "Backup of old kernel is in '${bkp_image}'"
mv -f "${tgt_image}" "${bkp_image}" || true
mv -f "${tgt_config}" "${bkp_config}" || true
mv -f "${tgt_sysmap}" "${bkp_sysmap}" || true
fi
# Install new copy
mv -f "${src_image}" "${tgt_image}"
mv -f "${src_config}" "${tgt_config}"
mv -f "${src_sysmap}" "${tgt_sysmap}"
Legacy version follows...
#!/bin/sh
#
# Copyright (C) 1995 - 1998, Ian A. Murdock <imurdock@debian.org>
# Copyright (C) 1998, 1999, Guy Maor
# Copyright (C) 2002, Matthew Wilcox
# Copyright (C) 2002, 2004, 2005, 2007, Clint Adams
#
# Install the kernel on a Debian Linux system.
#
# This script is called from /usr/src/linux/arch/i386/boot/install.sh.
# If you install it as /sbin/installkernel, you can do a "make install"
# from a generic kernel source tree, and the image will be installed to
# the proper place for Debian GNU/Linux.
set -e
if [ $# -eq 3 ] || [ $# -eq 4 ] ; then
img="$2"
map="$3"
ver="$1"
if [ $# -eq 4 ] && [ -n "$4" ] ; then
dir="$4"
else
dir="/boot"
fi
else
echo "Usage: installkernel <version> <image> <System.map> <directory>"
exit 1
fi
updatever () {
if [ -f "$dir/kernel/$1-$ver" ] ; then
mv "$dir/kernel/$1-$ver" "$dir/kernel/$1-$ver.old"
fi
cat "$2" > "$dir/kernel/$1-$ver"
if test -f "$dir/kernel/$1" ; then
if test -L "$dir/kernel/$1" &&
[ "$(readlink -f ${dir}/kernel/${1})" = "${dir}/kernel/${1}-${ver}" ]; then
ln -sf "$1-$ver.old" "$dir/kernel/$1.old"
else
mv "$dir/kernel/$1" "$dir/kernel/$1.old"
fi
fi
ln -sf "$1-$ver" "$dir/kernel/$1"
}
if [ "$(basename $img)" = "vmlinux" ] ; then
updatever vmlinux "$img"
else
updatever kernel "$img"
fi
updatever System.map "$map"
config=$(dirname "$map")
config="${config}/.config"
if [ -f "$config" ] ; then
updatever config "$config"
fi
#if [ "$(basename $img)" = "vmlinux" ] && [ "$(id -u)" = "0" ] ; then
# mkboot -i ${dir}/vmlinux-${ver}
#else
# mkboot -i ${dir}/vmlinuz-${ver}
#fi
