-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3.gather_mods.sh
executable file
·48 lines (35 loc) · 1.36 KB
/
3.gather_mods.sh
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
#!/bin/bash
echo "Enter module_source_path"
read module_source_path
echo "Entered: $module_source_path"
echo
init_mod_dir_name="generic"
mods=(`cat mod.list`)
mod_list_file="module_list.txt"
cat /dev/null > $mod_list_file
for mod in ${mods[@]}; do
while read -r actual_mod_path
do
after_kernel_path=$(echo $actual_mod_path | cut -d '/' -f5-)
after_kernel_dir=$(echo ${after_kernel_path%/*})
actual_mod_file=$(echo ${after_kernel_path##*/})
actual_mod_name=$(echo ${actual_mod_file%%.*})
init_mod_dir="lib/modules/$init_mod_dir_name/$after_kernel_dir"
mkdir -p $init_mod_dir
ko_path="${module_source_path}/${after_kernel_dir}/${actual_mod_name}.ko"
xz_path="${module_source_path}/${after_kernel_dir}/${actual_mod_name}.ko.xz"
init_mod_path=""
if [[ -e "$ko_path" ]]; then
init_mod_path="${init_mod_dir}/${actual_mod_name}.ko"
cp -npv $ko_path $init_mod_path
elif [[ -e "$xz_path" ]]; then
init_mod_path="${init_mod_dir}/${actual_mod_name}.ko.xz"
cp -np $xz_path $init_mod_path && echo "Copied: $actual_mod_name" || echo "FAILED: $actual_mod_name"
else
echo "Module $actual_mod_name not found in source path"
fi
if [[ -n "$init_mod_path" ]]; then
echo "/${init_mod_path}" >> $mod_list_file
fi
done < <(modprobe --show-depends $mod | cut -d ' ' -f2)
done