Add SQL query patterns documentation and Linux package build scripts
- Created `TV_SHOWS_SQL_QUERY_PATTERNS.md` to document SQL query patterns for TV shows, including performance issues and missing indexes. - Added `README.md` for Linux package building, detailing steps for creating Debian and Red Hat packages. - Implemented build scripts for Debian and Red Hat, including service files and post-installation hooks. - Added necessary scripts for managing Jellyfin service lifecycle on both Debian and Red Hat systems. - Included package specifications and installation instructions for both distributions.
This commit is contained in:
@@ -0,0 +1,262 @@
|
||||
# Linux Package Building
|
||||
|
||||
This directory contains scripts and templates for building Jellyfin Linux packages for both Debian and Red Hat-based distributions.
|
||||
|
||||
## Quick Start
|
||||
|
||||
### Build Both Packages
|
||||
|
||||
```bash
|
||||
cd /home/wjones/projects/pgsql-jellyfin
|
||||
chmod +x build-linux-packages.sh
|
||||
./build-linux-packages.sh
|
||||
```
|
||||
|
||||
Packages will be created in `build/packages/`.
|
||||
|
||||
### Build Specific Distribution
|
||||
|
||||
```bash
|
||||
# Debian only
|
||||
./build-linux-packages.sh --deb-only
|
||||
|
||||
# Red Hat only
|
||||
./build-linux-packages.sh --rpm-only
|
||||
|
||||
# Specific version
|
||||
./build-linux-packages.sh --version 11.0.0
|
||||
```
|
||||
|
||||
## Directory Structure
|
||||
|
||||
```
|
||||
scripts/
|
||||
├── build-linux-packages.sh # Main automated build script
|
||||
├── jellyfin.spec # Red Hat SPEC file template
|
||||
├── debian/
|
||||
│ ├── postinst.sh # Post-install hook (Debian)
|
||||
│ ├── prerm.sh # Pre-remove hook (Debian)
|
||||
│ ├── postrm.sh # Post-remove hook (Debian)
|
||||
│ └── jellyfin.service # Systemd service file (Debian)
|
||||
└── redhat/
|
||||
├── post.sh # Post-install hook (Red Hat)
|
||||
├── preun.sh # Pre-uninstall hook (Red Hat)
|
||||
├── postun.sh # Post-uninstall hook (Red Hat)
|
||||
└── jellyfin.service # Systemd service file (Red Hat)
|
||||
```
|
||||
|
||||
## Prerequisites
|
||||
|
||||
### All Systems
|
||||
|
||||
- .NET SDK (for publishing the application)
|
||||
- `fpm` (Effing Package Manager) for cross-distribution building
|
||||
|
||||
### Install FPM
|
||||
|
||||
**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
|
||||
```
|
||||
|
||||
## Package Specifications
|
||||
|
||||
### Publishing Parameters
|
||||
|
||||
Both distributions use identical .NET publishing parameters:
|
||||
- **Runtime**: `linux-x64` (64-bit Linux)
|
||||
- **Configuration**: `Release` (optimized build)
|
||||
- **Self-contained**: `true` (includes .NET runtime)
|
||||
- **Output location**: `/opt/jellyfin` (standard FHS compliant)
|
||||
|
||||
### Package Details
|
||||
|
||||
| Component | Debian | Red Hat |
|
||||
|-----------|--------|---------|
|
||||
| Extension | `.deb` | `.rpm` |
|
||||
| Install command | `dpkg -i` / `apt install` | `dnf install` |
|
||||
| Application dir | `/opt/jellyfin` | `/opt/jellyfin` |
|
||||
| Config dir | `/etc/jellyfin` | `/etc/jellyfin` |
|
||||
| Data dir | `/var/lib/jellyfin` | `/var/lib/jellyfin` |
|
||||
| Log dir | `/var/log/jellyfin` | `/var/log/jellyfin` |
|
||||
| Service file | `/etc/systemd/system/` | `/etc/systemd/system/` |
|
||||
| User | `jellyfin` (system user) | `jellyfin` (system user) |
|
||||
|
||||
## Installation
|
||||
|
||||
### Debian
|
||||
|
||||
```bash
|
||||
# Install package
|
||||
sudo dpkg -i jellyfin-11.0.0-amd64.deb
|
||||
sudo apt-get install -f # Fix dependencies if needed
|
||||
|
||||
# Start service
|
||||
sudo systemctl start jellyfin
|
||||
sudo systemctl status jellyfin
|
||||
|
||||
# View logs
|
||||
sudo journalctl -u jellyfin -f
|
||||
```
|
||||
|
||||
### Red Hat
|
||||
|
||||
```bash
|
||||
# Install package
|
||||
sudo dnf install jellyfin-11.0.0-1.x86_64.rpm
|
||||
|
||||
# Start service
|
||||
sudo systemctl start jellyfin
|
||||
sudo systemctl status jellyfin
|
||||
|
||||
# View logs
|
||||
sudo journalctl -u jellyfin -f
|
||||
```
|
||||
|
||||
## Verification
|
||||
|
||||
### Inspect Package Contents
|
||||
|
||||
**Debian:**
|
||||
```bash
|
||||
dpkg -c jellyfin-11.0.0-amd64.deb
|
||||
```
|
||||
|
||||
**Red Hat:**
|
||||
```bash
|
||||
rpm -qpl jellyfin-11.0.0-1.x86_64.rpm
|
||||
```
|
||||
|
||||
### Test Install/Remove Cycle
|
||||
|
||||
```bash
|
||||
# Install
|
||||
sudo dpkg -i jellyfin-11.0.0-amd64.deb # or dnf install for Red Hat
|
||||
|
||||
# Verify
|
||||
sudo systemctl status jellyfin
|
||||
|
||||
# Remove
|
||||
sudo dpkg -r jellyfin # or dnf remove for Red Hat
|
||||
```
|
||||
|
||||
## Build Details
|
||||
|
||||
### What the Build Script Does
|
||||
|
||||
1. **Checks prerequisites** - Ensures .NET SDK and fpm are available
|
||||
2. **Restores dependencies** - `dotnet restore Jellyfin.sln -r linux-x64`
|
||||
3. **Builds solution** - `dotnet build Jellyfin.sln --configuration Release`
|
||||
4. **Publishes application** - Creates self-contained linux-x64 binary
|
||||
5. **Generates Debian package** - Creates `.deb` with hooks and metadata
|
||||
6. **Generates Red Hat package** - Creates `.rpm` with hooks and metadata
|
||||
7. **Reports completion** - Displays package paths and sizes
|
||||
|
||||
### Build Artifacts
|
||||
|
||||
Output location: `<project-root>/build/packages/`
|
||||
|
||||
- `jellyfin-11.0.0-amd64.deb` - Debian package
|
||||
- `jellyfin-11.0.0-1.x86_64.rpm` - Red Hat package
|
||||
|
||||
## Hooks and Lifecycle
|
||||
|
||||
Both packages include installation and removal hooks:
|
||||
|
||||
### Installation
|
||||
- Creates `jellyfin` system user if not exists
|
||||
- Creates required directories (lib, log, cache)
|
||||
- Sets proper ownership and permissions
|
||||
- Enables and optionally starts systemd service
|
||||
|
||||
### Removal
|
||||
- Stops systemd service
|
||||
- Disables service from auto-start
|
||||
- Removes `jellyfin` user and group
|
||||
|
||||
## Service Configuration
|
||||
|
||||
The included `jellyfin.service` file provides:
|
||||
|
||||
- **Auto-restart** on failure (5s delay)
|
||||
- **Resource limits** (4GB max memory, 65k file descriptors)
|
||||
- **Proper logging** (journald integration)
|
||||
- **Directory configuration**:
|
||||
- `--datadir=/var/lib/jellyfin` (configuration and metadata)
|
||||
- `--logdir=/var/log/jellyfin` (application logs)
|
||||
- `--cachedir=/var/cache/jellyfin` (temporary cache)
|
||||
|
||||
## Customization
|
||||
|
||||
### Change Version
|
||||
|
||||
Edit `SharedVersion.cs` or use build script flag:
|
||||
|
||||
```bash
|
||||
./build-linux-packages.sh --version 12.0.0
|
||||
```
|
||||
|
||||
### Modify Dependencies
|
||||
|
||||
Edit install scripts or update FPM dependencies in `build-linux-packages.sh`:
|
||||
|
||||
```bash
|
||||
--depends "libssl3" \
|
||||
--depends "libicu72" \
|
||||
```
|
||||
|
||||
### Add Custom Hooks
|
||||
|
||||
Edit the respective hook scripts in `debian/` or `redhat/` directories.
|
||||
|
||||
## Documentation
|
||||
|
||||
For detailed information about the build process, see:
|
||||
- [LINUX_PACKAGE_BUILD_GUIDE.md](../docs/LINUX_PACKAGE_BUILD_GUIDE.md) - Complete guide with examples
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### FPM not found
|
||||
|
||||
```bash
|
||||
# Debian/Ubuntu
|
||||
sudo apt-get install ruby-dev && sudo gem install fpm
|
||||
|
||||
# Red Hat/CentOS
|
||||
sudo dnf install ruby-devel && sudo gem install fpm
|
||||
```
|
||||
|
||||
### Missing dependencies during install
|
||||
|
||||
For Debian, run:
|
||||
```bash
|
||||
sudo apt-get install -f
|
||||
```
|
||||
|
||||
For Red Hat, the package manager will automatically resolve.
|
||||
|
||||
### Permission denied when running script
|
||||
|
||||
```bash
|
||||
chmod +x build-linux-packages.sh
|
||||
```
|
||||
|
||||
### Check build details
|
||||
|
||||
Edit `build-linux-packages.sh` and remove `> /dev/null 2>&1` to see verbose output.
|
||||
|
||||
## Related Files
|
||||
|
||||
- **Build Script**: `build-linux-packages.sh`
|
||||
- **SPEC Template**: `scripts/jellyfin.spec`
|
||||
- **Debian Hooks**: `scripts/debian/{postinst,prerm,postrm}.sh`
|
||||
- **Red Hat Hooks**: `scripts/redhat/{post,preun,postun}.sh`
|
||||
- **Service Files**: Both distributions in `scripts/{debian,redhat}/jellyfin.service`
|
||||
- **Complete Guide**: `docs/LINUX_PACKAGE_BUILD_GUIDE.md`
|
||||
Reference in New Issue
Block a user