-
Notifications
You must be signed in to change notification settings - Fork 11
/
build-linux.sh
executable file
·149 lines (118 loc) · 5.22 KB
/
build-linux.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
#!/usr/bin/env bash
# exit when any command fails
set -e
target_dir='target/universal-unknown-linux-gnu/release'
build_binary() {
export CROSS_NO_WARNINGS=0
cross build --target x86_64-unknown-linux-gnu --release
cross build --target aarch64-unknown-linux-gnu --release
cross build --target armv7-unknown-linux-gnueabihf --release
# Clean universal binary
rm -rf "${target_dir:?}/"
# Build universal binary
mkdir -p "$target_dir/"
mkdir -p "$target_dir/x86_64/"
mkdir -p "$target_dir/aarch64/"
mkdir -p "$target_dir/armv7l/"
cp "target/x86_64-unknown-linux-gnu/release/browsers" "$target_dir/x86_64/browsers"
cp "target/aarch64-unknown-linux-gnu/release/browsers" "$target_dir/aarch64/browsers"
cp "target/armv7-unknown-linux-gnueabihf/release/browsers" "$target_dir/armv7l/browsers"
}
build_app_bundle() {
cp "extra/linux/dist/install.sh" "$target_dir/install.sh"
cp "extra/linux/dist/uninstall.sh" "$target_dir/uninstall.sh"
mkdir -p "$target_dir/resources/"
mkdir -p "$target_dir/resources/icons/"
for size in 16 32 64 128 256 512; do
mkdir -p "$target_dir/resources/icons/${size}x${size}/"
cp "resources/icons/${size}x${size}/software.Browsers.png" "$target_dir/resources/icons/${size}x${size}/software.Browsers.png"
done
mkdir -p "$target_dir/resources/i18n/"
mkdir -p "$target_dir/resources/i18n/en-US/"
cp "resources/i18n/en-US/builtin.ftl" "$target_dir/resources/i18n/en-US/builtin.ftl"
mkdir -p "$target_dir/resources/repository/"
cp "resources/repository/application-repository.toml" "$target_dir/resources/repository/application-repository.toml"
mkdir -p "$target_dir/template/"
mkdir -p "$target_dir/template/share/"
mkdir -p "$target_dir/template/share/applications/"
cp "extra/linux/dist/software.Browsers.template.desktop" "$target_dir/template/share/applications/software.Browsers.template.desktop"
mkdir -p "$target_dir/template/share/xfce4/"
mkdir -p "$target_dir/template/share/xfce4/helpers/"
cp "extra/linux/dist/xfce4/helpers/software.Browsers.template.desktop" "$target_dir/template/share/xfce4/helpers/software.Browsers.template.desktop"
}
make_archives() {
rm -f "./${target_dir:?}/browsers_linux.tar.gz"
rm -f "./${target_dir:?}/browsers_linux.tar.gz.sha256"
rm -f "./${target_dir:?}/browsers_linux.tar.gz.sig"
rm -f "./${target_dir:?}/browsers_linux.tar.xz"
rm -f "./${target_dir:?}/browsers_linux.tar.xz.sha256"
rm -f "./${target_dir:?}/browsers_linux.tar.xz.sig"
local filelist=(
'./x86_64/browsers'
'./aarch64/browsers'
'./armv7l/browsers'
'./resources/i18n/en-US/builtin.ftl'
'./resources/icons/16x16/software.Browsers.png'
'./resources/icons/32x32/software.Browsers.png'
'./resources/icons/64x64/software.Browsers.png'
'./resources/icons/128x128/software.Browsers.png'
'./resources/icons/256x256/software.Browsers.png'
'./resources/icons/512x512/software.Browsers.png'
'./resources/repository/application-repository.toml'
'./template/share/applications/software.Browsers.template.desktop'
'./template/share/xfce4/helpers/software.Browsers.template.desktop'
'./install.sh'
'./uninstall.sh'
)
tar -zcf "./$target_dir/browsers_linux.tar.gz" \
-C "./$target_dir" \
"${filelist[@]}"
create_signatures "$target_dir" "browsers_linux.tar.gz"
tar -Jcf "./$target_dir/browsers_linux.tar.xz" \
-C "./$target_dir" \
"${filelist[@]}"
create_signatures "$target_dir" "browsers_linux.tar.xz"
}
create_signatures() {
local target_dir="$1"
local file_name="$2"
# creates $filename.sha256
shasum --algorithm 256 "./$target_dir/$file_name" | cut -f1 -d' ' >"./$target_dir/$file_name.sha256"
# creates $filename.sig
signify -S -s "$APPCAST_SECRET_KEY_FILE" -m "./$target_dir/$file_name"
}
build_deb() {
# Build deb package
cd extra/linux || exit
./linux-deb-build.sh "$1" "$2"
cd ../../
}
make_deb_packages() {
# creating deb does not depend on universal directory at all, but will store the deb there
build_deb "amd64" "target/x86_64-unknown-linux-gnu"
build_deb "arm64" "target/aarch64-unknown-linux-gnu"
build_deb "armhf" "target/armv7-unknown-linux-gnueabihf"
cp "target/x86_64-unknown-linux-gnu/release/browsers_amd64.deb" "$target_dir/x86_64/browsers_amd64.deb"
cp "target/aarch64-unknown-linux-gnu/release/browsers_arm64.deb" "$target_dir/aarch64/browsers_arm64.deb"
cp "target/armv7-unknown-linux-gnueabihf/release/browsers_armhf.deb" "$target_dir/armv7l/browsers_armhf.deb"
}
build_rpm() {
# Build rpm package
cd extra/linux || exit
./linux-rpm-build.sh "$1" "$2"
cd ../../
}
make_rpm_packages() {
# creating rpm does not depend on universal directory at all, but will store the rpm there
build_rpm "x86_64" "target/x86_64-unknown-linux-gnu"
build_rpm "aarch64" "target/aarch64-unknown-linux-gnu"
build_rpm "armhfp" "target/armv7-unknown-linux-gnueabihf"
cp "target/x86_64-unknown-linux-gnu/release/browsers.x86_64.rpm" "$target_dir/x86_64/browsers.x86_64.rpm"
cp "target/aarch64-unknown-linux-gnu/release/browsers.aarch64.rpm" "$target_dir/aarch64/browsers.aarch64.rpm"
cp "target/armv7-unknown-linux-gnueabihf/release/browsers.armhfp.rpm" "$target_dir/armv7l/browsers.armhfp.rpm"
}
build_binary
build_app_bundle
make_archives
make_deb_packages
make_rpm_packages