1
#!/usr/bin/env /bin/bash
2
# Copyright (C) 2007 Intel Corporation
3
script=generate_compatible
5
[ "${prog/*$script/$script}" = "$script" ] || {
6
echo "This script must not be sourced."
18
die 1 "KSRC must be defined."
20
[ ! -e "${KSRC}/Makefile" ] &&
21
die 1 "Kernel Makefile not found at '$KSRC'"
23
. scripts/determine_compat
25
die $? "\nCould not provide compatible version. Try 2.6.18 or newer.\n\nTerminating."
31
die 5 "\n$SRC/ tree does not exist. Run 'make $SRC' to build the\n$SRC directory."
37
die 1 "$DST already exists. You must remove it before continuing."
40
echo "Building compatibility version in '$DST' directory:"
43
echo -n "Copying $DST from $SRC..."
44
cp -r ${SRC}* $DST || die $? "Copy failed."
47
(( !$requires_compat )) && exit 0
51
die 3 "$2 does not exist. Terminating."
52
echo -ne " + Applying: $2\n\t"
53
cat "$2" | while read command rest; do
55
"Commit:" | "Author:" | "")
57
*) echo "$command $rest"
63
patch -p1 -d $1 < "$2" > .patch.output || {
64
echo "-----patch failure output-----"
67
die 1 "$2 failed. Terminating."
69
[ -e .patch.output ] && rm .patch.output
75
die 3 "$2 does not exist. Terminating."
76
echo -ne " + Running: $2\n\t"
77
head -n 2 "$2" | tail -n 1 | sed -e 's,^#[[:space:]]*,,g' ||
83
(( !$has_mac80211_v2 )) && {
84
do_patch $DST patches/mac80211-v1.patch || die $? "Failed."
87
(( !$has_delayed_work )) && {
88
do_script $DST patches/01-queue_delayed_work.sh &&
89
do_script $DST patches/02-cancel_delayed_work.sh &&
90
do_patch $DST patches/02-kcompat_delayed_work.patch ||
94
(( !$has_new_request_irq )) && {
95
do_patch $DST patches/03-isr.patch || die $? "Failed."
98
(( !$has_rx_flag_radiotap )) && {
99
do_patch $DST patches/04-rx_flag_radiotap.patch || die $? "Failed."
102
(( !$has_delayed_work_define )) && {
103
do_patch $DST patches/05-delayed_work_define.patch || die $? "Failed."
106
(( !$has_wlan_80211 )) && {
107
do_patch $DST patches/wlan_80211.patch ||
111
(( !$has_csa_conf )) && {
112
do_patch $DST patches/06-csa.patch ||
116
(( !$has_hex_dump )) && {
117
do_patch $DST patches/07-hex_dump.patch ||
121
(( !$has_is_power_of_2 )) && {
122
do_patch $DST patches/08-is_power_of_2.patch ||
126
(( !$has_cancel_work_sync )) && {
127
do_patch $DST patches/09-cancel_work_sync.patch ||
131
(( $has_preferred_rate_control )) && {
132
do_patch $DST patches/10-preferred_rate_control.patch ||
136
(( !$has_i_private )) && {
137
do_script $DST patches/i_private.sh ||
138
die $? "Failure creating i_private rename compatibility."
142
(( !$has_mac80211_ht )) && {
143
grep -q 'export CONFIG_IWL4965_HT ?= y' Makefile
144
if [ $? -eq 0 ]; then
146
's/export CONFIG_IWL4965_HT[^_].*$/export CONFIG_IWL4965_HT ?= n/' \
152
(( !$has_mac80211_ht_agg )) && {
153
grep -q 'export CONFIG_IWL4965_HT_AGG ?= y' Makefile
154
if [ $? -eq 0 ]; then
156
's/export CONFIG_IWL4965_HT_AGG.*$/export CONFIG_IWL4965_HT_AGG ?= n/' \
162
(( $makefile_modified )) && exit 1