# Debian and Red Hat Package Building - Complete Summary ## Overview Your Jellyfin project can now build packages for both Debian and Red Hat-based distributions using a single publishing configuration. Both distributions use: - **Runtime**: `linux-x64` - **Configuration**: `Release` - **Self-contained**: `true` (includes .NET runtime) The publishing step is identical; only the packaging format differs (`.deb` vs `.rpm`). ## Documentation Structure ### πŸ“– Main Documentation **File**: [LINUX_PACKAGE_BUILD_GUIDE.md](LINUX_PACKAGE_BUILD_GUIDE.md) Complete reference covering: - Common publishing setup - Debian package building (FPM method and manual dpkg-deb method) - Red Hat package building (FPM method and native rpmbuild method) - Installation and verification procedures - Testing in Docker containers ### ⚑ Quick Reference **File**: [LINUX_PACKAGE_BUILD_QUICK_REFERENCE.md](LINUX_PACKAGE_BUILD_QUICK_REFERENCE.md) Quick commands for: - One-command builds - Prerequisites - Installation variations - Key directories and systemd commands - Troubleshooting table ### πŸ› οΈ Build Scripts **Location**: `scripts/` 1. **build-linux-packages.sh** - Main automated build script - Checks prerequisites - Publishes application - Creates both Debian and Red Hat packages - Colored output with progress indicators 2. **jellyfin.spec** - Red Hat SPEC file template - For native rpmbuild method - Contains hooks and metadata 3. **debian/** - Debian-specific files - postinst.sh - Post-install hook - prerm.sh - Pre-remove hook - postrm.sh - Post-remove hook - jellyfin.service - Systemd service file 4. **redhat/** - Red Hat-specific files - post.sh - Post-install hook - preun.sh - Pre-uninstall hook - postun.sh - Post-uninstall hook - jellyfin.service - Systemd service file 5. **scripts/README.md** - Build script documentation - Directory structure - Prerequisites and installation - Package specifications - Hooks and lifecycle - Customization options ## Quick Start ### Prerequisites (One-Time Setup) **Debian/Ubuntu:** ```bash sudo apt-get install ruby-dev sudo gem install fpm ``` **Red Hat/CentOS/Fedora:** ```bash sudo dnf install ruby-devel sudo gem install fpm ``` ### Build Both Packages ```bash cd /home/wjones/projects/pgsql-jellyfin chmod +x build-linux-packages.sh ./build-linux-packages.sh ``` Output: `build/packages/` - `jellyfin-11.0.0-amd64.deb` - `jellyfin-11.0.0-1.x86_64.rpm` ### Build Specific Distribution ```bash ./build-linux-packages.sh --deb-only # Debian only ./build-linux-packages.sh --rpm-only # Red Hat only ./build-linux-packages.sh --version 12.0.0 # Custom version ``` ### Install Package **Debian:** ```bash sudo dpkg -i build/packages/jellyfin-11.0.0-amd64.deb sudo apt-get install -f # Fix dependencies if needed sudo systemctl start jellyfin ``` **Red Hat:** ```bash sudo dnf install build/packages/jellyfin-11.0.0-1.x86_64.rpm sudo systemctl start jellyfin ``` ## Build Process Flow ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ User runs: ./build-linux-packages.sh β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β–Ό β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Check Prerequisites β”‚ β”‚ β€’ .NET SDK β”‚ β”‚ β€’ FPM (package manager) β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β–Ό β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Publish Application (linux-x64) β”‚ β”‚ β€’ Restore dependencies β”‚ β”‚ β€’ Build (Release config) β”‚ β”‚ β€’ Self-contained publish β”‚ β”‚ β†’ /tmp/jellyfin-publish-{pid} β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β–Ό β–Ό β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Build Debian β”‚ β”‚ Build Red Hatβ”‚ β”‚ Package β”‚ β”‚ Package β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ FPM: β”‚ β”‚ FPM: β”‚ β”‚ .deb format β”‚ β”‚ .rpm format β”‚ β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β–Ό β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Output to: build/packages/ β”‚ β”‚ β€’ jellyfin-VERSION-amd64.deb β”‚ β”‚ β€’ jellyfin-VERSION-1.x86_64.rpm β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` ## Key Features ### Package Metadata - **Version**: Automatically extracted from `SharedVersion.cs` - **Architecture**: x86_64 (64-bit) - **Dependencies**: - Debian: libssl3, libicu72, libfontconfig1 - Red Hat: openssl-libs, libicu, fontconfig ### Installation Hooks - **Post-install**: Creates user/group, sets permissions, enables service - **Pre-remove**: Stops service - **Post-remove**: Removes user/group ### Service File - **Type**: Simple systemd service - **Auto-restart**: On failure (5s delay) - **Resource limits**: 4GB max memory, 65k file descriptors - **Directories**: - Config: `/var/lib/jellyfin` - Logs: `/var/log/jellyfin` - Cache: `/var/cache/jellyfin` ### User Management - **Username**: `jellyfin` (system user, no shell) - **Home**: `/var/lib/jellyfin` - **Created automatically** during package installation - **Removed automatically** during package removal ## Testing ### Manual Testing ```bash # Extract and inspect package contents dpkg -c jellyfin-11.0.0-amd64.deb | head -20 rpm -qpl jellyfin-11.0.0-1.x86_64.rpm | head -20 # Verify hooks dpkg-deb -e jellyfin-11.0.0-amd64.deb /tmp/control rpm -qp --scripts jellyfin-11.0.0-1.x86_64.rpm ``` ### Docker Testing ```bash # Test on Debian docker run --rm -it -v $(pwd)/build/packages:/pkg debian:bookworm \ bash -c "dpkg -i /pkg/jellyfin-11.0.0-amd64.deb && systemctl status jellyfin" # Test on Fedora docker run --rm -it -v $(pwd)/build/packages:/pkg fedora:latest \ bash -c "dnf install -y /pkg/jellyfin-11.0.0-1.x86_64.rpm && systemctl status jellyfin" # Test on Rocky Linux docker run --rm -it -v $(pwd)/build/packages:/pkg rockylinux:9 \ bash -c "dnf install -y /pkg/jellyfin-11.0.0-1.x86_64.rpm && systemctl status jellyfin" ``` ## Troubleshooting ### FPM Installation Issues ```bash # Ensure Ruby development headers are installed sudo apt-get install ruby-dev # Debian/Ubuntu sudo dnf install ruby-devel # Red Hat # Then install FPM sudo gem install fpm ``` ### Build Script Permissions ```bash chmod +x build-linux-packages.sh chmod +x scripts/debian/postinst.sh scripts/debian/prerm.sh scripts/debian/postrm.sh chmod +x scripts/redhat/post.sh scripts/redhat/preun.sh scripts/redhat/postun.sh ``` ### Service Won't Start Check logs for errors: ```bash sudo journalctl -u jellyfin -n 50 sudo journalctl -u jellyfin -f # Follow logs ``` Check permissions: ```bash ls -la /opt/jellyfin ls -la /var/lib/jellyfin ``` ### Dependency Resolution **Debian**: If dpkg reports missing dependencies: ```bash sudo apt-get install -f ``` **Red Hat**: dnf resolves dependencies automatically ## No Red Hat System Required The documentation and scripts can be created and tested on any Linux system: - βœ… Debian/Ubuntu systems can create `.rpm` packages using FPM - βœ… Red Hat systems can create `.deb` packages using FPM - βœ… Cross-distribution testing via Docker - βœ… Single .NET publishing configuration works for both To actually run the packages on their respective distributions, you can: 1. Test locally using Docker containers 2. Deploy to VMs or servers running those distributions 3. Use CI/CD pipeline to test on actual systems ## File Manifest ``` /home/wjones/projects/pgsql-jellyfin/ β”œβ”€β”€ docs/ β”‚ β”œβ”€β”€ LINUX_PACKAGE_BUILD_GUIDE.md (Complete reference) β”‚ β”œβ”€β”€ LINUX_PACKAGE_BUILD_QUICK_REFERENCE.md (Quick commands) β”‚ └── PACKAGE_BUILDING_SUMMARY.md (This file) β”‚ β”œβ”€β”€ scripts/ β”‚ β”œβ”€β”€ README.md (Build scripts documentation) β”‚ β”œβ”€β”€ build-linux-packages.sh (Main build script) β”‚ β”œβ”€β”€ jellyfin.spec (Red Hat SPEC template) β”‚ β”œβ”€β”€ debian/ β”‚ β”‚ β”œβ”€β”€ postinst.sh β”‚ β”‚ β”œβ”€β”€ prerm.sh β”‚ β”‚ β”œβ”€β”€ postrm.sh β”‚ β”‚ └── jellyfin.service β”‚ └── redhat/ β”‚ β”œβ”€β”€ post.sh β”‚ β”œβ”€β”€ preun.sh β”‚ β”œβ”€β”€ postun.sh β”‚ └── jellyfin.service β”‚ └── build/ └── packages/ (Output location) β”œβ”€β”€ jellyfin-11.0.0-amd64.deb └── jellyfin-11.0.0-1.x86_64.rpm ``` ## Next Steps 1. βœ… **Read Documentation** - Start with [LINUX_PACKAGE_BUILD_QUICK_REFERENCE.md](LINUX_PACKAGE_BUILD_QUICK_REFERENCE.md) - Reference [LINUX_PACKAGE_BUILD_GUIDE.md](LINUX_PACKAGE_BUILD_GUIDE.md) for details 2. βœ… **Install Prerequisites** - `sudo apt-get install ruby-dev && sudo gem install fpm` (or Red Hat equivalent) 3. βœ… **Build Packages** - `./build-linux-packages.sh` 4. βœ… **Test Installation** - Test locally or in Docker containers - Verify service starts: `sudo systemctl status jellyfin` 5. βœ… **Deploy** - Copy `.deb` to Debian systems - Copy `.rpm` to Red Hat systems - Install and verify