blob: 41a9c5079b64fd4d1db26ce4da2b4999a63bbd61 (
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
|
#
# 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.
if [ -z "${KERNEL_VERSION}" ]; then
. ${ROOT_DIR}/helper/system.inc
[ -z "${KERNEL_VERSION}" ] && perror "KERNEL_VERSION still not set after sourcing, something is very wrong..."
fi
# set global KERNEL_TARGET_NAME
KERNEL_TARGET_NAME="vmlinuz-${KERNEL_VERSION}-openslx"
check_kernel_build_dir() {
[ -d "${MODULES_DIR}/kernel/build" ] && KERNEL_BUILD_DIR="${MODULES_DIR}/kernel/build" \
|| perror "No build directory set for the kernel. Was is built?"
# hack to get the real path of the installed modules
KERNEL_NEW_VERSION=$(ls ${KERNEL_BUILD_DIR}/lib/modules)
}
copy_kernel_modules() {
[ -z "${REQUIRED_KERNEL_MODULES}" ] && perror "REQUIRED_KERNEL_MODULES is empty. Check your config file."
check_kernel_build_dir
#
# process modules list
#
# search for modules in KERNEL_BUILD_DIR
cd "${KERNEL_BUILD_DIR}" || perror "Could not cd to ${KERNEL_BUILD_DIR}"
local KERNEL_MODULES_DIR="lib/modules/${KERNEL_NEW_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_BUILD_DIR}/${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}'"
KERNEL_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_NEW_VERSION}"
cd - >/dev/null
}
copy_firmware() {
[ -z "${REQUIRED_FIRMWARE}" ] && perror "REQUIRED_FIRMWARE is empty. Check your config file."
check_kernel_build_dir
#
# process firmware list
#
cd "${KERNEL_BUILD_DIR}" || perror "Could not cd!"
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_NEW_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_NEW_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 TOOL_STR="$TOOL_STR copy_kernel:"
check_kernel_build_dir
local KERNEL_DIR="${MODE_DIR}/builds/kernel"
pinfo "Copying '${KERNEL_TARGET_NAME}' to '${KERNEL_DIR}'."
[ -d "${KERNEL_DIR}" ] || mkdir -p "${KERNEL_DIR}"
cp "${KERNEL_BUILD_DIR}/${KERNEL_TARGET_NAME}" "${KERNEL_DIR}" || perror "Could not copy kernel!"
pinfo "You may want to update your systems firmware/modules to match the current kernel."
}
|