-
Notifications
You must be signed in to change notification settings - Fork 3
/
build_install_driver
executable file
·138 lines (129 loc) · 4.55 KB
/
build_install_driver
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
138
#!/bin/bash -e
function check_help {
case "$1" in
"--help" | "-h")
echo "************************************************************"
echo "*** HELP ***************************************************"
echo "************************************************************"
echo "*** Run the script without parameter to build and ***"
echo "*** install the driver. The build script will creates a ***"
echo "*** build directory (./tmp_build). ***"
echo "*** To specify a build directory just pass a directory ***"
echo "*** path. ***"
echo "*** ***"
echo "*** e.g.: ***"
echo "*** mkdir ./my_build_path ***"
echo "*** ./build_install_driver ./my_build_path ***"
echo "************************************************************"
exit 0
;;
*)
;;
esac
}
builddir="./tmp_build/"
if (( "$#" >= "1" )); then
check_help $1
if [ -d "${1}" ]; then
builddir=$(realpath "${1}")
else
echo "Error - Given parameter \"$1\" is not a folder or does not exist!"
exit 1
fi
else
mkdir -p "${builddir}"
fi
# check if directories contain white spaces...
invalid_path=$(pwd | { grep " " || true; } )
if [ "${invalid_path}" != "" ]; then
echo "Error - path contains spaces (\"${PWD}\")! Please use path without."
exit 1
fi
invalid_path=$(echo ${builddir} | { grep " " || true; } )
if [ "${invalid_path}" != "" ]; then
echo "Error - path contains spaces (\"${builddir}\")! Please use path without."
exit 1
fi
if [ -d "${builddir}/libcifx" ] || [ -d "${builddir}/uio_netx" ]; then
echo "********************************************************************************"
echo "NOTE: The build folder (\"${builddir}\") is not empty! Force overwrting (yes=y)?"
echo " Or pass a new build folder (./build_install_driver [my_build_folder]."
echo "********************************************************************************"
read delete_files
if [ "${delete_files}" = "y" ]; then
echo "...deleting build folder!"
rm -rf "${builddir}/libcifx"
rm -rf "${builddir}/uio_netx"
else
echo "...canceled build process!"
exit 1
fi
fi
driver_src=$(dirname $(realpath $0))
scripts_dir="${driver_src}/scripts"
cur_path=$PWD
kernelversion=""
ret=0
install_step="uio_netx"
while [ "$install_step" != "stop" ]
do
case $install_step in
error)
echo "************************************************************"
echo "**** An error occured during the installation ***"
echo "************************************************************"
echo "Please check the error message in the previous steps."
echo "When the problem is fixed restart the installation."
install_step="stop"
ret=1
;;
uio_netx)
install_step="firmware"
mkdir -p "${builddir}/uio_netx"
echo "************************************************************"
echo "**** Start building kernel module uio_netx ***"
echo "************************************************************"
if ! "${scripts_dir}/"install_uio_netx build "${builddir}/uio_netx"; then # build module
echo "Error building kernel module!"
install_step="error"
fi
if ! "${scripts_dir}/"install_uio_netx install "${builddir}/uio_netx"; then # install module
echo "Error installing kernel module!"
install_step="error"
fi
;;
firmware)
install_step="libcifx"
echo "************************************************************"
echo "**** Installing kernel module and firmware ***"
echo "************************************************************"
install_step="libcifx"
if ! "${scripts_dir}/"install_firmware install ; then # install firmware
echo "Error installing firmware!"
install_step="error"
fi
if ! "${scripts_dir}/"install_uio_netx update ; then # load driver
echo "Error updating module dependencies!"
install_step="error"
fi
if ! "${scripts_dir}/"install_uio_netx unload ; then
echo "Error unloading driver!"
install_step="error"
fi
if ! "${scripts_dir}/"install_uio_netx load; then
echo "Error loading driver!"
install_step="error"
fi
;;
libcifx)
echo "************************************************************"
echo "**** Building and installing user space library libcifx ***"
echo "************************************************************"
mkdir -p "${builddir}/libcifx"
"${scripts_dir}/"install_libcifx "${builddir}/libcifx"
install_step="stop"
;;
esac
done
cd ..
exit $ret