~ubuntu-branches/ubuntu/hardy/linux-backports-modules-2.6.24/hardy-security

« back to all changes in this revision

Viewing changes to updates/wireless/iwlwifi/iwlwifi/scripts/patch_kernel

  • Committer: Bazaar Package Importer
  • Author(s): , Ben Collins
  • Date: 2008-04-02 06:59:04 UTC
  • Revision ID: james.westby@ubuntu.com-20080402065904-e5knh2gn2hms3xbb
Tags: 2.6.24-14.11
[Ben Collins]

* iwlwifi: Update to iwlwifi-1.2.25 and mac80211-10.0.4
  - LP: #200950
* ubuntu: Slight cleanups to module hiearchy and Makefiles
* mac80211: Enable LED triggers
* iwlwifi: Add LED trigger support (rx and tx only)
  - LP: #176090

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env /bin/bash
 
2
 
 
3
echo "Deprecated"
 
4
exit 0
 
5
 
 
6
function check_params()
 
7
{
 
8
    if [ "$1" ]; then
 
9
        DEST="$1"
 
10
        export DEST=${DEST/%\//}/
 
11
        export MAC80211=${DEST}drivers/net/wireless/mac80211/
 
12
        return 0
 
13
    fi
 
14
 
 
15
    cat <<EOF
 
16
Usage: patch_kernel /PATH/TO/KERNEL
 
17
eg: patch_kernel /lib/modules/\$(uname -r)/source
 
18
EOF
 
19
}
 
20
 
 
21
 
 
22
function verify_continue()
 
23
{
 
24
    cat << EOF
 
25
This will install this driver into your kernel tree located here:
 
26
 
 
27
  ${DEST}
 
28
 
 
29
If you would like to install to a different location, run
 
30
this as follows: 
 
31
 
 
32
  make KSRC=/path/to/kernel patch_kernel
 
33
 
 
34
EOF
 
35
 
 
36
    read -p "Do you wish to continue? [Yn] " reply
 
37
    case $reply in
 
38
        Y|y|"") 
 
39
            return 0 
 
40
            ;;
 
41
        *) echo "Terminating patch prcoess." 
 
42
            return 1 
 
43
            ;; 
 
44
    esac
 
45
    
 
46
    if [ "$(shell whoami)" != "root" ]; then
 
47
        cat << EOF
 
48
If this fails, you may need to be root to patch the kernel.
 
49
EOF
 
50
    fi
 
51
}
 
52
 
 
53
 
 
54
function clean_tree()
 
55
{
 
56
cat <<EOF
 
57
Setting 'iwlwifi' entries in:
 
58
  ${MAC80211}Kconfig
 
59
EOF
 
60
    [ -e ${MAC80211}Kconfig ] &&
 
61
    grep -v "^source.*iwlwifi" ${MAC80211}Kconfig > .tmp-Kconfig
 
62
    echo "source \"drivers/net/wireless/mac80211/iwlwifi/Kconfig\"" >> \
 
63
        .tmp-Kconfig
 
64
 
 
65
cat <<EOF
 
66
Setting 'iwlwifi' entries in:
 
67
    ${MAC80211}Makefile
 
68
EOF
 
69
 
 
70
    [ -e ${MAC80211}Makefile ] &&
 
71
    grep -v "CONFIG_IWLWIFI" \
 
72
        ${MAC80211}Makefile > .tmp-Makefile
 
73
    echo 'obj-$(CONFIG_IWLWIFI) += iwlwifi/' >> .tmp-Makefile
 
74
 
 
75
    if test -f ${DEST}.config; then
 
76
        cat <<EOF
 
77
Clearing 'iwlwifi' entries from:
 
78
  ${DEST}.config
 
79
EOF
 
80
        grep -v "CONFIG_IWLWIFI" ${DEST}.config |
 
81
                grep -v "CONFIG_IWL3945" |
 
82
                grep -v "CONFIG_IWL4965" > .tmp-config
 
83
    fi
 
84
 
 
85
    if test -f ${DEST}include/linux/autoconf.h; then
 
86
        cat <<EOF
 
87
Clearing 'iwlwifi' entries from:
 
88
  ${DEST}include/linux/autoconf.h
 
89
EOF
 
90
        grep -v "CONFIG_IWLWIFI" ${DEST}include/linux/autoconf.h |
 
91
                grep -v "CONFIG_IWL3945" |
 
92
                grep -v "CONFIG_IWL4965" > .tmp-autoconf
 
93
    fi
 
94
 
 
95
    grep -q mac80211 ${DEST}drivers/net/wireless/Kconfig || {
 
96
cat <<EOF
 
97
Adding mac80211/Kconfig to:
 
98
  ${DEST}drivers/net/wireless
 
99
EOF
 
100
 
 
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
 
103
    }
 
104
 
 
105
    grep -q mac80211 ${DEST}drivers/net/wireless/Makefile || {
 
106
cat <<EOF
 
107
Adding mac80211/Makefile to:
 
108
  ${DEST}drivers/net/wireless
 
109
EOF
 
110
 
 
111
cp ${DEST}drivers/net/wireless/Makefile .tmp-wireless-Makefile
 
112
echo 'obj-y += mac80211/' >> .tmp-wireless-Makefile
 
113
    }
 
114
 
 
115
    return 0
 
116
}
 
117
 
 
118
function check_perms() 
 
119
{
 
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
 
124
 
 
125
cat <<EOF
 
126
 
 
127
Insufficient permissions to write to:
 
128
 
 
129
    ${MAC80211}iwlwifi
 
130
 
 
131
Aborting.  Perhaps try running as root?
 
132
EOF
 
133
 
 
134
    return 1
 
135
}
 
136
    
 
137
 
 
138
function copy_files()
 
139
{
 
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/
 
145
}
 
146
 
 
147
function add_to_tree() 
 
148
{
 
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
 
156
    fi
 
157
    if test -f ${DEST}.config; then
 
158
        cp ${DEST}.config ${DEST}.config.bk
 
159
        mv -f .tmp-config ${DEST}.config
 
160
    fi
 
161
    
 
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
 
168
    return 0
 
169
 
 
170
}
 
171
 
 
172
function show_results()
 
173
{
 
174
    cat <<EOF
 
175
 
 
176
Kernel has been updated to include:
 
177
 
 
178
    iwlwifi drivers for Linux
 
179
 
 
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.
 
182
EOF
 
183
}
 
184
 
 
185
check_params $@ &&
 
186
scripts/check_kernel "${DEST}" &&
 
187
verify_continue && 
 
188
check_perms &&
 
189
clean_tree && 
 
190
copy_files && 
 
191
add_to_tree && 
 
192
show_results