-
Notifications
You must be signed in to change notification settings - Fork 15
/
build.sh
executable file
·78 lines (67 loc) · 2.71 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
#!/bin/sh
project_name="ua3f"
release_version="0.7.2"
target=main.go
dist=./dist
release_dir=./bin
rm -rf $release_dir/*
rm -rf $dist/*
mkdir -p $release_dir
mkdir -p $dist/bin
cd $(dirname $0)
gofmt -w ./
cd $(dirname $0)/src
for goarch in "amd64" "arm" "arm64" "mipsle" "mips64" "riscv64" "386"; do
obj_name=$project_name-$release_version-$goarch
GOOS=linux GOARCH=$goarch go build -trimpath -ldflags="-s -w" -o $obj_name $target
cp $obj_name ../dist/bin/
mv $obj_name $project_name
tar -zcf ../bin/$project_name-$release_version-$goarch.tar.gz $project_name
rm -f $project_name
done
# mipsle-softfloat
obj_name=$project_name-$release_version-mipsle-softfloat
GOOS=linux GOARCH="mipsle" GOMIPS=softfloat go build -trimpath -ldflags="-s -w" -o $obj_name $target
cp $obj_name ../dist/bin/
mv $obj_name $project_name
tar -zcf ../bin/$project_name-$release_version-mipsle-softfloat.tar.gz $project_name
rm -f $project_name
# mipsle-hardfloat
obj_name=$project_name-$release_version-mipsle-hardfloat
GOOS=linux GOARCH="mipsle" GOMIPS=hardfloat go build -trimpath -ldflags="-s -w" -o $obj_name $target
cp $obj_name ../dist/bin/
mv $obj_name $project_name
tar -zcf ../bin/$project_name-$release_version-mipsle-hardfloat.tar.gz $project_name
rm -f $project_name
# armv7
obj_name=$project_name-$release_version-armv7
GOOS=linux GOARCH="arm" GOARM=7 go build -trimpath -ldflags="-s -w" -o $obj_name $target
cp $obj_name ../dist/bin/
mv $obj_name $project_name
tar -zcf ../bin/$project_name-$release_version-armv7.tar.gz $project_name
rm -f $project_name
# armv8
cp ../bin/$project_name-$release_version-arm64.tar.gz ../bin/$project_name-$release_version-armv8.tar.gz
cp ../dist/bin/$project_name-$release_version-arm64 ../dist/bin/$project_name-$release_version-armv8
cd ../bin
for file in ./*; do
md5 -r $file >>sha1sum.txt
done
cd ..
opkg_template=./ipkg
ipkg_build=ipkg-build.sh
mkdir -p $opkg_template/usr/bin
mkdir -p $opkg_template/usr/lib/lua/luci/controller
mkdir -p $opkg_template/usr/lib/lua/luci/model/cbi
mkdir -p $opkg_template/etc/init.d
mkdir -p $opkg_template/etc/config
cp openwrt/files/luci/controller.lua $opkg_template/usr/lib/lua/luci/controller/ua3f.lua
cp openwrt/files/luci/cbi.lua $opkg_template/usr/lib/lua/luci/model/cbi/ua3f.lua
cp openwrt/files/ua3f.init $opkg_template/etc/init.d/ua3f
cp openwrt/files/ua3f.uci $opkg_template/etc/config/ua3f
for goarch in "amd64" "arm" "arm64" "mipsle" "mips64" "riscv64" "386" "mipsle-softfloat" "mipsle-hardfloat" "armv7" "armv8"; do
obj_name=$project_name-$release_version-$goarch
mv $dist/bin/$obj_name $opkg_template/usr/bin/ua3f
sh $ipkg_build $opkg_template
mv $project_name"_"$release_version-1_all.ipk $dist/$project_name"_"$release_version-1_$goarch.ipk
done