jellyfin-mpv-shim/gen_pkg.sh

143 lines
4.3 KiB
Bash
Raw Normal View History

2020-08-14 05:14:16 +00:00
#!/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")"
2020-08-14 05:43:40 +00:00
function download_compat {
2020-08-25 01:32:49 +00:00
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
2020-08-14 05:54:20 +00:00
if [[ "$(which wget 2>/dev/null)" != "" ]]
2020-08-14 05:43:40 +00:00
then
wget -qO "$1" "$2"
else [[ "$(which curl)" != "" ]]
2020-08-14 05:54:20 +00:00
curl -sL "$2" > "$1"
2020-08-14 05:43:40 +00:00
fi
2020-08-25 01:32:49 +00:00
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
2020-08-14 05:43:40 +00:00
}
2020-08-14 05:14:16 +00:00
function get_resource_version {
2020-08-25 02:01:12 +00:00
curl -s --head https://github.com/"$1"/releases/latest | \
2020-08-14 05:14:16 +00:00
grep -i '^location: ' | sed 's/.*tag\///g' | tr -d '\r'
}
2020-08-25 02:01:12 +00:00
if [[ "$1" == "--get-pyinstaller" ]]
then
echo "Downloading pyinstaller..."
2023-02-13 08:03:17 +00:00
pi_version=$(get_resource_version pyinstaller/pyinstaller)
2020-08-25 02:01:12 +00:00
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
2020-08-25 02:20:39 +00:00
elif [[ "$1" == "--gen-fingerprint" ]]
then
(
get_resource_version pyinstaller/pyinstaller
get_resource_version iwalton3/default-shader-pack
2020-08-25 02:24:54 +00:00
) | tee az-cache-fingerprint.list
2020-08-25 02:20:39 +00:00
exit 0
2020-08-25 02:01:12 +00:00
fi
2020-08-14 05:14:16 +00:00
# Verify versioning
2021-04-20 00:07:38 +00:00
current_version=$(get_resource_version jellyfin/jellyfin-mpv-shim)
2020-08-14 05:14:16 +00:00
current_version=${current_version:1}
constants_version=$(cat jellyfin_mpv_shim/constants.py | grep '^CLIENT_VERSION' | cut -d '"' -f 2)
2024-05-14 06:38:59 +00:00
setup_version=$(grep 'version=' setup.py | cut -d '"' -f 2 | sed 's/.post.*//g')
2021-04-20 00:07:38 +00:00
iss_version=$(grep '^#define MyAppVersion' "Jellyfin MPV Shim.iss" | cut -d '"' -f 2)
2020-08-14 05:14:16 +00:00
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
2020-08-25 02:01:12 +00:00
if [[ "$(get_resource_version iwalton3/default-shader-pack)" != "$(cat .last_sp_version)" ]]
2020-08-14 05:14:16 +00:00
then
update_shader_pack="yes"
fi
fi
if [[ "$update_shader_pack" == "yes" ]]
then
echo "Downloading shaders..."
2020-08-25 02:01:12 +00:00
sp_version=$(get_resource_version iwalton3/default-shader-pack)
2020-08-25 01:32:49 +00:00
download_compat release.zip "https://github.com/iwalton3/default-shader-pack/archive/$sp_version.zip" "sp"
2020-08-14 05:14:16 +00:00
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
2020-08-14 05:43:40 +00:00
if [[ "$1" == "--install" ]]
2020-08-14 05:14:16 +00:00
then
if [[ "$(which sudo 2> /dev/null)" != "" && ! "$*" =~ "--local" ]]
then
sudo pip3 install .[all]
else
pip3 install .[all]
fi
2020-08-14 05:43:40 +00:00
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
2020-08-14 05:14:16 +00:00
fi