70 lines
2.3 KiB
Bash
Executable file
70 lines
2.3 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)
|
|
|
|
if command -v update-desktop-database >/dev/null 2>&1; then
|
|
echo "==> Refresh desktop database"
|
|
if [[ -w "$PREFIX/share/applications" ]]; then
|
|
update-desktop-database "$PREFIX/share/applications" || true
|
|
else
|
|
sudo -n update-desktop-database "$PREFIX/share/applications" 2>/dev/null || \
|
|
echo " skipped: sudo authentication required"
|
|
fi
|
|
fi
|
|
|
|
if command -v xdg-mime >/dev/null 2>&1; then
|
|
echo "==> Register common legacy video defaults"
|
|
xdg-mime default "$APPID.desktop" \
|
|
video/mpeg \
|
|
video/x-mpeg \
|
|
video/x-mpeg2 \
|
|
video/x-ms-wmv \
|
|
video/x-ms-wm \
|
|
video/x-ms-asf \
|
|
application/vnd.ms-asf
|
|
fi
|
|
|
|
echo "==> Installed version"
|
|
"$bin_target" --version
|
|
|
|
echo "OK - COSMIC Media Player rebuilt and redeployed."
|