Archived
Replace SLF4J with BarnLogger and update documentation
- Replace SLF4J/logback with custom BarnLogger across all source files - BarnLogger is disabled by default for CLI commands, enabled for service - Fixes #30: debug logs no longer break JSON/XML CLI output - Add SpotBugs exclusions for BarnLogger false positives - Update docs: remove .deb and AUR references (no longer applicable) - Update docs: add Windows setup.exe installation instructions - Update docs: clarify auto-update only works with Homebrew Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
41126eeed4
commit
d95ac32739
44 files changed
+466
-1227
No files matched your search
+69
-386
@@ -1,137 +1,100 @@
|
||||
# Auto-Update
|
||||
# Updating Barn
|
||||
|
||||
This document describes Barn's built-in self-update mechanism.
|
||||
This document describes how to keep Barn updated on different platforms.
|
||||
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
Barn includes a `barn update` command that can check for and install new versions directly from GitHub Releases without requiring a package manager.
|
||||
| Platform | Update Method | Automatic |
|
||||
|----------|---------------|-----------|
|
||||
| macOS (Homebrew) | `brew upgrade barn` | Yes |
|
||||
| macOS (manual) | Download from GitHub Releases | No |
|
||||
| Windows | Download setup installer from GitHub Releases | No |
|
||||
| Linux | Download binary from GitHub Releases | No |
|
||||
|
||||
---
|
||||
|
||||
## Commands
|
||||
## macOS (Homebrew)
|
||||
|
||||
### Check for Updates
|
||||
If you installed Barn via Homebrew, updates are handled automatically:
|
||||
|
||||
```bash
|
||||
barn update --check
|
||||
# Check for updates
|
||||
brew outdated barn
|
||||
|
||||
# Update Barn
|
||||
brew upgrade barn
|
||||
|
||||
# Restart the service after updating
|
||||
brew services restart barn
|
||||
```
|
||||
|
||||
Output:
|
||||
Homebrew will automatically fetch the latest version from the Homebrew tap when you run `brew upgrade`.
|
||||
|
||||
```
|
||||
Current version: 1.2.3
|
||||
Latest version: 1.3.0
|
||||
Update available: yes
|
||||
---
|
||||
|
||||
Run 'barn update' to install the latest version.
|
||||
```
|
||||
## macOS (Manual Installation)
|
||||
|
||||
### Install Latest Version
|
||||
If you installed Barn manually (not via Homebrew):
|
||||
|
||||
```bash
|
||||
barn update
|
||||
```
|
||||
1. Download the latest binary from [GitHub Releases](https://github.com/samson-media/barn/releases/latest)
|
||||
2. Stop the service: `barn service stop`
|
||||
3. Replace the binary:
|
||||
```bash
|
||||
chmod +x barn-macos-arm64
|
||||
sudo mv barn-macos-arm64 /usr/local/bin/barn
|
||||
```
|
||||
4. Verify: `barn --version`
|
||||
5. Start the service: `barn service start`
|
||||
|
||||
Output:
|
||||
---
|
||||
|
||||
```
|
||||
Current version: 1.2.3
|
||||
Latest version: 1.3.0
|
||||
## Windows
|
||||
|
||||
Downloading barn-macos-arm64...
|
||||
Verifying checksum...
|
||||
Installing...
|
||||
Restarting service...
|
||||
To update Barn on Windows:
|
||||
|
||||
Successfully updated to version 1.3.0
|
||||
```
|
||||
1. Download the latest `setup-barn-vX.X.X-windows-x64.exe` from [GitHub Releases](https://github.com/samson-media/barn/releases/latest)
|
||||
2. Run the installer - it will automatically:
|
||||
- Stop the Barn service
|
||||
- Update the binary
|
||||
- Restart the service
|
||||
|
||||
### Install Specific Version
|
||||
Alternatively, for silent updates:
|
||||
|
||||
```bash
|
||||
barn update --version=1.2.0
|
||||
```
|
||||
```powershell
|
||||
# Download the installer
|
||||
Invoke-WebRequest -Uri "https://github.com/samson-media/barn/releases/latest/download/setup-barn-vX.X.X-windows-x64.exe" -OutFile "setup-barn.exe"
|
||||
|
||||
### Force Update (Reinstall Current Version)
|
||||
|
||||
```bash
|
||||
barn update --force
|
||||
```
|
||||
|
||||
### JSON Output
|
||||
|
||||
```bash
|
||||
barn update --check --output=json
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"current_version": "1.2.3",
|
||||
"latest_version": "1.3.0",
|
||||
"update_available": true,
|
||||
"release_url": "https://github.com/samson-media/barn/releases/tag/v1.3.0"
|
||||
}
|
||||
# Run silent installation
|
||||
.\setup-barn.exe /S
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Update Flow
|
||||
## Linux
|
||||
|
||||
### 1. Query GitHub Releases API
|
||||
To update Barn on Linux:
|
||||
|
||||
Barn queries the GitHub Releases API to find the latest version:
|
||||
1. Download the latest binary from [GitHub Releases](https://github.com/samson-media/barn/releases/latest)
|
||||
2. Stop the service:
|
||||
```bash
|
||||
sudo systemctl stop barn
|
||||
```
|
||||
3. Replace the binary:
|
||||
```bash
|
||||
chmod +x barn-linux-x64
|
||||
sudo mv barn-linux-x64 /usr/local/bin/barn
|
||||
```
|
||||
4. Verify: `barn --version`
|
||||
5. Start the service:
|
||||
```bash
|
||||
sudo systemctl start barn
|
||||
```
|
||||
|
||||
```
|
||||
GET https://api.github.com/repos/samson-media/barn/releases/latest
|
||||
```
|
||||
---
|
||||
|
||||
Response includes:
|
||||
- Version tag
|
||||
- Asset download URLs
|
||||
- Checksums
|
||||
|
||||
### 2. Compare Versions
|
||||
|
||||
Versions are compared using semantic versioning:
|
||||
|
||||
```
|
||||
1.3.0 > 1.2.3 → Update available
|
||||
1.2.3 = 1.2.3 → Up to date
|
||||
1.2.0 < 1.2.3 → Downgrade (requires --force)
|
||||
```
|
||||
|
||||
### 3. Download Binary
|
||||
|
||||
The appropriate binary is downloaded based on OS and architecture:
|
||||
|
||||
| OS | Architecture | Asset |
|
||||
|----|--------------|-------|
|
||||
| Linux | x86_64 | `barn-linux-x64` |
|
||||
| Linux | ARM64 | `barn-linux-arm64` |
|
||||
| macOS | x86_64 | `barn-macos-x64` |
|
||||
| macOS | ARM64 | `barn-macos-arm64` |
|
||||
| Windows | x86_64 | `barn-windows-x64.exe` |
|
||||
|
||||
### 4. Verify Checksum
|
||||
|
||||
The SHA256 checksum is verified against `SHA256SUMS`:
|
||||
|
||||
```bash
|
||||
# Downloaded automatically and verified
|
||||
sha256sum -c SHA256SUMS
|
||||
```
|
||||
|
||||
If verification fails, the update is aborted.
|
||||
|
||||
### 5. Replace Binary
|
||||
|
||||
The old binary is replaced with the new one.
|
||||
|
||||
### 6. Verify Installation
|
||||
|
||||
After replacement, Barn verifies the new binary works:
|
||||
## Checking Your Current Version
|
||||
|
||||
```bash
|
||||
barn --version
|
||||
@@ -139,296 +102,16 @@ barn --version
|
||||
|
||||
---
|
||||
|
||||
## Platform-Specific Behavior
|
||||
## Release Notifications
|
||||
|
||||
### Windows
|
||||
To be notified of new releases, watch the [GitHub repository](https://github.com/samson-media/barn):
|
||||
|
||||
Windows cannot replace a running executable. The update process:
|
||||
|
||||
1. Download new binary to temp location
|
||||
2. Stop the Barn service
|
||||
3. Rename current `barn.exe` to `barn.exe.old`
|
||||
4. Move new binary to `barn.exe`
|
||||
5. Start the Barn service
|
||||
6. Delete `barn.exe.old` on next run
|
||||
|
||||
```
|
||||
C:\Program Files\Barn\
|
||||
barn.exe ← New version
|
||||
barn.exe.old ← Previous version (deleted on next run)
|
||||
```
|
||||
|
||||
### Linux / macOS
|
||||
|
||||
Direct replacement if permissions allow:
|
||||
|
||||
```bash
|
||||
# Requires write permission to binary location
|
||||
sudo barn update
|
||||
```
|
||||
|
||||
If running without sudo and binary is in a protected location:
|
||||
|
||||
```
|
||||
Error: Cannot update binary at /usr/local/bin/barn
|
||||
Permission denied. Run with sudo or use your package manager.
|
||||
```
|
||||
|
||||
### Package Manager Installations
|
||||
|
||||
If Barn detects it was installed via a package manager, it warns the user:
|
||||
|
||||
```
|
||||
Warning: Barn appears to be installed via Homebrew.
|
||||
Using 'barn update' may conflict with your package manager.
|
||||
|
||||
Recommended: Run 'brew upgrade barn' instead.
|
||||
|
||||
Continue anyway? [y/N]
|
||||
```
|
||||
|
||||
Detection methods:
|
||||
|
||||
| Package Manager | Detection |
|
||||
|-----------------|-----------|
|
||||
| Homebrew | Binary in `/opt/homebrew/` or `/usr/local/Cellar/` |
|
||||
| apt/dpkg | Binary in `/usr/bin/` with dpkg ownership |
|
||||
| pacman | Binary in `/usr/bin/` with pacman ownership |
|
||||
| WinGet | Registry entries present |
|
||||
|
||||
---
|
||||
|
||||
## Security
|
||||
|
||||
### HTTPS Only
|
||||
|
||||
All downloads use HTTPS. HTTP is never used.
|
||||
|
||||
### Checksum Verification
|
||||
|
||||
Every download is verified against the published SHA256 checksum:
|
||||
|
||||
```
|
||||
SHA256SUMS content:
|
||||
a1b2c3d4... barn-linux-x64
|
||||
e5f6g7h8... barn-linux-arm64
|
||||
...
|
||||
```
|
||||
|
||||
If the checksum doesn't match, the update fails:
|
||||
|
||||
```
|
||||
Error: Checksum verification failed
|
||||
Expected: a1b2c3d4...
|
||||
Got: xxxxxxxx...
|
||||
|
||||
The download may be corrupted or tampered with.
|
||||
Update aborted.
|
||||
```
|
||||
|
||||
### Signature Verification (Optional)
|
||||
|
||||
If GPG signatures are published, Barn can verify them:
|
||||
|
||||
```bash
|
||||
barn update --verify-signature
|
||||
```
|
||||
|
||||
This requires the Samson Media public key to be imported.
|
||||
|
||||
---
|
||||
|
||||
## Configuration
|
||||
|
||||
Update behavior can be configured in `barn.conf`:
|
||||
|
||||
```toml
|
||||
[update]
|
||||
# Disable update checks
|
||||
enabled = true
|
||||
|
||||
# Check for updates automatically on service start
|
||||
check_on_start = true
|
||||
|
||||
# Notify about updates without auto-installing
|
||||
auto_install = false
|
||||
|
||||
# GitHub API endpoint (for enterprise GitHub)
|
||||
github_api = "https://api.github.com"
|
||||
|
||||
# Proxy settings
|
||||
proxy = ""
|
||||
```
|
||||
|
||||
### Environment Variables
|
||||
|
||||
```bash
|
||||
# Disable update functionality
|
||||
BARN_UPDATE_ENABLED=false
|
||||
|
||||
# Use proxy for downloads
|
||||
BARN_UPDATE_PROXY=http://proxy.example.com:8080
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Rollback
|
||||
|
||||
Barn keeps the previous version as a backup.
|
||||
|
||||
### Automatic Backup
|
||||
|
||||
During update, the previous binary is preserved:
|
||||
|
||||
| Platform | Backup Location |
|
||||
|----------|-----------------|
|
||||
| Linux/macOS | `/usr/local/bin/barn.backup` or alongside binary |
|
||||
| Windows | `barn.exe.backup` |
|
||||
|
||||
### Manual Rollback
|
||||
|
||||
```bash
|
||||
barn update --rollback
|
||||
```
|
||||
|
||||
Or manually:
|
||||
|
||||
```bash
|
||||
# Linux/macOS
|
||||
sudo mv /usr/local/bin/barn.backup /usr/local/bin/barn
|
||||
|
||||
# Windows
|
||||
move "C:\Program Files\Barn\barn.exe.backup" "C:\Program Files\Barn\barn.exe"
|
||||
```
|
||||
|
||||
### Rollback Retention
|
||||
|
||||
Only the most recent previous version is kept. Older backups are deleted.
|
||||
|
||||
---
|
||||
|
||||
## Offline Mode
|
||||
|
||||
If network is unavailable:
|
||||
|
||||
```bash
|
||||
barn update --check
|
||||
```
|
||||
|
||||
```
|
||||
Error: Cannot reach GitHub API
|
||||
Check your network connection or proxy settings.
|
||||
|
||||
For offline installation, download the binary manually from:
|
||||
https://github.com/samson-media/barn/releases
|
||||
```
|
||||
|
||||
### Manual Offline Update
|
||||
|
||||
1. Download binary on another machine
|
||||
2. Transfer to target machine
|
||||
3. Replace binary manually:
|
||||
|
||||
```bash
|
||||
chmod +x barn-linux-x64
|
||||
sudo mv barn-linux-x64 /usr/local/bin/barn
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Update Notifications
|
||||
|
||||
When `check_on_start = true`, Barn checks for updates when the service starts and logs:
|
||||
|
||||
```
|
||||
[INFO] Update available: 1.3.0 (current: 1.2.3)
|
||||
[INFO] Run 'barn update' to install
|
||||
```
|
||||
|
||||
This check is non-blocking and doesn't affect service startup.
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Update Check Fails
|
||||
|
||||
```
|
||||
Error: Failed to check for updates
|
||||
GitHub API rate limit exceeded.
|
||||
```
|
||||
|
||||
Solution: Wait an hour or authenticate with a GitHub token:
|
||||
|
||||
```bash
|
||||
GITHUB_TOKEN=xxx barn update --check
|
||||
```
|
||||
|
||||
### Permission Denied
|
||||
|
||||
```
|
||||
Error: Cannot write to /usr/local/bin/barn
|
||||
```
|
||||
|
||||
Solution: Run with elevated privileges:
|
||||
|
||||
```bash
|
||||
sudo barn update
|
||||
```
|
||||
|
||||
### Binary Corrupted After Update
|
||||
|
||||
```
|
||||
Error: barn: cannot execute binary file
|
||||
```
|
||||
|
||||
Solution: Roll back and report the issue:
|
||||
|
||||
```bash
|
||||
sudo mv /usr/local/bin/barn.backup /usr/local/bin/barn
|
||||
barn --version # Verify rollback worked
|
||||
```
|
||||
|
||||
### Service Won't Start After Update
|
||||
|
||||
1. Check logs: `barn service logs`
|
||||
2. Roll back: `barn update --rollback`
|
||||
3. Start service: `barn service start`
|
||||
|
||||
---
|
||||
|
||||
## Implementation Details
|
||||
|
||||
### Version Detection
|
||||
|
||||
Barn determines its own version at compile time:
|
||||
|
||||
```kotlin
|
||||
object Version {
|
||||
const val CURRENT = "1.2.3" // Injected at build
|
||||
val commit = System.getenv("BARN_COMMIT") ?: "unknown"
|
||||
}
|
||||
```
|
||||
|
||||
### API Endpoint
|
||||
|
||||
```
|
||||
GET https://api.github.com/repos/samson-media/barn/releases/latest
|
||||
Accept: application/vnd.github.v3+json
|
||||
```
|
||||
|
||||
### Download with Progress
|
||||
|
||||
Downloads show progress for large binaries:
|
||||
|
||||
```
|
||||
Downloading barn-linux-x64...
|
||||
[████████████████████░░░░░░░░░░] 67% (12.3 MB / 18.4 MB)
|
||||
```
|
||||
1. Go to https://github.com/samson-media/barn
|
||||
2. Click "Watch" → "Custom" → Select "Releases"
|
||||
|
||||
---
|
||||
|
||||
## Next Steps
|
||||
|
||||
- [Releasing](releasing.md) - How versions are published
|
||||
- [Distribution](distribution.md) - Package manager alternatives
|
||||
- [Distribution](distribution.md) - Installation methods by platform
|
||||
Reference in new issue
Block a user