1
#!/usr/bin/env /bin/bash
6
function check_params()
10
export DEST=${DEST/%\//}/
11
export MAC80211=${DEST}drivers/net/wireless/mac80211/
16
Usage: patch_kernel /PATH/TO/KERNEL
17
eg: patch_kernel /lib/modules/\$(uname -r)/source
22
function verify_continue()
25
This will install this driver into your kernel tree located here:
29
If you would like to install to a different location, run
32
make KSRC=/path/to/kernel patch_kernel
36
read -p "Do you wish to continue? [Yn] " reply
41
*) echo "Terminating patch prcoess."
46
if [ "$(shell whoami)" != "root" ]; then
48
If this fails, you may need to be root to patch the kernel.
57
Setting 'iwlwifi' entries in:
60
[ -e ${MAC80211}Kconfig ] &&
61
grep -v "^source.*iwlwifi" ${MAC80211}Kconfig > .tmp-Kconfig
62
echo "source \"drivers/net/wireless/mac80211/iwlwifi/Kconfig\"" >> \
66
Setting 'iwlwifi' entries in:
70
[ -e ${MAC80211}Makefile ] &&
71
grep -v "CONFIG_IWLWIFI" \
72
${MAC80211}Makefile > .tmp-Makefile
73
echo 'obj-$(CONFIG_IWLWIFI) += iwlwifi/' >> .tmp-Makefile
75
if test -f ${DEST}.config; then
77
Clearing 'iwlwifi' entries from:
80
grep -v "CONFIG_IWLWIFI" ${DEST}.config |
81
grep -v "CONFIG_IWL3945" |
82
grep -v "CONFIG_IWL4965" > .tmp-config
85
if test -f ${DEST}include/linux/autoconf.h; then
87
Clearing 'iwlwifi' entries from:
88
${DEST}include/linux/autoconf.h
90
grep -v "CONFIG_IWLWIFI" ${DEST}include/linux/autoconf.h |
91
grep -v "CONFIG_IWL3945" |
92
grep -v "CONFIG_IWL4965" > .tmp-autoconf
95
grep -q mac80211 ${DEST}drivers/net/wireless/Kconfig || {
97
Adding mac80211/Kconfig to:
98
${DEST}drivers/net/wireless
101
cp ${DEST}drivers/net/wireless/Kconfig .tmp-wireless-Kconfig
102
sed -i -e "s,endmenu,source \"drivers/net/wireless/mac80211/Kconfig\"\nendmenu,g" .tmp-wireless-Kconfig
105
grep -q mac80211 ${DEST}drivers/net/wireless/Makefile || {
107
Adding mac80211/Makefile to:
108
${DEST}drivers/net/wireless
111
cp ${DEST}drivers/net/wireless/Makefile .tmp-wireless-Makefile
112
echo 'obj-y += mac80211/' >> .tmp-wireless-Makefile
118
function check_perms()
120
[ -d ${MAC80211}iwlwifi ] && [ -w ${MAC80211}iwlwifi ] && return 0
121
[ -d ${MAC80211} ] && [ -w ${MAC80211} ] && return 0
122
[ -d ${DEST}drivers/net/wireless/ ] &&
123
[ -w ${DEST}drivers/net/wireless/ ] && return 0
127
Insufficient permissions to write to:
131
Aborting. Perhaps try running as root?
138
function copy_files()
140
echo "Copying files..."
141
cp README.iwlwifi ${DEST}Documentation/networking
142
mkdir -p ${MAC80211}iwlwifi
143
cp compatible/{Kconfig,Makefile} ${MAC80211}iwlwifi/
144
cp compatible/*.{c,h} ${MAC80211}iwlwifi/
147
function add_to_tree()
149
echo "Installing potentially modified files..."
150
[ -e ${MAC80211}Kconfig ] && cp ${MAC80211}Kconfig ${MAC80211}Kconfig.bk
151
[ -e ${MAC80211}Makefile ] && cp ${MAC80211}Makefile ${MAC80211}Makefile.bk
152
if test -f ${DEST}include/linux/autoconf.h; then
153
cp ${DEST}include/linux/autoconf.h \
154
${DEST}include/linux/autoconf.h.bk
155
mv -f .tmp-autoconf ${DEST}include/linux/autoconf.h
157
if test -f ${DEST}.config; then
158
cp ${DEST}.config ${DEST}.config.bk
159
mv -f .tmp-config ${DEST}.config
162
mv -f .tmp-Kconfig ${MAC80211}Kconfig
163
mv -f .tmp-Makefile ${MAC80211}Makefile
164
[ -e .tmp-wireless-Kconfig ] &&
165
mv -f .tmp-wireless-Kconfig ${DEST}drivers/net/wireless/Kconfig
166
[ -e .tmp-wireless-Makefile ] &&
167
mv -f .tmp-wireless-Makefile ${DEST}drivers/net/wireless/Makefile
172
function show_results()
176
Kernel has been updated to include:
178
iwlwifi drivers for Linux
180
you can now edit your kernel's configuration via 'make menuconfig' and
181
build as you would any kernel image and set of modules.
186
scripts/check_kernel "${DEST}" &&