source: branches/stable/mindi/distributions/debian/FindDistroFailsafe @ 1063

Last change on this file since 1063 was 1063, checked in by bruno, 13 years ago
  • USB device support for mindi (Tested and Working)
  • Begining of USB device support for mondo (maybe not even compiling)
  • FindDistroFailsafe? build process support
  • makemount list doesn't issue weird messages anymore around LVM
  • Property svn:executable set to *
File size: 4.1 KB
Line 
1#!/bin/bash
2#
3# $Id$
4#
5# FindDistroFailsafe - Find correct FAILSAFE kernel to use on Debian systems.
6# (c) A. Leidenfrost
7#
8# Approach:
9# - get architecture
10# - get kernel version (e.g. '2.6' or '2.4') of running kernel
11# - find matching latest generic kernel using list of virtual candiates
12#
13# Caveats:
14# - candiates lists need to be maintained manually; not too much overhead
15# - the kernel relases don't have to match, i.e. a 2.6.12 could be running and
16#   a 2.6.15 might get selected as failsafe; probably ok
17#
18# Changelog:
19# 28Jan06AL: - initial version
20# 12Feb06AL: - removed 'FATAL ERROR' from error messages
21#            - check for status of kernel package, not dpkg (silly glitch)
22#            - tell users to install kernel package when not found
23#            - turned from independent script into snippet that is sourced by mindi
24#              (prefixed all variables with 'EXT_' as external name space)
25#            - use Die for better error reporting (possible through previous step)
26#
27
28
29# Define candiate lists for virtual kernel packages
30EXT_virt_kernel_pkg_cand_amd64_26="linux-image-2.6-amd64"
31EXT_virt_kernel_pkg_cand_i386_24="kernel-image-2.4-386"
32EXT_virt_kernel_pkg_cand_i386_26="linux-image-2.6-486 kernel-image-2.6-386 linux-image-386" # Sarge Etch/Sid Breezy
33EXT_virt_kernel_pkg_cand_ia64_24="kernel-image-2.4-itanium"
34EXT_virt_kernel_pkg_cand_ia64_26="linux-image-2.6-itanium kernel-image-2.6-itanium"
35
36####################################################
37# +++ No maintainable parts beyond this point. +++ #
38####################################################
39
40
41# Get architecure of system
42EXT_system_architecture=`dpkg --print-architecture 2> /dev/null`
43if [ $? -ne 0 ]; then
44    Die "Failed to determine system architecture. Terminating."
45fi
46
47# Get version of running kernel
48EXT_kernel_version=`uname -r 2> /dev/null | cut -c1-3 2> /dev/null`
49if [ $? -ne 0 ]; then
50    Die "Failed to get version of running kernel. Terminating."
51fi
52
53# Get virtual kernel package candiates corresponding to architecture and kernel version
54case "$EXT_system_architecture" in
55    "amd64")
56        case "$EXT_kernel_version" in
57            "2.6")
58                EXT_virt_kernel_pkg_cand=$EXT_virt_kernel_pkg_cand_amd64_26 ;;
59            *)
60                Die "Kernel version $EXT_kernel_version not supported on architecture $EXT_system_architecture. Terminating." ;;
61        esac;;
62    "i386")
63        case "$EXT_kernel_version" in
64            "2.4")
65                EXT_virt_kernel_pkg_cand=$EXT_virt_kernel_pkg_cand_i386_24 ;;
66            "2.6")
67                EXT_virt_kernel_pkg_cand=$EXT_virt_kernel_pkg_cand_i386_26 ;;
68            *)
69                Die "Kernel version $EXT_kernel_version not supported on architecture $EXT_system_architecture. Terminating." ;;
70        esac;;
71    "ia64")
72        case "$EXT_kernel_version" in
73            "2.4")
74                EXT_virt_kernel_pkg_cand=$EXT_virt_kernel_pkg_cand_ia64_24 ;;
75            "2.6")
76                EXT_virt_kernel_pkg_cand=$EXT_virt_kernel_pkg_cand_ia64_26 ;;
77            *)
78                Die "Kernel version $EXT_kernel_version not supported on architecture $EXT_system_architecture. Terminating." ;;
79        esac;;
80    *)
81        Die "Architecture $EXT_system_architecture not supported. Terminating." ;;
82esac
83
84# Determine kernel package from virtual candidates
85for EXT_cand in $EXT_virt_kernel_pkg_cand; do
86    EXT_kernel_package=`dpkg --print-avail $EXT_cand 2>/dev/null | grep "^Depends: " | cut -d" " -f2`
87    [ -n "$EXT_kernel_package" ] && break
88done
89if [ -z "$EXT_kernel_package" ]; then
90    Die "Failed to get real kernel package for virtual kernel package candiate(s) $EXT_virt_kernel_pkg_cand. Terminating."
91fi
92
93# Verify that kernel package is installed
94# (This is what users that don't have a suitable kernel to be used as failsafe will see.)
95if [ `dpkg --status $EXT_kernel_package 2>/dev/null | grep -c "Status: install ok installed"` -ne 1 ]; then
96    Die "Debian kernel package $EXT_kernel_package not installed. Please install (one of): $EXT_virt_kernel_pkg_cand. Terminating."
97fi
98
99# Get path to kernel image
100EXT_kernel_image=`dpkg -L "$EXT_kernel_package" 2> /dev/null | grep -m 1 vmlinuz`
101if [ -z "$EXT_kernel_image" ]; then
102    Die "Failed to get path to kernel image from package $EXT_kernel_package. Terminating."
103else
104    # Export kernel version
105    export FAILSAFE_KBIN="$EXT_kernel_image"
106    export FAILSAFE_KVER="`echo $EXT_kernel_image | cut -d- -f2-`"
107fi
Note: See TracBrowser for help on using the repository browser.