-
Notifications
You must be signed in to change notification settings - Fork 45
/
makeModules.sh
executable file
·53 lines (46 loc) · 1.39 KB
/
makeModules.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
49
50
51
52
53
#!/bin/bash
# Make kernel modules for NVIDIA Jetson Developer Kit
# Copyright (c) 2016-21 Jetsonhacks
# MIT License
SOURCE_TARGET="/usr/src"
KERNEL_RELEASE=$( uname -r | cut -d. -f1-2) # e.g. 4.9
function usage
{
echo "usage: ./makeModules.sh [[-d directory ] | [-h]]"
echo "-d | --directory Directory path to parent of kernel"
echo "-h | --help This message"
}
# Iterate through command line inputs
while [ "$1" != "" ]; do
case $1 in
-d | --directory ) shift
SOURCE_TARGET=$1
;;
-h | --help ) usage
exit
;;
* ) usage
exit 1
esac
shift
done
LAST="${SOURCE_TARGET: -1}"
if [ $LAST != '/' ] ; then
SOURCE_TARGET="$SOURCE_TARGET""/"
fi
# Check to see if source tree is already installed
PROPOSED_SRC_PATH="$SOURCE_TARGET""kernel/kernel-"$KERNEL_RELEASE
echo "Proposed source path: ""$PROPOSED_SRC_PATH"
if [ ! -d "$PROPOSED_SRC_PATH" ]; then
tput setaf 1
echo "==== Cannot find kernel source! =============== "
tput sgr0
echo "The kernel source does not appear to be installed at: "
echo " ""$PROPOSED_SRC_PATH"
echo "Unable to start making kernel."
exit 1
fi
export SOURCE_TARGET
export KERNEL_RELEASE
# E Option carries over environment variables
sudo -E ./scripts/makeModules.sh