cosmic-player/redeploy.sh

48 lines
1.6 KiB
Bash
Executable file

#!/usr/bin/env bash
# Rebuild and deploy the local COSMIC Media Player fork.
#
# Keep this binary in /usr/local/bin so it intentionally overrides the packaged
# /usr/bin/cosmic-player, but only after rebuilding from the current local
# source tree.
set -euo pipefail
REPO="${COSMIC_PLAYER_REPO:-/home/lionel/Projets/COSMIC/cosmic-player}"
TOOLCHAIN="${COSMIC_RUST_TOOLCHAIN:-1.93.0}"
PREFIX="${COSMIC_LOCAL_PREFIX:-/usr/local}"
APPID="com.system76.CosmicPlayer"
BIN_NAME="cosmic-player"
cd "$REPO"
echo "==> Repository: $REPO"
echo "==> Branch: $(git branch --show-current 2>/dev/null || echo unknown)"
echo "==> Build release with Rust $TOOLCHAIN"
cargo "+$TOOLCHAIN" build --release
bin_built="$REPO/target/release/$BIN_NAME"
bin_target="$PREFIX/bin/$BIN_NAME"
if [[ -e "$bin_target" ]]; then
backup="${bin_target}.bak.$(date +%Y%m%d-%H%M%S)"
echo "==> Backup $bin_target -> $backup"
sudo cp -a "$bin_target" "$backup"
fi
echo "==> Install binary"
sudo install -Dm0755 "$bin_built" "$bin_target"
echo "==> Install desktop integration"
sudo install -Dm0644 "target/xdgen/$APPID.desktop" "$PREFIX/share/applications/$APPID.desktop"
sudo install -Dm0644 "target/xdgen/$APPID.metainfo.xml" "$PREFIX/share/metainfo/$APPID.metainfo.xml"
sudo install -Dm0644 "res/$APPID.thumbnailer" "$PREFIX/share/thumbnailers/$APPID.thumbnailer"
while IFS= read -r icon; do
rel="${icon#res/icons/hicolor/}"
sudo install -Dm0644 "$icon" "$PREFIX/share/icons/hicolor/$rel"
done < <(find "res/icons/hicolor" -type f -name "$APPID.svg" | sort)
echo "==> Installed version"
"$bin_target" --version
echo "OK - COSMIC Media Player rebuilt and redeployed."