blob: 4216f25a35a8d6d2f2ed9b1b2c8dbc77bdf994ed (
plain) (
blame)
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
#
# Common functions to copy kernel related files
#
############################################################
#
#
# copies kernel modules as given in the module config file
# * depends on 'depmod'
# * requires REQUIRED_KERNEL_MODULES to be set.
# (entries must be a relative path to /lib/modules/<KERNEL_VERSION>)
#
# ex: for /lib/modules/3.2.0/kernel/fs/nfs/nfs.ko
# must be given as kernel/fs/nfs/nfs.ko
#
# this code depends on KERNEL_VERSION, this file needs to be sourced after helper/system.inc!
# (TODO: maybe source system.inc if KERNEL_VERSION is empty.
#[ -z "${KERNEL_VERSION}" ] && perror "KERNEL_VERSION not set. Was helper/system.inc sourced?"
KERNEL_NFS_DIR=""
mount_kernel_dir() {
[ -z "$KERNEL_NFS_DIR" ] || return 0
KERNEL_NFS_DIR="$(mktemp -d)"
mount -t nfs -o ro "132.230.8.228:/srv/openslx/kernel" "$KERNEL_NFS_DIR"
local RET=$?
if [ "x$RET" != "x0" ]; then
KERNEL_NFS_DIR=""
perror "Mounting kernel nfs dir to $KERNEL_NFS_DIR failed."
exit 1
fi
#pinfo "$KERNEL_NFS_DIR/$SELECTED_KERNEL"
#qnd_exit
[ -d "$KERNEL_NFS_DIR/$SELECTED_KERNEL" ] || perror "directory for $KERNEL_VERSION ($SELECTED_KERNEL) does not exist on NFS server"
}
unmount_kernel_dir() {
[ -z "$KERNEL_NFS_DIR" ] && return 0
pinfo "Unmounting kernel nfs stuff....."
umount "$KERNEL_NFS_DIR" || perror "Could not unmount kernel NFS share at '$KERNEL_NFS_DIR' - check the following lsof output:\n$(lsof -n | grep "$KERNEL_NFS_DIR")\n- End of lsof output -"
rmdir "$KERNEL_NFS_DIR"
KERNEL_NFS_DIR=""
}
copy_kernel_modules() {
[ -z "${REQUIRED_KERNEL_MODULES}" ] && perror "REQUIRED_KERNEL_MODULES is empty. Check your config file."
#
# process modules list
#
mount_kernel_dir
cd "$KERNEL_NFS_DIR/$SELECTED_KERNEL" || perror "Could not cd to $KERNEL_NFS_DIR/$SELECTED_KERNEL"
local KERNEL_MODULES_DIR="lib/modules/${KERNEL_VERSION}"
local KERNEL_MODULES_LIST=""
for KERNEL_MODULE in ${REQUIRED_KERNEL_MODULES}; do
local KERNEL_MODULE_PATH="${KERNEL_MODULES_DIR}/${KERNEL_MODULE}"
if grep "${KERNEL_MODULE}" "${KERNEL_NFS_DIR}/${SELECTED_KERNEL}/${KERNEL_MODULES_DIR}/modules.builtin" >/dev/null; then
pdebug "Already built-in ${KERNEL_MODULE}."
elif [ -e "${KERNEL_MODULE_PATH}" ]; then
pdebug "Copying '${KERNEL_MODULE_PATH}'"
MODULES_LIST+=" ${KERNEL_MODULE_PATH}"
else
pwarning "Module ${KERNEL_MODULE} not found. Skipping. (might cause problems on certain clients!)"
continue
fi
done
if [ ! -z "${KERNEL_MODULES_LIST}" ]; then
local COUNT=$(echo "${KERNEL_MODULES_LIST}" | wc -w)
pinfo "Copying $COUNT modules to target directory."
tarcopy "${KERNEL_MODULES_LIST}" "${TARGET_BUILD_DIR}"
fi
#
# generate modules map files
#
# first strip modules.order of all the modules we don't use
cat "${KERNEL_MODULES_DIR}/modules.order" | grep -E $(echo ${REQUIRED_KERNEL_MODULES} | tr '\ ' '|') \
>> "${TARGET_BUILD_DIR}/${KERNEL_MODULES_DIR}/modules.order"
# copy list of builtin kernel modules
cp "${KERNEL_MODULES_DIR}/modules.builtin" "${TARGET_BUILD_DIR}/${KERNEL_MODULES_DIR}"
# with modules.order and modules.builtin, we can run depmod for the rest of the files
depmod -b "${TARGET_BUILD_DIR}" -a "${KERNEL_VERSION}"
cd - >/dev/null
}
copy_firmware() {
[ -z "${REQUIRED_FIRMWARE}" ] && perror "REQUIRED_FIRMWARE is empty. Check your config file."
#
# process firmware list
#
mount_kernel_dir
cd "$KERNEL_NFS_DIR/$SELECTED_KERNEL" || perror "Could not cd to $KERNEL_NFS_DIR/$SELECTED_KERNEL"
local FIRMWARE_DIR="lib/firmware"
local FIRMWARE_LIST=""
for FIRMWARE in ${REQUIRED_FIRMWARE}; do
local FOUND=0
for CANDIDATE in "${FIRMWARE_DIR}/${FIRMWARE}" "${FIRMWARE_DIR}/${KERNEL_VERSION}/${FIRMWARE}"; do
if [ -e "${CANDIDATE}" ]; then
pdebug "Copying '${CANDIDATE}'"
FIRMWARE_LIST+=" ${CANDIDATE}"
FOUND=1
fi
done
[ $FOUND -ne 1 ] && pwarning "Neither '${FIRMWARE_DIR}/${FIRMWARE}' nor '${FIRMWARE_DIR}/${KERNEL_VERSION}/${FIRMWARE}' "\
" was found on the system. Skipping. (might cause problems on certain clients!)"
done
if [ ! -z "${FIRMWARE_LIST}" ]; then
local COUNT=$(echo "${FIRMWARE_LIST}" | wc -w)
pinfo "Copying $COUNT firmware to target directory."
tarcopy "${FIRMWARE_LIST}" "${TARGET_BUILD_DIR}"
fi
cd - >/dev/null
}
copy_kernel() {
local KERNEL_NAME="vmlinuz-${KERNEL_VERSION}"
[ -e "${KERNEL_DIR}/${KERNEL_NAME}" ] && return
local TOOL_STR="$TOOL_STR copy_kernel:"
mkdir -p "${KERNEL_DIR}"
pinfo "New kernel found. Copying '${KERNEL_NAME}' to '${KERNEL_DIR}'."
mount_kernel_dir
cp "$KERNEL_NFS_DIR/$SELECTED_KERNEL/bzImage" "$KERNEL_DIR/$KERNEL_NAME" || perror "Could not copy kernel from '$KERNEL_NFS_DIR/$SELECTED_KERNEL/bzImage' to '$KERNEL_DIR/$KERNEL_NAME'"
pinfo "You may want to update your systems firmware/modules to match the current kernel."
}
|