-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathbuild_tarball.sh
133 lines (111 loc) · 3.87 KB
/
build_tarball.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
#!/bin/bash
set -e
usage() {
echo "Usage: $(basename "$0") [-h] [-a <x64|armv7l|arm64|all> default=x64]"
echo
echo " Options:"
echo " -a Architecture to build for (<x64|armv7l|arm64|all> default=x64)"
echo " -o Output directory"
echo " -h Show this help and exit"
}
download_electron_binary(){
arch=${1}
echo "Downloading electron ${arch}"
LINK=$(jq -r .electron."${arch}" ./utility/version_info.json)
curl -L -o "${TEMPDIR}/electron-${arch}.zip" "${LINK}"
unzip -q "${TEMPDIR}/electron-${arch}.zip" -d "${TEMPDIR}/electron-${arch}"
}
build_tarball(){
arch=${1}
app_dir="${TEMPDIR}/yandex-music_${version}_${arch}"
mkdir -p "${app_dir}/usr/lib/yandex-music"
mkdir -p "${app_dir}/usr/share/applications"
mkdir -p "${app_dir}/usr/share/licenses/yandex-music"
mkdir -p "${app_dir}/usr/share/pixmaps"
mkdir -p "${app_dir}/usr/bin"
install -Dm644 "${TEMPDIR}/app/yandex-music.asar" "${app_dir}/usr/lib/yandex-music/yandex-music.asar"
install -Dm644 "${TEMPDIR}/app/favicon.png" "${app_dir}/usr/share/pixmaps/yandex-music.png"
install -Dm644 "${TEMPDIR}/app/favicon.png" "${app_dir}/usr/share/icons/hicolor/48x48/apps/yandex-music.png"
install -Dm644 "${TEMPDIR}/app/favicon-512x512.png" "${app_dir}/usr/share/icons/hicolor/512x512/apps/yandex-music.png"
install -Dm644 "${TEMPDIR}/app/favicon.svg" "${app_dir}/usr/share/icons/hicolor/scalable/apps/yandex-music.svg"
install -Dm644 "./templates/desktop" "${app_dir}/usr/share/applications/yandex-music.desktop"
install -Dm644 "./templates/default.conf" "${app_dir}/usr/lib/yandex-music/default.conf"
install -Dm644 "./LICENSE.md" "${app_dir}/usr/share/licenses/yandex-music/LICENSE"
mv "${TEMPDIR}/electron-${arch}/" "${app_dir}/usr/lib/yandex-music/electron"
install -Dm755 "./templates/yandex-music.sh" "${app_dir}/usr/bin/yandex-music"
sed -i "s|%electron_path%|/usr/lib/yandex-music/electron/electron|g" "${app_dir}/usr/bin/yandex-music"
sed -i "s|%asar_path%|/usr/lib/yandex-music/yandex-music.asar|g" "${app_dir}/usr/bin/yandex-music"
cd "${app_dir}"
tar -czf "${OUTPUT_DIR}/yandex-music_${version}_${arch}.tar.gz" *
cd "${INITIAL_DIR}"
}
INITIAL_DIR="${PWD}"
OUTPUT_DIR="${PWD}/tar"
x64=0
armv7l=0
arm64=0
#checking for arch option (if not specified set x64) and h option
while getopts :a:h name; do
case ${name} in
a)
case ${OPTARG} in
x64) x64=1 ;;
armv7l) armv7l=1 ;;
arm64) arm64=1 ;;
all)
x64=1
armv7l=1
arm64=1
;;
*)
echo "Invalid architecture specified"
usage
exit 1
;;
esac
;;
h)
usage
exit 0
;;
*)
usage
exit 1
;;
esac
done
#checking if at least one arch is specified else set x64
if [ ${x64} -eq 0 ] && [ ${armv7l} -eq 0 ] && [ ${arm64} -eq 0 ]; then
x64=1
fi
clear() {
rm -rf "${TEMPDIR}"
}
TEMPDIR="$(mktemp -d)"
trap clear EXIT
#loading version info with jq
version=$(jq -r '.ym.version' ./utility/version_info.json)
exe_name=$(jq -r '.ym.exe_name' ./utility/version_info.json)
exe_link=$(jq -r '.ym.exe_link' ./utility/version_info.json)
exe_sha256=$(jq -r '.ym.exe_sha256' ./utility/version_info.json)
#downloading exe
echo "Downloading ${exe_name}"
curl -L -o "${TEMPDIR}/${exe_name}" "${exe_link}"
#checking sha256
echo "Checking sha256"
echo "${exe_sha256} ${TEMPDIR}/${exe_name}" | sha256sum -c
echo "Repaking ${exe_name}"
bash repack.sh -o "${TEMPDIR}/app" "${TEMPDIR}/${exe_name}"
mkdir -p "${OUTPUT_DIR}"
if [ ${x64} -eq 1 ]; then
download_electron_binary "x64"
build_tarball "x64"
fi
if [ ${armv7l} -eq 1 ]; then
download_electron_binary "armv7l"
build_tarball "armv7l"
fi
if [ ${arm64} -eq 1 ]; then
download_electron_binary "arm64"
build_tarball "arm64"
fi