File: 80-install-modules

package info (click to toggle)
xen-tools 4.2-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,568 kB
  • ctags: 172
  • sloc: perl: 5,082; sh: 2,092; makefile: 239
file content (84 lines) | stat: -rwxr-xr-x 1,811 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/sh
#
#  Install modules from the host system into the new image, and
# ensure that 'module-init-tools' is setup.
#
#  This is most likely required if you're using a custom kernel
# for your Xen system.  But even if it isn't required it can't
# really do anything bad; just waste a bit of space.
#
# Steve
# --
# http://www.steve.org.uk/


prefix=$1



#
#  Source our common functions
#
if [ -e /usr/lib/xen-tools/common.sh ]; then
    . /usr/lib/xen-tools/common.sh
else
    . ./hooks/common.sh
fi


#
# Log our start
#
logMessage Script $0 starting


#
#  The name of the package containing the correct modules.
#
linux_modules_package="linux-modules-$(uname -r)"

#
#  Attempt to install that package.  This will either work on an Etch
# system, or fail on a Sarge/custom kernel.
#
if [ -n "${modules}" -a -d "${modules}" ]; then

    #
    # Modules path was specified during install
    #
    logMessage "Copying modules from ${modules}"

    mkdir -p ${prefix}/lib/modules
    cp -au ${modules} ${prefix}/lib/modules
elif chroot ${prefix} /usr/bin/apt-cache show ${linux_modules_package} >/dev/null 2>/dev/null; then

    logMessage "Package '${linux_modules_package}' is available - installing"

    #
    # If it worked then we can install the package.
    #
    installDebianPackage ${prefix} ${linux_modules_package}
else

    #
    # Fall back to copying over modules from the host to the new
    # system.
    #
    logMessage "Package '${linux_modules_package}' is not available"
    logMessage "Copying modules from /lib/modules/$(uname -r)"

    mkdir -p ${prefix}/lib/modules
    cp -au /lib/modules/$(uname -r) ${prefix}/lib/modules
fi


#
#  Install the module-init-tools package.
#
installDebianPackage ${prefix} module-init-tools


#
#  Log our finish
#
logMessage Script $0 finished