This repository has been archived by the owner on Aug 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 338
/
build.sh
executable file
·167 lines (155 loc) · 5.78 KB
/
build.sh
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
155
156
157
158
159
160
161
162
163
164
165
166
#!/bin/bash
CRTDIR=$(pwd)
base=$1
profile=$2
ui=$3
tag=$4
tagm=$5
echo $base
if [ ! -e "$base" ]; then
echo "Please enter base folder"
exit 1
else
if [ ! -d $base ]; then
echo "Openwrt base folder not exist"
exit 1
fi
fi
if [ ! -n "$profile" ]; then
profile=target_wlan_ap-gl-ax1800
fi
if [ ! -n "$ui" ]; then
ui=true
fi
if [ ! -n "$tag" ]; then
tag=main
fi
if [ ! -n "$tagm" ]; then
tagm=main
fi
if [[ $ui == true ]]; then
git clone -b $tagm https://github.com/gl-inet/glinet4.x.git ~/glinet
fi
echo "Start..."
#clone source tree
git clone -b $tag https://github.com/gl-inet/gl-infra-builder.git $base/gl-infra-builder
cp -r custom/ $base/gl-infra-builder/feeds/custom/
cp -r *.yml $base/gl-infra-builder/profiles
cd $base/gl-infra-builder
function build_firmware(){
cd ~/openwrt
need_gl_ui=$1
ui_path=$2
# fix helloword build error
rm -rf feeds/packages/lang/golang
svn co https://github.com/openwrt/packages/branches/openwrt-23.05/lang/golang feeds/packages/lang/golang
#install feed
./scripts/feeds update -a && ./scripts/feeds install -a && make defconfig
#build
if [[ $need_gl_ui == true ]]; then
make -j$(expr $(nproc) + 1) GL_PKGDIR=~/glinet/$ui_path/ V=s
else
make -j$(expr $(nproc) + 1) V=s
fi
return
}
function copy_file(){
path=$1
mkdir ~/firmware
mkdir ~/packages
cd $path
rm -rf packages
cp -rf ./* ~/firmware
cp -rf ~/openwrt/bin/packages/* ~/packages
return
}
case $profile in
target_wlan_ap-gl-ax1800|\
target_wlan_ap-gl-axt1800|\
target_wlan_ap-gl-ax1800-5-4|\
target_wlan_ap-gl-axt1800-5-4)
if [[ $profile == *5-4* ]]; then
python3 setup.py -c configs/config-wlan-ap-5.4.yml
else
python3 setup.py -c configs/config-wlan-ap.yml
fi
ln -s $base/gl-infra-builder/wlan-ap/openwrt ~/openwrt && cd ~/openwrt
if [[ $ui == true ]]; then
if [[ $profile == *ax1800* ]]; then
cp ~/glinet/pkg_config/gl_pkg_config_ax1800.mk ~/glinet/ipq60xx/gl_pkg_config.mk
cp ~/glinet/pkg_config/glinet_depends_ax1800.yml ./profiles/glinet_depends.yml
else
cp ~/glinet/pkg_config/gl_pkg_config_axt1800.mk ~/glinet/ipq60xx/gl_pkg_config.mk
cp ~/glinet/pkg_config/glinet_depends_axt1800.yml ./profiles/glinet_depends.yml
fi
./scripts/gen_config.py glinet_depends custom
else
./scripts/gen_config.py $profile openwrt_common glinet_nas luci custom
fi
build_firmware $ui ipq60xx && copy_file ~/openwrt/bin/targets/*/*
;;
target_mt7981_gl-mt2500|\
target_mt7981_gl-mt3000|\
target_mt7981_gl-x3000|\
target_mt7981_gl-xe3000)
python3 setup.py -c configs/config-mt798x-7.6.6.1.yml
ln -s $base/gl-infra-builder/mt7981 ~/openwrt && cd ~/openwrt
if [[ $ui == true ]]; then
if [[ $profile == *mt3000* ]]; then
cp ~/glinet/pkg_config/gl_pkg_config_mt3000.mk ~/glinet/mt7981/gl_pkg_config.mk
cp ~/glinet/pkg_config/glinet_depends_mt3000.yml ./profiles/glinet_depends.yml
./scripts/gen_config.py glinet_depends custom
elif [[ $profile == *mt2500* ]]; then
cp ~/glinet/pkg_config/gl_pkg_config_mt2500.mk ~/glinet/mt7981/gl_pkg_config.mk
cp ~/glinet/pkg_config/glinet_depends_mt2500.yml ./profiles/glinet_depends.yml
./scripts/gen_config.py glinet_depends custom
else
./scripts/gen_config.py $profile glinet_nas custom
fi
else
./scripts/gen_config.py $profile glinet_nas custom
fi
build_firmware $ui mt7981 && copy_file ~/openwrt/bin/targets/*/*
;;
target_siflower_gl-sf1200|\
target_siflower_gl-sft1200)
python3 setup.py -c configs/config-siflower-18.x.yml
ln -s $base/gl-infra-builder/openwrt-18.06/siflower/openwrt-18.06 ~/openwrt && cd ~/openwrt
./scripts/gen_config.py $profile glinet_nas custom
build_firmware && copy_file ~/openwrt/bin/targets/*
;;
target_ath79_gl-s200|\
target_ipq40xx_gl-a1300)
ui_path=
python3 setup.py -c configs/config-21.02.2.yml
ln -s $base/gl-infra-builder/openwrt-21.02/openwrt-21.02.2 ~/openwrt && cd ~/openwrt
if [[ $ui == true ]]; then
if [[ $profile == *s200* ]]; then
cp -rf ~/glinet/pkg_config/gl_pkg_config_ath79_s200.mk ~/glinet/ath79/gl_pkg_config.mk
cp -rf ~/glinet/pkg_config/gl_pkg_config_ath79_s200.yml ./profiles/
./scripts/gen_config.py $profile gl_pkg_config_ath79_s200 custom
ui_path=ath79
elif [[ $profile == *a1300* ]]; then
cp ~/glinet/pkg_config/gl_pkg_config_a1300.mk ~/glinet/ipq40xx/gl_pkg_config.mk
cp ~/glinet/pkg_config/glinet_depends_a1300.yml ./profiles/glinet_depends.yml
./scripts/gen_config.py glinet_depends custom
ui_path=ipq40xx
else
./scripts/gen_config.py $profile openwrt_common glinet_nas luci custom
fi
else
./scripts/gen_config.py $profile openwrt_common glinet_nas luci custom
fi
build_firmware $ui $ui_path && copy_file ~/openwrt/bin/targets/*/*
;;
target_ath79_gl-ar300m-nor|\
target_ath79_gl-ar300m-nand|\
target_ath79_gl-x300b-nor|\
target_ath79_gl-x300b-nor-nand|\
target_ramips_gl-mt1300)
python3 setup.py -c configs/config-22.03.4.yml
ln -s $base/gl-infra-builder/openwrt-22.03/openwrt-22.03.4 ~/openwrt && cd ~/openwrt
./scripts/gen_config.py $profile luci custom
build_firmware && copy_file ~/openwrt/bin/targets/*/*
;;
esac