-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathtest-flatpak-build.sh
More file actions
executable file
Β·178 lines (156 loc) Β· 5.56 KB
/
Copy pathtest-flatpak-build.sh
File metadata and controls
executable file
Β·178 lines (156 loc) Β· 5.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#!/bin/bash
# Test script to verify flatpak build configuration
# This script simulates the CI environment and tests the flatpak build process
set -e
echo "π Testing Flatpak Build Configuration"
echo "======================================"
echo ""
# Check prerequisites
echo "π Checking prerequisites..."
if ! command -v flatpak &> /dev/null; then
echo "β flatpak is not installed"
echo "Install with: sudo apt-get install -y flatpak flatpak-builder"
exit 1
fi
if ! command -v flatpak-builder &> /dev/null; then
echo "β flatpak-builder is not installed"
echo "Install with: sudo apt-get install -y flatpak-builder"
exit 1
fi
if ! command -v npm &> /dev/null; then
echo "β npm is not installed"
exit 1
fi
echo " β flatpak is installed"
echo " β flatpak-builder is installed"
echo " β npm is installed"
echo ""
# Verify we're in the electron directory
if [ ! -f "electron-builder.json" ]; then
echo "β Error: Must be run from the electron directory"
exit 1
fi
# Step 1: Add flathub remote (user)
echo "π¦ Step 1: Adding Flathub remote (user install)..."
if flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo; then
echo " β Flathub remote added"
else
echo " βΉ Flathub remote already exists"
fi
echo ""
# Step 2: Install required runtimes (user)
echo "π¦ Step 2: Installing Flatpak runtimes (user install)..."
echo " This may take a few minutes on first run..."
echo ""
echo " Installing org.freedesktop.Platform//24.08..."
if flatpak install --user -y flathub org.freedesktop.Platform//24.08 2>&1 | grep -v "already installed" || true; then
echo " β org.freedesktop.Platform//24.08 installed"
fi
echo " Installing org.freedesktop.Sdk//24.08..."
if flatpak install --user -y flathub org.freedesktop.Sdk//24.08 2>&1 | grep -v "already installed" || true; then
echo " β org.freedesktop.Sdk//24.08 installed"
fi
echo " Installing org.electronjs.Electron2.BaseApp//24.08..."
if flatpak install --user -y flathub org.electronjs.Electron2.BaseApp//24.08 2>&1 | grep -v "already installed" || true; then
echo " β org.electronjs.Electron2.BaseApp//24.08 installed"
fi
echo ""
# Step 3: Verify runtimes are installed
echo "π Step 3: Verifying installed runtimes..."
if flatpak list --user | grep -q "org.freedesktop.Platform"; then
echo " β org.freedesktop.Platform found"
else
echo " β org.freedesktop.Platform not found"
exit 1
fi
if flatpak list --user | grep -q "org.freedesktop.Sdk"; then
echo " β org.freedesktop.Sdk found"
else
echo " β org.freedesktop.Sdk not found"
exit 1
fi
if flatpak list --user | grep -q "org.electronjs.Electron2.BaseApp"; then
echo " β org.electronjs.Electron2.BaseApp found"
else
echo " β org.electronjs.Electron2.BaseApp not found"
exit 1
fi
echo ""
# Step 4: Validate flatpak configuration
echo "π Step 4: Validating Flatpak configuration..."
if [ -f "validate-flatpak.sh" ]; then
bash validate-flatpak.sh
else
echo " β validate-flatpak.sh not found, skipping"
fi
echo ""
# Step 5: Check if web build exists
echo "π Step 5: Checking for web build..."
if [ -d "../web/dist" ] && [ "$(ls -A ../web/dist)" ]; then
echo " β Web build exists"
WEB_BUILT=true
else
echo " β Web build not found"
echo " Note: Full electron build requires web to be built first"
echo " Run: cd ../web && npm install && npm run build"
WEB_BUILT=false
fi
echo ""
# Step 6: Install electron dependencies if not already done
echo "π¦ Step 6: Installing electron dependencies..."
if [ ! -d "node_modules" ]; then
echo " Installing npm packages..."
npm ci
else
echo " β Dependencies already installed"
fi
echo ""
# Step 7: Attempt to build (or dry-run)
echo "π¨ Step 7: Testing electron-builder configuration..."
if [ "$WEB_BUILT" = true ]; then
echo " Attempting full build with flatpak target..."
echo " This will take several minutes..."
echo ""
# Set DEBUG to see detailed output
export DEBUG=electron-builder,@malept/flatpak-bundler
export NODE_OPTIONS="--max_old_space_size=4096"
# Run electron-builder
if npx electron-builder --config electron-builder.json --linux --x64 --publish never; then
echo ""
echo " β
Build completed successfully!"
echo ""
echo " Generated files:"
ls -lh dist/*.{AppImage,flatpak} 2>/dev/null || echo " (no flatpak/AppImage files found)"
else
echo ""
echo " β Build failed"
echo " Check the output above for errors"
exit 1
fi
else
echo " β Skipping full build (web not built)"
echo " To test the full build:"
echo " 1. cd ../web && npm install && npm run build"
echo " 2. cd ../electron && bash test-flatpak-build.sh"
fi
echo ""
echo "β
Flatpak configuration test completed!"
echo ""
echo "Summary:"
echo " β’ Flatpak runtimes are installed correctly (user install)"
echo " β’ Configuration files are valid"
echo " β’ electron-builder configuration includes flatpak target"
echo ""
if [ "$WEB_BUILT" = true ]; then
echo " β’ Build test: PASSED"
echo ""
echo "The changes to release.yaml should fix the CI build:"
echo " 1. Runtimes installed in user space (not system)"
echo " 2. Debug logging enabled for @malept/flatpak-bundler"
else
echo " β’ Build test: SKIPPED (requires web build)"
echo ""
echo "To complete the test, build the web app first:"
echo " cd ../web && npm install && npm run build"
echo " cd ../electron && bash test-flatpak-build.sh"
fi