forked from jellyfin/jellyfin-mpv-shim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen_pkg.sh
executable file
·142 lines (129 loc) · 4.31 KB
/
gen_pkg.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
#!/bin/bash
# This script:
# - Checks the current version
# - Verifies all versions match and are newer
# - Downloads/updates web client
# - Download/updates default-shader-pack
# - Generates locales
# - Builds the python package
cd "$(dirname "$0")"
function download_compat {
if [[ "$AZ_CACHE" != "" ]]
then
download_id=$(echo "$2" | md5sum | sed 's/ .*//g')
if [[ -e "$AZ_CACHE/$3/$download_id" ]]
then
echo "Cache hit: $AZ_CACHE/$3/$download_id"
cp "$AZ_CACHE/$3/$download_id" "$1"
return
elif [[ "$3" != "" ]]
then
rm -r "$AZ_CACHE/$3" 2> /dev/null
fi
fi
if [[ "$(which wget 2>/dev/null)" != "" ]]
then
wget -qO "$1" "$2"
else [[ "$(which curl)" != "" ]]
curl -sL "$2" > "$1"
fi
if [[ "$AZ_CACHE" != "" ]]
then
echo "Saving to: $AZ_CACHE/$3/$download_id"
mkdir -p "$AZ_CACHE/$3/"
cp "$1" "$AZ_CACHE/$3/$download_id"
fi
}
function get_resource_version {
curl -s --head https://github.com/"$1"/releases/latest | \
grep -i '^location: ' | sed 's/.*tag\///g' | tr -d '\r'
}
if [[ "$1" == "--get-pyinstaller" ]]
then
echo "Downloading pyinstaller..."
pi_version=$(get_resource_version pyinstaller/pyinstaller)
download_compat release.zip "https://github.com/pyinstaller/pyinstaller/archive/$pi_version.zip" "pi"
(
mkdir pyinstaller
cd pyinstaller
unzip ../release.zip > /dev/null && rm ../release.zip
mv pyinstaller-*/* ./
rm -r pyinstaller-*
)
exit 0
elif [[ "$1" == "--gen-fingerprint" ]]
then
(
get_resource_version pyinstaller/pyinstaller
get_resource_version iwalton3/default-shader-pack
) | tee az-cache-fingerprint.list
exit 0
fi
# Verify versioning
current_version=$(get_resource_version jellyfin/jellyfin-mpv-shim)
current_version=${current_version:1}
constants_version=$(cat jellyfin_mpv_shim/constants.py | grep '^CLIENT_VERSION' | cut -d '"' -f 2)
setup_version=$(grep 'version=' setup.py | cut -d '"' -f 2)
iss_version=$(grep '^#define MyAppVersion' "Jellyfin MPV Shim.iss" | cut -d '"' -f 2)
appdata_version=$(grep 'release version="' jellyfin_mpv_shim/integration/com.github.iwalton3.jellyfin-mpv-shim.appdata.xml | \
head -n 1 | cut -d '"' -f 2)
if [[ "$current_version" == "$constants_version" ]]
then
echo "Warning: This version matches the current published version."
echo "If you are building a release, the publish will not succeed."
fi
if [[ "$constants_version" != "$setup_version" || "$setup_version" != "$iss_version" || "$iss_version" != "$appdata_version" ]]
then
echo "Error: The release does not have the same version numbers in all files!"
echo "Please correct this before releasing!"
echo "Constants: $constants_version, Setup: $setup_version, ISS: $iss_version, Flatpak: $appdata_version"
fi
# Generate translations
find -iname '*.po' | while read -r file
do
msgfmt "$file" -o "${file%.*}.mo"
done
# Download default-shader-pack
update_shader_pack="no"
if [[ ! -e "jellyfin_mpv_shim/default_shader_pack" ]]
then
update_shader_pack="yes"
elif [[ -e ".last_sp_version" ]]
then
if [[ "$(get_resource_version iwalton3/default-shader-pack)" != "$(cat .last_sp_version)" ]]
then
update_shader_pack="yes"
fi
fi
if [[ "$update_shader_pack" == "yes" ]]
then
echo "Downloading shaders..."
sp_version=$(get_resource_version iwalton3/default-shader-pack)
download_compat release.zip "https://github.com/iwalton3/default-shader-pack/archive/$sp_version.zip" "sp"
rm -r jellyfin_mpv_shim/default_shader_pack 2> /dev/null
(
mkdir default_shader_pack
cd default_shader_pack
unzip ../release.zip > /dev/null && rm ../release.zip
mv default-shader-pack-*/* ./
rm -r default-shader-pack-*
)
mv default_shader_pack jellyfin_mpv_shim/
echo "$sp_version" > .last_sp_version
fi
# Generate package
if [[ "$1" == "--install" ]]
then
if [[ "$(which sudo 2> /dev/null)" != "" && ! "$*" =~ "--local" ]]
then
sudo pip3 install .[all]
else
pip3 install .[all]
fi
elif [[ "$1" != "--skip-build" ]]
then
rm -r build/ dist/ .eggs 2> /dev/null
mkdir build/ dist/
echo "Building release package."
python3 setup.py sdist bdist_wheel > /dev/null
fi