Skip to content

Commit f0e7c1d

Browse files
committed
fix(packaging): resolve RPM installation and module import issues
- Fix Python module import by adding PYTHONPATH to launcher script - Make icon installation robust with fallback placeholder SVG - Ensure desktop file is properly installed from src/resources/desktop/ - Add error handling to launcher for better debugging The RPM package now works correctly when installed, allowing the application to launch from both command line and desktop icon via DEBUG option. Fixes issues with: - ModuleNotFoundError when running 'sql-schema-studio' - Missing icon and desktop files during RPM build
1 parent 1d4d31f commit f0e7c1d

1 file changed

Lines changed: 37 additions & 2 deletions

File tree

scripts/packaging/build_rpm.sh

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,20 +124,38 @@ Features:
124124
mkdir -p %{buildroot}/usr/lib/python3/dist-packages/src
125125
cp -r src/* %{buildroot}/usr/lib/python3/dist-packages/src/
126126
127+
# Ensure __init__.py exists if it doesn't
128+
if [ ! -f "%{buildroot}/usr/lib/python3/dist-packages/src/__init__.py" ]; then
129+
touch %{buildroot}/usr/lib/python3/dist-packages/src/__init__.py
130+
fi
131+
127132
# Remove __pycache__
128133
find %{buildroot} -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null || true
129134
130135
# Install icon
131136
mkdir -p %{buildroot}/usr/share/icons/hicolor/scalable/apps/
132137
if [ -f "src/resources/ui/icons/logo.svg" ]; then
133138
cp src/resources/ui/icons/logo.svg %{buildroot}/usr/share/icons/hicolor/scalable/apps/sql-schema-studio.svg
139+
elif [ -f "src/resources/ui/icons/sql-schema-studio.svg" ]; then
140+
cp src/resources/ui/icons/sql-schema-studio.svg %{buildroot}/usr/share/icons/hicolor/scalable/apps/sql-schema-studio.svg
141+
else
142+
# Create a simple placeholder icon if no icon exists
143+
cat > %{buildroot}/usr/share/icons/hicolor/scalable/apps/sql-schema-studio.svg << 'SVG_EOF'
144+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100" height="100">
145+
<rect width="100" height="100" rx="20" fill="#2d3748"/>
146+
<text x="50" y="55" font-family="Arial" font-size="40" font-weight="bold" fill="#48bb78" text-anchor="middle">SQL</text>
147+
<text x="50" y="75" font-family="Arial" font-size="12" fill="#a0aec0" text-anchor="middle">Schema Studio</text>
148+
</svg>
149+
SVG_EOF
150+
echo "WARNING: No icon found, using placeholder"
134151
fi
135152
136153
# Install desktop file
137154
mkdir -p %{buildroot}/usr/share/applications/
138155
if [ -f "src/resources/desktop/sql-schema-studio.desktop" ]; then
139156
cp src/resources/desktop/sql-schema-studio.desktop %{buildroot}/usr/share/applications/
140157
else
158+
# Fallback desktop file
141159
cat > %{buildroot}/usr/share/applications/sql-schema-studio.desktop << 'DESKTOP_EOF'
142160
[Desktop Entry]
143161
Name=SQL Schema Studio
@@ -149,14 +167,31 @@ Type=Application
149167
Categories=Development;Database;IDE;
150168
StartupWMClass=SQL Schema Studio
151169
MimeType=text/x-sql;
170+
Keywords=postgresql;database;sql;schema;designer;analytics;
152171
DESKTOP_EOF
153172
fi
154173
155174
# Create launcher script
156175
mkdir -p %{buildroot}/usr/bin
157176
cat > %{buildroot}/usr/bin/sql-schema-studio << 'LAUNCHER_EOF'
158-
#!/bin/bash
159-
exec python3 -m src.main "$@"
177+
#!/usr/bin/env python3
178+
import sys
179+
import os
180+
181+
# Add the dist-packages directory to sys.path
182+
dist_packages = '/usr/lib/python3/dist-packages'
183+
if os.path.exists(dist_packages):
184+
sys.path.insert(0, dist_packages)
185+
186+
# Try to import and run main
187+
try:
188+
from src.main import main
189+
sys.exit(main())
190+
except ImportError as e:
191+
print(f"Error: Could not import SQL Schema Studio module", file=sys.stderr)
192+
print(f"Details: {e}", file=sys.stderr)
193+
print(f"Python path: {sys.path}", file=sys.stderr)
194+
sys.exit(1)
160195
LAUNCHER_EOF
161196
chmod 755 %{buildroot}/usr/bin/sql-schema-studio
162197

0 commit comments

Comments
 (0)