feat: better linux packaging

close #24
This commit is contained in:
edde746
2025-12-26 15:27:59 +01:00
parent 3494fbc5be
commit 2ad06c4dbc
7 changed files with 253 additions and 8 deletions
+25 -5
View File
@@ -359,13 +359,16 @@ jobs:
- name: Cache APT packages - name: Cache APT packages
uses: awalsh128/cache-apt-pkgs-action@latest uses: awalsh128/cache-apt-pkgs-action@latest
with: with:
packages: clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev libstdc++-12-dev libasound2-dev libmpv-dev mpv keybinder-3.0 packages: clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev libstdc++-12-dev libasound2-dev libmpv-dev mpv keybinder-3.0 ruby ruby-dev rubygems build-essential rpm libarchive-tools imagemagick
version: 1.0 version: 1.1
- name: Install Linux dependencies - name: Install Linux dependencies
run: | run: |
sudo apt-get update sudo apt-get update
sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev libstdc++-12-dev libasound2-dev libmpv-dev mpv keybinder-3.0 sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev libstdc++-12-dev libasound2-dev libmpv-dev mpv keybinder-3.0 ruby ruby-dev rubygems build-essential rpm libarchive-tools imagemagick
- name: Install fpm
run: sudo gem install fpm
- name: Install dependencies - name: Install dependencies
run: flutter pub get run: flutter pub get
@@ -378,10 +381,17 @@ jobs:
cd build/linux/x64/release/bundle cd build/linux/x64/release/bundle
tar -czf $GITHUB_WORKSPACE/plezy-linux.tar.gz * tar -czf $GITHUB_WORKSPACE/plezy-linux.tar.gz *
- name: Attest Linux tarball - name: Build Linux Packages
run: OUTPUT_DIR=$GITHUB_WORKSPACE python3 linux/packaging/build-packages.py
- name: Attest Linux artifacts
uses: actions/attest-build-provenance@v2 uses: actions/attest-build-provenance@v2
with: with:
subject-path: plezy-linux.tar.gz subject-path: |
plezy-linux.tar.gz
plezy-linux.deb
plezy-linux.rpm
plezy-linux.pkg.tar.zst
- name: Upload Linux App - name: Upload Linux App
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
@@ -389,6 +399,15 @@ jobs:
name: linux-app name: linux-app
path: plezy-linux.tar.gz path: plezy-linux.tar.gz
- name: Upload Linux Packages
uses: actions/upload-artifact@v4
with:
name: linux-packages
path: |
plezy-linux.deb
plezy-linux.rpm
plezy-linux.pkg.tar.zst
create-release: create-release:
needs: [build-android, build-ios, build-macos, build-windows, build-linux] needs: [build-android, build-ios, build-macos, build-windows, build-linux]
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -415,6 +434,7 @@ jobs:
artifacts/windows-portable/plezy-windows-portable.7z artifacts/windows-portable/plezy-windows-portable.7z
artifacts/windows-installer/plezy-windows-installer.exe artifacts/windows-installer/plezy-windows-installer.exe
artifacts/linux-app/plezy-linux.tar.gz artifacts/linux-app/plezy-linux.tar.gz
artifacts/linux-packages/*
draft: true draft: true
prerelease: false prerelease: false
generate_release_notes: true generate_release_notes: true
+3 -3
View File
@@ -19,9 +19,9 @@ A modern Plex client for desktop and mobile. Built with Flutter for native perfo
### Desktop ### Desktop
- [Windows (x64)](https://github.com/edde746/plezy/releases/latest/download/plezy-windows-installer.exe) - [Windows (x64)](https://github.com/edde746/plezy/releases/latest/download/plezy-windows-installer.exe)
- [macOS (Universal)](https://github.com/edde746/plezy/releases/latest/download/plezy-macos.zip) - [macOS (Universal)](https://github.com/edde746/plezy/releases/latest/download/plezy-macos.dmg)
- [Linux (x64)](https://github.com/edde746/plezy/releases/latest/download/plezy-linux.tar.gz) - [Linux (x64)](https://github.com/edde746/plezy/releases/latest) - .deb, .rpm, .pkg.tar.zst, and portable tar.gz available
- [NixOS/Nix](https://github.com/mio-19/nurpkgs/tree/main/pkgs/plezy) - Community package by [@mio-19](https://github.com/mio-19) via `nur.repos.mio.plezy` - [NixOS/Nix](https://github.com/mio-19/nurpkgs/tree/main/pkgs/plezy) - Community package by [@mio-19](https://github.com/mio-19)
## Features ## Features
+10
View File
@@ -0,0 +1,10 @@
#!/bin/bash
# Update icon cache
if command -v gtk-update-icon-cache &> /dev/null; then
gtk-update-icon-cache -f -t /usr/share/icons/hicolor || true
fi
# Update desktop database
if command -v update-desktop-database &> /dev/null; then
update-desktop-database /usr/share/applications || true
fi
+10
View File
@@ -0,0 +1,10 @@
#!/bin/bash
# Update icon cache
if command -v gtk-update-icon-cache &> /dev/null; then
gtk-update-icon-cache -f -t /usr/share/icons/hicolor || true
fi
# Update desktop database
if command -v update-desktop-database &> /dev/null; then
update-desktop-database /usr/share/applications || true
fi
+192
View File
@@ -0,0 +1,192 @@
#!/usr/bin/env python3
import os
import re
import subprocess
import shutil
from pathlib import Path
# Paths
SCRIPT_DIR = Path(__file__).parent.resolve()
PROJECT_ROOT = SCRIPT_DIR.parent.parent
BUILD_DIR = PROJECT_ROOT / "build/linux/x64/release/bundle"
OUTPUT_DIR = Path(os.environ.get("OUTPUT_DIR", PROJECT_ROOT))
# Package metadata
METADATA = {
"name": "plezy",
"license": "Proprietary",
"vendor": "edde746",
"maintainer": "edde746 <noreply@github.com>",
"url": "https://github.com/edde746/plezy",
"description": "A modern Plex client for desktop and mobile",
}
# Icon sizes to generate
ICON_SIZES = [16, 32, 48, 64, 128, 256, 512]
# Distro-specific configuration
DISTROS = {
"deb": {
"type": "deb",
"arch": "amd64",
"category": "video",
"ext": "deb",
"compression": ["--deb-compression", "xz", "--deb-priority", "optional"],
"depends": [
"libgtk-3-0",
"libmpv2 | libmpv1",
"libepoxy0",
"libkeybinder-3.0-0",
"libasound2",
"libglib2.0-0",
],
},
"rpm": {
"type": "rpm",
"arch": "x86_64",
"category": "Multimedia",
"ext": "rpm",
"compression": ["--rpm-compression", "xzmt"],
"depends": [
"gtk3",
"mpv-libs",
"libepoxy",
"keybinder3",
"alsa-lib",
"glib2",
],
},
"pacman": {
"type": "pacman",
"arch": "x86_64",
"category": None,
"ext": "pkg.tar.zst",
"compression": ["--pacman-compression", "zstd"],
"depends": [
"gtk3",
"mpv",
"libepoxy",
"keybinder3",
"alsa-lib",
"glib2",
],
},
}
def get_version() -> str:
"""Extract version from pubspec.yaml."""
pubspec = PROJECT_ROOT / "pubspec.yaml"
content = pubspec.read_text()
match = re.search(r"^version:\s*(.+)$", content, re.MULTILINE)
if not match:
raise RuntimeError("Could not find version in pubspec.yaml")
return match.group(1).split("+")[0]
def generate_icons():
"""Generate icons at multiple sizes using ImageMagick."""
print("Generating icons...")
source = PROJECT_ROOT / "assets/plezy.png"
for size in ICON_SIZES:
dest_dir = SCRIPT_DIR / f"icons/{size}x{size}"
dest_dir.mkdir(parents=True, exist_ok=True)
dest = dest_dir / "plezy.png"
# Try magick (ImageMagick 7) first, then convert (ImageMagick 6)
for cmd in ["magick", "convert"]:
if shutil.which(cmd):
subprocess.run([cmd, str(source), "-resize", f"{size}x{size}", str(dest)], check=True)
break
else:
print(f"Warning: ImageMagick not found, copying original icon for {size}x{size}")
shutil.copy(source, dest)
def get_file_mappings() -> list[str]:
"""Get file mappings for fpm."""
mappings = [
f"{BUILD_DIR}/=/opt/plezy/",
f"{SCRIPT_DIR}/com.edde746.plezy.desktop=/usr/share/applications/com.edde746.plezy.desktop",
f"{SCRIPT_DIR}/plezy.sh=/usr/bin/plezy",
]
for size in ICON_SIZES:
mappings.append(
f"{SCRIPT_DIR}/icons/{size}x{size}/plezy.png=/usr/share/icons/hicolor/{size}x{size}/apps/plezy.png"
)
return mappings
def build_package(distro: str, version: str):
"""Build a package for the specified distro."""
config = DISTROS[distro]
output_file = OUTPUT_DIR / f"{METADATA['name']}-linux.{config['ext']}"
print(f"Building .{config['ext']} package...")
cmd = [
"fpm",
"-s", "dir",
"-t", config["type"],
"-n", METADATA["name"],
"-v", version,
"--iteration", "1",
"--license", METADATA["license"],
"--vendor", METADATA["vendor"],
"--maintainer", METADATA["maintainer"],
"--url", METADATA["url"],
"--description", METADATA["description"],
"--architecture", config["arch"],
]
if config["category"]:
cmd.extend(["--category", config["category"]])
for dep in config["depends"]:
cmd.extend(["--depends", dep])
cmd.extend(config["compression"])
cmd.extend([
"--after-install", str(SCRIPT_DIR / "after-install.sh"),
"--after-remove", str(SCRIPT_DIR / "after-remove.sh"),
"--package", str(output_file),
])
cmd.extend(get_file_mappings())
subprocess.run(cmd, check=True)
print(f"Created: {output_file}")
def main():
# Verify build exists
if not BUILD_DIR.exists():
print(f"Error: Build directory not found at {BUILD_DIR}")
print("Please run 'flutter build linux --release' first")
exit(1)
version = get_version()
print(f"Building packages for {METADATA['name']} version {version}")
# Make scripts executable
for script in ["plezy.sh", "after-install.sh", "after-remove.sh"]:
(SCRIPT_DIR / script).chmod(0o755)
# Generate icons
generate_icons()
# Build all packages
for distro in DISTROS:
build_package(distro, version)
print("\nAll packages built successfully!")
for f in OUTPUT_DIR.glob(f"{METADATA['name']}-linux.*"):
print(f" {f}")
if __name__ == "__main__":
main()
+10
View File
@@ -0,0 +1,10 @@
[Desktop Entry]
Type=Application
Name=Plezy
Comment=A modern Plex client for desktop and mobile
Exec=/opt/plezy/plezy
Icon=plezy
Terminal=false
Categories=AudioVideo;Video;Player;
Keywords=plex;media;streaming;video;
StartupWMClass=plezy
+3
View File
@@ -0,0 +1,3 @@
#!/bin/bash
cd /opt/plezy
exec ./plezy "$@"