forked from cilix-lab/ubuntu-wrt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update
executable file
·154 lines (146 loc) · 6.24 KB
/
update
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/bin/bash
ask() { local q="$1"; local d=${2:-"n"}
read -p "$q [$d]: " r; r=${r:-"$d"}
local i=0; while true; do
case $r in
y|Y|yes|Yes|yES|YES )
return 0
;;
n|N|no|No|nO )
return 1
;;
* )
i=$((i+1))
[ $i -le 3 ] && read -p "Not a valid answer. Try 'y' or 'n': " r || exit 1
continue
;;
esac
done
}
workdir=$(dirname $(realpath `dirname $0`)); err=0
distro="linux-stable"
current_tag="v4.14.32"
color_no='\033[0m'
color_fail='\033[0;31m'
color_ok='\033[0;32m'
echo "This script will pull sources from git and update Ubuntu-WRT."
echo "The sources of $distro will be needed. You should clone them to $workdir"
echo "folder. Current tag: $current_tag."
echo "Sources will be pulled within the parent directory: $workdir"
if ! ask "Do you wish to continue?" "y"; then exit 0; fi
# remove all $distro files
echo "Backing up .config."
cp "$workdir/ubuntu-wrt/$distro/.config" /tmp/config.backup
echo -n "Removing current files... "
rm -r "$workdir/ubuntu-wrt/$distro" > /dev/null 2>&1 &&\
echo -e "${color_ok}[OK]${color_no}" &&\
mkdir "$workdir/ubuntu-wrt/$distro" ||\
echo -e "${color_fail}[Failed]${color_no}"
if ! cp /tmp/config.backup "$workdir/ubuntu-wrt/$distro/.config" || ! rm /tmp/config.backup; then
echo "Something went wrong when trying to fetch .config backup."
exit 1
fi
# mwlwifi
cd "$workdir"; echo "Updating mwlwifi... "
[ ! -d ./mwlwifi ] && git clone https://github.com/kaloz/mwlwifi.git
if cd mwlwifi; then
git pull; cd ..
[ ! -d "ubuntu-wrt/$distro/drivers/net/wireless/marvell" ] && mkdir -p "ubuntu-wrt/$distro/drivers/net/wireless/marvell"
cp -r mwlwifi ubuntu-wrt/$distro/drivers/net/wireless/marvell/
rm -rf ubuntu-wrt/$distro/drivers/net/wireless/marvell/mwlwifi/.git
mv -f ubuntu-wrt/$distro/drivers/net/wireless/marvell/mwlwifi/Makefile.kernel ubuntu-wrt/$distro/drivers/net/wireless/marvell/mwlwifi/Makefile
rm -rf ubuntu-wrt/$distro/drivers/net/wireless/marvell/mwlwifi/bin
if [ -d "$workdir/$distro" ]; then
distro_ok=true
cd "$workdir/$distro"
if git status | grep -q 'Changes not staged for commit'; then
echo "Changes not commited on $distro. Please commit or drop changes."
exit 2
fi
if [ "$current_tag" != "$(git describe --tags)" ]; then
if ! git checkout tags/$current_tag > /dev/null; then
echo "Changes not commited on $distro. Please commit or drop changes."
exit 1
fi
fi
cd "$workdir/ubuntu-wrt/$distro"
for f in 'drivers/net/wireless/marvell/Kconfig' 'drivers/net/wireless/marvell/Makefile' 'firmware/Makefile' 'arch/arm/boot/dts/armada-385-linksys.dtsi' 'arch/arm/boot/dts/armada-385-linksys-rango.dts' 'drivers/leds/trigger/Kconfig' 'drivers/leds/trigger/ledtrig-netdev.c' 'drivers/leds/trigger/Makefile'; do
[ ! -d "$(dirname $f)" ] && mkdir -p "$(dirname $f)"
[ -f "$workdir/$distro/$f" ] &&\
cp -f "$workdir/$distro/$f" "$f" ||\
echo "File $f is missing... "
done
else
echo "$distro folder missing. Could not fetch necessary files!"
exit 1
fi
# Apply ValCher's patches
for p in 'https://raw.githubusercontent.com/ValCher1961/McDebian_WRT3200ACM/master/kernel-4.14.X/patch.mvdrv' 'https://raw.githubusercontent.com/ValCher1961/McDebian_WRT3200ACM/master/kernel-4.14.X/patch.nand-ecc' 'https://raw.githubusercontent.com/ValCher1961/McDebian_WRT3200ACM/master/kernel-4.14.X/patch.leds-net'; do
wget -q "$p" -O - | cat - | patch -p1
done &&\
rm -rf firmware
if ask "Do you wish to apply ValCher's regfree patch?" "y"; then
echo "Applying patches to mwlwifi... "
for f in 'https://raw.githubusercontent.com/ValCher1961/McDebian_WRT3200ACM/master/kernel-4.14.X/patch.rango.dts' 'https://raw.githubusercontent.com/ValCher1961/McDebian_WRT3200ACM/master/kernel-4.14.X/patch.regfree'; do
wget -q "$f" -O - | cat - | patch -p1
done
fi
else
echo "Failed to clone mwlwifi."
err=$((err+1))
fi
# mwifiex firmware
cd "$workdir"; echo "Updating mwifiex firmware... "
[ ! -d ./linux-firmware ] && git clone git:https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git
if cd linux-firmware; then
git pull; cd ..
else
echo "Failed to clone linux-firmware."
err=$((err+10))
fi
# sch_cake
cd "$workdir"; echo "Updating sch_cake... "
[ ! -d ./sch_cake ] && git clone https://github.com/dtaht/sch_cake.git
if cd sch_cake; then
git pull; cd ..
[ ! -d "ubuntu-wrt/$distro/net/sched" ] && mkdir -p "ubuntu-wrt/$distro/net/sched"
cp -f sch_cake/*.c sch_cake/*.h ubuntu-wrt/$distro/net/sched/
echo "Writing Kconfig and Makefile."
cd "$workdir/ubuntu-wrt/$distro"
for f in 'net/sched/Kconfig' 'net/sched/Makefile'; do
[ -f "$workdir/$distro/$f" ] &&\
cp -f "$workdir/$distro/$f" "$f" ||\
echo "File $f is missing... "
done
sed -i '/^obj-$(CONFIG_NET_SCH_PIE).*/a obj-$(CONFIG_NET_SCH_CAKE) += sch_cake.o' net/sched/Makefile
sed -i 's/^config NET_SCH_INGRESS$/config NET_SCH_CAKE\n\ttristate "Cake (Common Applications Kept Enhanced)"\n\t---help---\n\t Cake is the rollup of 3 years of deployment experience of the htb + fq_codel.\n\nconfig NET_SCH_INGRESS/' net/sched/Kconfig
else
echo "Failed to clone sch_cake."
err=$((err+100))
fi
# wireless-regdb
cd "$workdir"; echo "Updating wireless-regdb... "
[ ! -d ./wireless-regdb ] && git clone git:https://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-regdb.git
if cd wireless-regdb; then
git pull; cd ..
[ ! -d "ubuntu-wrt/$distro/net/wireless" ] && mkdir -p "ubuntu-wrt/$distro/net/wireless"
cp -f wireless-regdb/db.txt ubuntu-wrt/$distro/net/wireless/db.txt
else
echo "Failed to clone wireless-regdb."
err=$((err+1000))
fi
cd "$workdir"
if [ $err = 0 ]; then
if ask "Done. Do you wish to run ubuntu-wrt ./merge to update $distro sources?" "n"; then
[ -d "$workdir/$distro" ] &&\
ubuntu-wrt/merge -s ubuntu-wrt/$distro -t $distro -i ||\
echo "$workdir/$distro does not exist."
fi
echo
echo "Starting from kernel 4.14, firmware is no longer included in tree and it is not installed by make modules_install anymore."
echo "You should install manually from linux-firmware repository (mwifiex: linux-firmware/mrvl/sd8887_uapsta.bin) and mwlwifi (mwlwifi/bin/firmware/*.bin)."
echo
else
echo "There have been errors during update."
exit $err
fi