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."
17
echo "If patch or script failed, check pre/ and post/ for current stage." ||
18
echo "Try setting DEBUG=1 to maintain pre/ and post/ staging."
23
KSRC="/lib/modules/$(uname -r)/build"
25
[ ! -e "${KSRC}/Makefile" ] &&
26
die 1 "Kernel Makefile not found at '$KSRC'"
28
. scripts/determine_compat
30
die $? "\nCould not provide compatible version. Try 2.6.18 or newer.\n\nTerminating."
36
die 5 "\n$SRC/ tree does not exist. Run 'make $SRC' to build the\n$SRC directory."
42
die 1 "$DST already exists. You must remove it before continuing."
45
echo "Building compatibility version in '$DST' directory:"
48
echo -n "Copying $DST from $SRC..."
49
cp -r ${SRC}* $DST || die $? "Copy failed."
52
(( DEBUG )) && rsync --delete -aprl $DST post/ > /dev/null
63
rsync --delete -aprl post/ pre/ > /dev/null
65
[ -e patches/"$1" ] ||
66
die 3 "patches/$1 does not exist. Terminating."
67
echo -ne " + Applying: patches/$1\n\t"
68
cat "patches/$1" | while read command rest; do
70
"Commit:" | "Author:" | "")
72
*) echo "$command $rest"
78
patch -p1 -d $OUT < patches/"$1" > .patch.output || {
79
echo "-----patch failure output-----"
82
die 1 "patches/$1 failed. Terminating."
84
[ -e .patch.output ] && rm .patch.output
89
[ -x "patches/$1" ] ||
90
die 3 "patches/$1 does not exist. Terminating."
91
echo -ne " + Running: $1\n\t"
92
head -n 2 "patches/$1" | tail -n 1 | sed -e 's,^#[[:space:]]*,,g' ||
96
rsync --delete -aprl post/ pre/ > /dev/null
98
patches/$1 $OUT || return 1
103
(( !$has_new_qdisc )) && {
104
do_patch qdisc-api.patch ||
105
die $? "Failure creating new qdisc compatibility."
108
(( !$has_i_private )) && {
109
do_script i_private.sh ||
110
die $? "Failure creating i_private rename compatibility."
113
(( !$has_block_cipher )) && {
114
do_patch block-cipher.patch ||
115
die $? "Failure creating block cipher compatibility."
118
(( !$has_debugfs_symlink )) && {
119
do_patch debugfs_create_symlink.patch ||
120
die $? "Failure creating debugfs symlink compatibility."
123
(( !$has_ieee80211_ptr )) && {
124
do_patch ieee80211_ptr.patch ||
125
die $? "Failure creating ieee80211_ptr compatibility."
126
do_script ieee80211_ptr.sh ||
127
die $? "Failure creating ieee80211_ptr compatibility."
130
(( !$has_delayed_work )) && {
131
do_patch delayed_work.patch &&
132
do_script delayed_work.sh &&
134
cp patches/kcompat-delayed_work.h post/net/mac80211/ ||
135
die $? "Failure creating delayed work compatibility."
137
cp patches/kcompat-delayed_work.h $DST/net/mac80211/ ||
138
die $? "Failure creating delayed work compatibility."
142
(( !$has_rtnl_notify )) && {
143
do_patch rtnl_notify.patch ||
144
die $? "Failure creating rtnl_notify compatiblity."
147
(( ! $has_class_dev_removed )) && {
148
(( ! $has_ieee80211_ptr )) && {
149
do_patch class_dev_to_dev-wireless-ieee80211_ptr.patch ||
150
die $? "Failure creating class_dev compatiblity."
152
do_patch class_dev_to_dev-wireless.patch ||
153
die $? "Failure creating class_dev compatiblity."
157
(( ! $has_dev_release )) && {
158
do_patch dev_release.patch ||
159
die $? "Failure creating dev_release compatiblity."
162
# The nl code isn't in Linus' tree as of commit-id:
163
# c1a13ff57ab1ce52a0aae9984594dbfcfbaf68c0
165
#(( !$has_new_genlmsg )) && {
166
# do_patch nl80211-remove-kconfig.patch ||
167
# die $? "Failure removing nl80211 from config"
170
# The cfg80211 files aren't in Linus' tree as of commit-id:
171
# c1a13ff57ab1ce52a0aae9984594dbfcfbaf68c0
173
#(( !$has_device_rename )) && {
174
# (( $has_new_genlmsg )) && {
175
# do_patch nl80211-remove-kconfig.patch ||
176
# die $? "Failure removing nl80211 from config (req. since no device_rename)"
178
# do_patch device_rename.patch ||
179
# die $? "Failure removing device_rename usage"
182
(( !$has_net_sch_fifo )) && {
183
do_patch net_sch_fifo.patch ||
184
die $? "Failure adding net_sch_fifo compatibility."
187
(( !$has_skb_mac_header )) && {
188
do_patch skb_mac_header.patch
190
cp patches/kcompat-skb_mac_header.h post/net/mac80211/ ||
191
die $? "Failure creating delayed work compatibility."
193
cp patches/kcompat-skb_mac_header.h $DST/net/mac80211/ ||
194
die $? "Failure creating delayed work compatibility."
198
(( !$has_ilog2 )) && {
199
do_script ilog2.sh ||
200
die $? "Failure running ilog2 compat script"
203
(( !$has_div_round_up )) && {
204
do_patch div_round_up.patch ||
205
die $? "Failure adding DIV_ROUND_UP compat"
208
(( !$has_seq_open_const )) && {
209
do_patch seq_open_const.patch ||
210
die $? "Failure adding seq_open() const compat"
213
(( !$has_nlmsg_trim )) && {
214
do_patch nlmsg_trim.patch ||
215
die $? "Failure nlmsg_trim removal compat"
218
(( !$has_tcf_destroy_chain )) && {
219
do_patch tcf_destroy_chain.patch ||
220
die $? "Failure tcf_destroy_chain compat"
223
#(( !$has_new_nla_policy )) && {
224
# do_patch nla_policy.patch ||
225
# die $? "Failure old nla_policy compat"
228
#(( !$has_new_nla_put_flag )) && {
229
# do_patch nla_put_flag.patch ||
230
# die $? "Failure old NLA_PUT_FLAG compat"
233
#(( !$has_new_nlmsg_new )) && {
234
# do_patch nlmsg_new.patch ||
235
# die $? "Failure old nlmsg_new() compat"
238
(( !$has_debugfs_rename )) && {
239
do_patch debugfs_rename.patch ||
240
die $? "Failure debugfs_rename() compat"
243
(( DEBUG )) || exit 0
245
rsync --delete -avprl post/ $DST > /dev/null &&