-
Notifications
You must be signed in to change notification settings - Fork 3
/
patch_kernel.sh
46 lines (35 loc) · 1.05 KB
/
patch_kernel.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
#!/bin/bash
####
# This is an attempt to make a generic patch routine to insert support
# for Atmel's I2C TPM, tested on kernel version 3.2.
####
if [ ! -d "$1" ]; then
echo "Usage: $0 /path/to/kernel/source"
exit
fi
OBJ_LINE="obj-\$(CONFIG_TCG_TIS_I2C_ATMEL) += tpm_i2c_atmel.o"
####
# Move source file to drivers/char/tpm
####
cp ./tpm_i2c_atmel.c $1/drivers/char/tpm/
####
# Add obj line
####
CHECK=`awk '/tpm_i2c_atmel/ { print NR;}' $1/drivers/char/tpm/Makefile`
if [ ! "${CHECK}" = "" ]; then
echo "Problem: Makefile already contains tpm_i2c_atmel obj line."
else
echo "${OBJ_LINE}" >> $1/drivers/char/tpm/Makefile
fi
####
# Insert tristate
####
CHECK=`awk '/TCG_TIS_I2C_ATMEL/ { print NR;}' $1/drivers/char/tpm/Kconfig`
if [ ! "${CHECK}" = "" ]; then
echo "Problem: Kconfig already contains TCG_TIS_I2C_ATMEL tristate."
else
LAST_LINE=`awk '/endif # TCG_TPM/ { print NR;}' $1/drivers/char/tpm/Kconfig`
sed "$((LAST_LINE-1))r patches/Kconfig.add" < $1/drivers/char/tpm/Kconfig > Kconfig.mod
mv Kconfig.mod $1/drivers/char/tpm/Kconfig
fi
echo "Success"