unify build, fix opening files when app is running
This commit is contained in:
301
packaging/README.md
Normal file
301
packaging/README.md
Normal file
@@ -0,0 +1,301 @@
|
||||
# Packaging Guide
|
||||
|
||||
This directory contains packaging files and installation scripts for RLogg on different platforms.
|
||||
|
||||
## Directory Structure
|
||||
|
||||
```
|
||||
packaging/
|
||||
├── linux/
|
||||
│ ├── rlogg.desktop # XDG desktop entry file
|
||||
│ ├── text-x-log.xml # MIME type definition for .log files
|
||||
│ └── install.sh # Linux installation script
|
||||
├── windows/
|
||||
│ ├── file-association.reg # Windows registry file for manual setup
|
||||
│ └── install.ps1 # PowerShell installation script
|
||||
└── README.md # This file
|
||||
```
|
||||
|
||||
## Building for Distribution
|
||||
|
||||
### Linux
|
||||
|
||||
1. **Build the release binary:**
|
||||
```bash
|
||||
cargo build --release
|
||||
```
|
||||
|
||||
2. **Test the installation script:**
|
||||
```bash
|
||||
cd packaging/linux
|
||||
./install.sh
|
||||
```
|
||||
|
||||
3. **Create a distribution package:**
|
||||
```bash
|
||||
# Create a tarball
|
||||
cd target/release
|
||||
tar -czf rlogg-linux-x64.tar.gz rlogg ../../packaging/linux/*
|
||||
```
|
||||
|
||||
### Windows
|
||||
|
||||
1. **Build the release binary:**
|
||||
```powershell
|
||||
cargo build --release
|
||||
```
|
||||
|
||||
2. **Test the installation script:**
|
||||
```powershell
|
||||
cd packaging\windows
|
||||
powershell -ExecutionPolicy Bypass -File install.ps1
|
||||
```
|
||||
|
||||
3. **Create a distribution package:**
|
||||
```powershell
|
||||
# Create a ZIP file
|
||||
Compress-Archive -Path target\release\rlogg.exe, packaging\windows\* -DestinationPath rlogg-windows-x64.zip
|
||||
```
|
||||
|
||||
## Distribution Packages
|
||||
|
||||
### Linux Packages
|
||||
|
||||
#### DEB Package (Debian/Ubuntu)
|
||||
|
||||
Create a `debian/` directory structure for building `.deb` packages:
|
||||
|
||||
```bash
|
||||
mkdir -p debian/usr/local/bin
|
||||
mkdir -p debian/usr/share/applications
|
||||
mkdir -p debian/usr/share/mime/packages
|
||||
|
||||
cp target/release/rlogg debian/usr/local/bin/
|
||||
cp packaging/linux/rlogg.desktop debian/usr/share/applications/
|
||||
cp packaging/linux/text-x-log.xml debian/usr/share/mime/packages/
|
||||
|
||||
# Create DEBIAN control file
|
||||
mkdir -p debian/DEBIAN
|
||||
cat > debian/DEBIAN/control <<EOF
|
||||
Package: rlogg
|
||||
Version: 0.3.1
|
||||
Section: utils
|
||||
Priority: optional
|
||||
Architecture: amd64
|
||||
Maintainer: Your Name <your.email@example.com>
|
||||
Description: Fast log file viewer
|
||||
A fast log file viewer with search, filtering, and highlighting capabilities
|
||||
EOF
|
||||
|
||||
# Build the package
|
||||
dpkg-deb --build debian rlogg_0.3.1_amd64.deb
|
||||
```
|
||||
|
||||
#### AppImage
|
||||
|
||||
For universal Linux distribution:
|
||||
|
||||
```bash
|
||||
# Install linuxdeploy
|
||||
wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
|
||||
chmod +x linuxdeploy-x86_64.AppImage
|
||||
|
||||
# Create AppDir structure
|
||||
mkdir -p AppDir/usr/bin
|
||||
mkdir -p AppDir/usr/share/applications
|
||||
mkdir -p AppDir/usr/share/mime/packages
|
||||
|
||||
cp target/release/rlogg AppDir/usr/bin/
|
||||
cp packaging/linux/rlogg.desktop AppDir/usr/share/applications/
|
||||
cp packaging/linux/text-x-log.xml AppDir/usr/share/mime/packages/
|
||||
|
||||
# Build AppImage
|
||||
./linuxdeploy-x86_64.AppImage --appdir AppDir --output appimage
|
||||
```
|
||||
|
||||
### Windows Packages
|
||||
|
||||
#### NSIS Installer
|
||||
|
||||
Install NSIS and create an installer script:
|
||||
|
||||
```nsis
|
||||
!define APPNAME "RLogg"
|
||||
!define COMPANYNAME "Your Company"
|
||||
!define DESCRIPTION "Fast log file viewer"
|
||||
!define VERSIONMAJOR 0
|
||||
!define VERSIONMINOR 3
|
||||
!define VERSIONBUILD 1
|
||||
|
||||
RequestExecutionLevel user
|
||||
|
||||
Name "${APPNAME}"
|
||||
Icon "path\to\icon.ico"
|
||||
OutFile "rlogg-setup.exe"
|
||||
InstallDir "$LOCALAPPDATA\Programs\${APPNAME}"
|
||||
|
||||
Section "Install"
|
||||
SetOutPath $INSTDIR
|
||||
File "target\release\rlogg.exe"
|
||||
|
||||
WriteUninstaller "$INSTDIR\Uninstall.exe"
|
||||
|
||||
# Create file association
|
||||
WriteRegStr HKCU "Software\Classes\.log" "" "RLogg.LogFile"
|
||||
WriteRegStr HKCU "Software\Classes\RLogg.LogFile\shell\open\command" "" '"$INSTDIR\rlogg.exe" "%1"'
|
||||
SectionEnd
|
||||
|
||||
Section "Uninstall"
|
||||
Delete "$INSTDIR\rlogg.exe"
|
||||
Delete "$INSTDIR\Uninstall.exe"
|
||||
RMDir "$INSTDIR"
|
||||
|
||||
DeleteRegKey HKCU "Software\Classes\.log"
|
||||
DeleteRegKey HKCU "Software\Classes\RLogg.LogFile"
|
||||
SectionEnd
|
||||
```
|
||||
|
||||
## Testing File Associations
|
||||
|
||||
### Linux Testing
|
||||
|
||||
1. **Create a test log file:**
|
||||
```bash
|
||||
echo "Test log entry" > /tmp/test.log
|
||||
```
|
||||
|
||||
2. **Test command-line opening:**
|
||||
```bash
|
||||
rlogg /tmp/test.log
|
||||
```
|
||||
|
||||
3. **Test XDG opening:**
|
||||
```bash
|
||||
xdg-open /tmp/test.log
|
||||
```
|
||||
|
||||
4. **Test in file manager:**
|
||||
- Navigate to `/tmp/` in your file manager
|
||||
- Double-click `test.log`
|
||||
- Right-click → Open With → RLogg
|
||||
|
||||
5. **Test multiple files:**
|
||||
```bash
|
||||
echo "Log 1" > /tmp/test1.log
|
||||
echo "Log 2" > /tmp/test2.log
|
||||
rlogg /tmp/test1.log /tmp/test2.log
|
||||
```
|
||||
|
||||
### Windows Testing
|
||||
|
||||
1. **Create a test log file:**
|
||||
```powershell
|
||||
"Test log entry" | Out-File -FilePath "$env:TEMP\test.log"
|
||||
```
|
||||
|
||||
2. **Test command-line opening:**
|
||||
```powershell
|
||||
& "$env:LOCALAPPDATA\Programs\RLogg\rlogg.exe" "$env:TEMP\test.log"
|
||||
```
|
||||
|
||||
3. **Test in File Explorer:**
|
||||
- Open File Explorer
|
||||
- Navigate to `%TEMP%`
|
||||
- Double-click `test.log`
|
||||
- Right-click → Open with → RLogg
|
||||
|
||||
4. **Test multiple files:**
|
||||
```powershell
|
||||
"Log 1" | Out-File -FilePath "$env:TEMP\test1.log"
|
||||
"Log 2" | Out-File -FilePath "$env:TEMP\test2.log"
|
||||
& "$env:LOCALAPPDATA\Programs\RLogg\rlogg.exe" "$env:TEMP\test1.log" "$env:TEMP\test2.log"
|
||||
```
|
||||
|
||||
## Platform-Specific Notes
|
||||
|
||||
### Linux
|
||||
|
||||
- **Desktop environments tested:**
|
||||
- GNOME 40+
|
||||
- KDE Plasma 5.20+
|
||||
- XFCE 4.16+
|
||||
- i3/sway (via xdg-utils)
|
||||
|
||||
- **Dependencies:**
|
||||
- `xdg-utils` for `update-desktop-database` and `update-mime-database`
|
||||
- Usually pre-installed on most distributions
|
||||
|
||||
- **Wayland compatibility:**
|
||||
- Tested and working on Wayland sessions
|
||||
- File associations work the same as X11
|
||||
|
||||
### Windows
|
||||
|
||||
- **Tested on:**
|
||||
- Windows 10 (version 1909+)
|
||||
- Windows 11
|
||||
|
||||
- **Registry location:**
|
||||
- User-local: `HKEY_CURRENT_USER\Software\Classes\`
|
||||
- No admin rights required
|
||||
|
||||
- **Antivirus:**
|
||||
- Some antivirus software may flag unsigned executables
|
||||
- Consider code signing for production releases
|
||||
|
||||
## CI/CD Integration
|
||||
|
||||
### GitHub Actions Example
|
||||
|
||||
```yaml
|
||||
name: Build and Package
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
build-linux:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Build
|
||||
run: cargo build --release
|
||||
- name: Package
|
||||
run: |
|
||||
cd target/release
|
||||
tar -czf rlogg-linux-x64.tar.gz rlogg ../../packaging/linux/*
|
||||
- name: Upload
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: rlogg-linux
|
||||
path: target/release/rlogg-linux-x64.tar.gz
|
||||
|
||||
build-windows:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Build
|
||||
run: cargo build --release
|
||||
- name: Package
|
||||
run: |
|
||||
Compress-Archive -Path target\release\rlogg.exe, packaging\windows\* -DestinationPath rlogg-windows-x64.zip
|
||||
- name: Upload
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: rlogg-windows
|
||||
path: rlogg-windows-x64.zip
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
See [docs/FILE_ASSOCIATIONS.md](../docs/FILE_ASSOCIATIONS.md) for detailed troubleshooting guides.
|
||||
|
||||
## Contributing
|
||||
|
||||
When adding new packaging formats or improving existing ones:
|
||||
|
||||
1. Test on the target platform
|
||||
2. Update this README with clear instructions
|
||||
3. Add troubleshooting steps if needed
|
||||
4. Submit a pull request with test results
|
||||
78
packaging/linux/install.sh
Executable file
78
packaging/linux/install.sh
Executable file
@@ -0,0 +1,78 @@
|
||||
#!/bin/bash
|
||||
# Install rlogg and create file association for .log files
|
||||
# This script installs to user-local directories (~/.local/) and does not require sudo
|
||||
|
||||
set -e
|
||||
|
||||
echo "Installing RLogg Log Viewer..."
|
||||
echo ""
|
||||
|
||||
# Determine the directory where this script is located
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
# Check if rlogg binary exists
|
||||
if [ ! -f "$SCRIPT_DIR/../../target/release/rlogg" ]; then
|
||||
echo "Error: rlogg binary not found at $SCRIPT_DIR/../../target/release/rlogg"
|
||||
echo "Please build the project first with: cargo build --release"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# User-local installation (no sudo required)
|
||||
echo "Installing binary to ~/.local/bin/..."
|
||||
mkdir -p ~/.local/bin
|
||||
cp "$SCRIPT_DIR/../../target/release/rlogg" ~/.local/bin/
|
||||
chmod +x ~/.local/bin/rlogg
|
||||
|
||||
# Install desktop file with correct path
|
||||
echo "Installing desktop file..."
|
||||
mkdir -p ~/.local/share/applications
|
||||
|
||||
# Create desktop file with absolute path to the binary
|
||||
cat > ~/.local/share/applications/rlogg.desktop <<EOF
|
||||
[Desktop Entry]
|
||||
Version=1.0
|
||||
Type=Application
|
||||
Name=RLogg
|
||||
GenericName=Log Viewer
|
||||
Comment=Fast log file viewer with search, filtering, and highlighting
|
||||
Exec=$HOME/.local/bin/rlogg %F
|
||||
Icon=rlogg
|
||||
Terminal=false
|
||||
Categories=Development;Utility;
|
||||
MimeType=text/x-log;
|
||||
Keywords=log;viewer;search;filter;
|
||||
EOF
|
||||
|
||||
# Update MIME database
|
||||
echo "Installing MIME type definition..."
|
||||
mkdir -p ~/.local/share/mime/packages
|
||||
cp "$SCRIPT_DIR/text-x-log.xml" ~/.local/share/mime/packages/
|
||||
|
||||
# Update desktop and MIME databases
|
||||
echo "Updating databases..."
|
||||
if command -v update-desktop-database &> /dev/null; then
|
||||
update-desktop-database ~/.local/share/applications 2>/dev/null || true
|
||||
fi
|
||||
|
||||
if command -v update-mime-database &> /dev/null; then
|
||||
update-mime-database ~/.local/share/mime 2>/dev/null || true
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Installation complete!"
|
||||
echo ""
|
||||
echo "RLogg has been installed to: ~/.local/bin/rlogg"
|
||||
echo ""
|
||||
echo "IMPORTANT: Make sure ~/.local/bin is in your PATH."
|
||||
echo "Add this line to your ~/.bashrc or ~/.zshrc if it's not already there:"
|
||||
echo ' export PATH="$HOME/.local/bin:$PATH"'
|
||||
echo ""
|
||||
echo "File associations have been configured for .log files."
|
||||
echo "You may need to log out and log back in for file associations to take effect."
|
||||
echo ""
|
||||
echo "To uninstall, run:"
|
||||
echo " rm ~/.local/bin/rlogg"
|
||||
echo " rm ~/.local/share/applications/rlogg.desktop"
|
||||
echo " rm ~/.local/share/mime/packages/text-x-log.xml"
|
||||
echo " update-desktop-database ~/.local/share/applications"
|
||||
echo " update-mime-database ~/.local/share/mime"
|
||||
14
packaging/linux/rlogg.desktop
Normal file
14
packaging/linux/rlogg.desktop
Normal file
@@ -0,0 +1,14 @@
|
||||
[Desktop Entry]
|
||||
Version=1.0
|
||||
Type=Application
|
||||
Name=RLogg
|
||||
GenericName=Log Viewer
|
||||
Comment=Fast log file viewer with search, filtering, and highlighting
|
||||
# NOTE: Use absolute path for Exec to work in GUI file managers
|
||||
# The install.sh script will automatically set this to $HOME/.local/bin/rlogg
|
||||
Exec=/usr/local/bin/rlogg %F
|
||||
Icon=rlogg
|
||||
Terminal=false
|
||||
Categories=Development;Utility;
|
||||
MimeType=text/x-log;
|
||||
Keywords=log;viewer;search;filter;
|
||||
7
packaging/linux/text-x-log.xml
Normal file
7
packaging/linux/text-x-log.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
|
||||
<mime-type type="text/x-log">
|
||||
<comment>Log file</comment>
|
||||
<glob pattern="*.log"/>
|
||||
</mime-type>
|
||||
</mime-info>
|
||||
19
packaging/windows/file-association.reg
Normal file
19
packaging/windows/file-association.reg
Normal file
@@ -0,0 +1,19 @@
|
||||
Windows Registry Editor Version 5.00
|
||||
|
||||
; Associate .log files with RLogg
|
||||
; Edit the path below if you installed RLogg to a different location
|
||||
|
||||
[HKEY_CURRENT_USER\Software\Classes\.log]
|
||||
@="RLogg.LogFile"
|
||||
|
||||
[HKEY_CURRENT_USER\Software\Classes\RLogg.LogFile]
|
||||
@="Log File"
|
||||
|
||||
[HKEY_CURRENT_USER\Software\Classes\RLogg.LogFile\DefaultIcon]
|
||||
@="\"C:\\Program Files\\RLogg\\rlogg.exe\",0"
|
||||
|
||||
[HKEY_CURRENT_USER\Software\Classes\RLogg.LogFile\shell\open\command]
|
||||
@="\"C:\\Program Files\\RLogg\\rlogg.exe\" \"%1\""
|
||||
|
||||
[HKEY_CURRENT_USER\Software\Classes\RLogg.LogFile\shell\open]
|
||||
@="Open with RLogg"
|
||||
63
packaging/windows/install.ps1
Normal file
63
packaging/windows/install.ps1
Normal file
@@ -0,0 +1,63 @@
|
||||
# RLogg Installation Script for Windows
|
||||
# Run with: powershell -ExecutionPolicy Bypass -File install.ps1
|
||||
|
||||
param(
|
||||
[string]$InstallPath = "$env:LOCALAPPDATA\Programs\RLogg"
|
||||
)
|
||||
|
||||
Write-Host "Installing RLogg Log Viewer..." -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
# Determine the directory where this script is located
|
||||
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$BinaryPath = Join-Path (Split-Path (Split-Path $ScriptDir -Parent) -Parent) "target\release\rlogg.exe"
|
||||
|
||||
# Check if rlogg.exe exists
|
||||
if (-not (Test-Path $BinaryPath)) {
|
||||
Write-Host "Error: rlogg.exe not found at $BinaryPath" -ForegroundColor Red
|
||||
Write-Host "Please build the project first with: cargo build --release" -ForegroundColor Yellow
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Create directory
|
||||
Write-Host "Installing binary to $InstallPath..." -ForegroundColor Green
|
||||
New-Item -ItemType Directory -Force -Path $InstallPath | Out-Null
|
||||
|
||||
# Copy binary
|
||||
Copy-Item $BinaryPath $InstallPath\
|
||||
|
||||
# Create registry entries for .log file association
|
||||
Write-Host "Configuring file associations..." -ForegroundColor Green
|
||||
|
||||
$regPath = "HKCU:\Software\Classes\.log"
|
||||
New-Item -Path $regPath -Force | Out-Null
|
||||
Set-ItemProperty -Path $regPath -Name "(default)" -Value "RLogg.LogFile"
|
||||
|
||||
$regPath = "HKCU:\Software\Classes\RLogg.LogFile"
|
||||
New-Item -Path $regPath -Force | Out-Null
|
||||
Set-ItemProperty -Path $regPath -Name "(default)" -Value "Log File"
|
||||
|
||||
$regPath = "HKCU:\Software\Classes\RLogg.LogFile\DefaultIcon"
|
||||
New-Item -Path $regPath -Force | Out-Null
|
||||
Set-ItemProperty -Path $regPath -Name "(default)" -Value "`"$InstallPath\rlogg.exe`",0"
|
||||
|
||||
$regPath = "HKCU:\Software\Classes\RLogg.LogFile\shell\open\command"
|
||||
New-Item -Path $regPath -Force | Out-Null
|
||||
Set-ItemProperty -Path $regPath -Name "(default)" -Value "`"$InstallPath\rlogg.exe`" `"%1`""
|
||||
|
||||
$regPath = "HKCU:\Software\Classes\RLogg.LogFile\shell\open"
|
||||
New-Item -Path $regPath -Force | Out-Null
|
||||
Set-ItemProperty -Path $regPath -Name "(default)" -Value "Open with RLogg"
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Installation complete!" -ForegroundColor Green
|
||||
Write-Host ""
|
||||
Write-Host "RLogg is installed at: $InstallPath\rlogg.exe" -ForegroundColor Cyan
|
||||
Write-Host "File associations have been configured for .log files." -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
Write-Host "You can now double-click .log files to open them in RLogg." -ForegroundColor Yellow
|
||||
Write-Host ""
|
||||
Write-Host "To uninstall, run:" -ForegroundColor Yellow
|
||||
Write-Host " Remove-Item -Recurse `"$InstallPath`"" -ForegroundColor Gray
|
||||
Write-Host " Remove-Item -Recurse HKCU:\Software\Classes\.log" -ForegroundColor Gray
|
||||
Write-Host " Remove-Item -Recurse HKCU:\Software\Classes\RLogg.LogFile" -ForegroundColor Gray
|
||||
Reference in New Issue
Block a user