Update plugin to Gramps 6.0 and add snap installation script
- Update MODULE_VERSION from 5.1 to 6.0 in MyTimeline.gpr.py - Add install_to_snap.sh script to copy plugin to snap-installed Gramps - Script includes automatic directory detection, backup functionality, and error handling
This commit is contained in:
parent
2874fe35d1
commit
b32be12aea
@ -22,7 +22,7 @@ from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
MODULE_VERSION = "5.1"
|
||||
MODULE_VERSION = "6.0"
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
#
|
||||
|
||||
146
install_to_snap.sh
Executable file
146
install_to_snap.sh
Executable file
@ -0,0 +1,146 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Script to install MyTimeline plugin to snap-installed Gramps
|
||||
#
|
||||
# This script copies the MyTimeline plugin files to the Gramps snap plugin directory
|
||||
# so it can be used in the snap-installed version of Gramps 6.0
|
||||
#
|
||||
|
||||
set -e # Exit on error
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Get the directory where this script is located
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# Source plugin files
|
||||
PLUGIN_SRC_DIR="$SCRIPT_DIR"
|
||||
PLUGIN_FILES=("MyTimeline.gpr.py" "MyTimeline.py")
|
||||
|
||||
# Target directory for snap-installed Gramps
|
||||
# Gramps 6.0 plugins directory in snap
|
||||
PLUGIN_DEST_DIR="$HOME/snap/gramps/current/.local/share/gramps/gramps60/plugins"
|
||||
|
||||
# Alternative locations to try (in case snap structure differs)
|
||||
ALTERNATIVE_DIRS=(
|
||||
"$HOME/snap/gramps/current/.local/share/gramps/gramps60/plugins"
|
||||
"$HOME/snap/gramps/current/.gramps/gramps60/plugins"
|
||||
"$HOME/snap/gramps/current/.gramps/plugins"
|
||||
"$HOME/snap/gramps/common/.local/share/gramps/gramps60/plugins"
|
||||
"$HOME/.local/share/gramps/gramps60/plugins"
|
||||
"$HOME/.gramps/gramps60/plugins"
|
||||
)
|
||||
|
||||
echo "=========================================="
|
||||
echo "MyTimeline Plugin Installer for Snap Gramps"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
|
||||
# Function to find the correct plugin directory
|
||||
find_plugin_dir() {
|
||||
# Try the primary location first
|
||||
if [ -d "$PLUGIN_DEST_DIR" ]; then
|
||||
echo "$PLUGIN_DEST_DIR"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Try alternative locations
|
||||
for dir in "${ALTERNATIVE_DIRS[@]}"; do
|
||||
if [ -d "$dir" ]; then
|
||||
echo "$dir"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
# If not found, ask user or create the primary location
|
||||
echo ""
|
||||
echo -e "${YELLOW}Warning: Plugin directory not found in standard locations.${NC}"
|
||||
echo "Attempting to create: $PLUGIN_DEST_DIR"
|
||||
mkdir -p "$PLUGIN_DEST_DIR"
|
||||
echo "$PLUGIN_DEST_DIR"
|
||||
return 0
|
||||
}
|
||||
|
||||
# Verify source files exist
|
||||
echo "Checking source files..."
|
||||
MISSING_FILES=()
|
||||
for file in "${PLUGIN_FILES[@]}"; do
|
||||
if [ ! -f "$PLUGIN_SRC_DIR/$file" ]; then
|
||||
MISSING_FILES+=("$file")
|
||||
else
|
||||
echo -e "${GREEN}✓${NC} Found: $file"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ${#MISSING_FILES[@]} -gt 0 ]; then
|
||||
echo ""
|
||||
echo -e "${RED}Error: Missing required plugin files:${NC}"
|
||||
for file in "${MISSING_FILES[@]}"; do
|
||||
echo " - $file"
|
||||
done
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Find the target directory
|
||||
echo ""
|
||||
echo "Locating Gramps plugin directory..."
|
||||
TARGET_DIR=$(find_plugin_dir)
|
||||
|
||||
if [ -z "$TARGET_DIR" ]; then
|
||||
echo -e "${RED}Error: Could not determine plugin directory location.${NC}"
|
||||
echo "Please check if Gramps is installed via snap."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}✓${NC} Target directory: $TARGET_DIR"
|
||||
echo ""
|
||||
|
||||
# Check if plugin already exists
|
||||
PLUGIN_EXISTS=false
|
||||
for file in "${PLUGIN_FILES[@]}"; do
|
||||
if [ -f "$TARGET_DIR/$file" ]; then
|
||||
PLUGIN_EXISTS=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Backup existing plugin if it exists
|
||||
if [ "$PLUGIN_EXISTS" = true ]; then
|
||||
echo -e "${YELLOW}Warning: Plugin files already exist in target directory.${NC}"
|
||||
BACKUP_DIR="$TARGET_DIR/mytimeline_backup_$(date +%Y%m%d_%H%M%S)"
|
||||
echo "Creating backup in: $BACKUP_DIR"
|
||||
mkdir -p "$BACKUP_DIR"
|
||||
for file in "${PLUGIN_FILES[@]}"; do
|
||||
if [ -f "$TARGET_DIR/$file" ]; then
|
||||
cp "$TARGET_DIR/$file" "$BACKUP_DIR/"
|
||||
fi
|
||||
done
|
||||
echo -e "${GREEN}✓${NC} Backup created"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# Copy plugin files
|
||||
echo "Installing plugin files..."
|
||||
for file in "${PLUGIN_FILES[@]}"; do
|
||||
cp "$PLUGIN_SRC_DIR/$file" "$TARGET_DIR/"
|
||||
echo -e "${GREEN}✓${NC} Installed: $file"
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo -e "${GREEN}Installation completed successfully!${NC}"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
echo "Plugin files installed to:"
|
||||
echo " $TARGET_DIR"
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo " 1. Restart Gramps if it's currently running"
|
||||
echo " 2. Go to Edit → Preferences → Plugins"
|
||||
echo " 3. Enable the 'MyTimeline' plugin"
|
||||
echo " 4. The plugin should appear in the Views menu under 'Families'"
|
||||
echo ""
|
||||
Loading…
x
Reference in New Issue
Block a user