Skip to content

Commit 9450c5a

Browse files
committed
docs: add manual Linux .deb packaging guide
1 parent 7ee910d commit 9450c5a

1 file changed

Lines changed: 257 additions & 0 deletions

File tree

docs/distribution/manualfordeb.md

Lines changed: 257 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,257 @@
1+
# Packaging a Neutralino App as a `.deb` — Manual Guide
2+
3+
This guide walks you through every step that the automated packaging script performs, so you can do it entirely by hand.
4+
5+
---
6+
7+
## Prerequisites
8+
9+
Before you begin, make sure you have the following installed:
10+
11+
- [Neutralino CLI](https://neutralino.js.org/docs/cli/neu-cli) (`neu`)
12+
- `dpkg-deb` (comes with `dpkg` on Debian/Ubuntu)
13+
14+
Also ensure your project has:
15+
16+
- A `neutralino.config.json` with a `binaryName` field (e.g., `myapp`)
17+
- A **256×256 PNG** icon at `resources/icons/appIcon.png`
18+
19+
> Throughout this guide, replace `<binary-name>` with your actual binary name (e.g., `myapp`).
20+
21+
---
22+
23+
## Step 1 — Build the Neutralino App
24+
25+
Run the following command in your project root:
26+
27+
```bash
28+
neu build
29+
```
30+
31+
This compiles your app and places the output inside the `dist/` directory. After the build, you will find a folder at:
32+
33+
```
34+
dist/<binary-name>/
35+
```
36+
37+
Containing files like:
38+
39+
```
40+
<binary-name>-linux_x64
41+
<binary-name>-linux_arm64
42+
<binary-name>-linux_armhf
43+
<binary-name>-mac_x64
44+
<binary-name>-mac_arm64
45+
<binary-name>-mac_universal
46+
<binary-name>-win_x64.exe
47+
neutralinojs.log
48+
resources.neu
49+
```
50+
51+
For the `.deb` package, you will only need **`<binary-name>-linux_x64`** and **`resources.neu`**.
52+
53+
---
54+
55+
## Step 2 — Create the Package Directory Structure
56+
57+
Create a folder called `mypkg` (or any name you prefer) in your project root. Inside it, create the following directory tree exactly:
58+
59+
```
60+
mypkg
61+
├── DEBIAN
62+
│ └── control
63+
├── opt
64+
│ └── <binary-name>
65+
│ ├── <binary-name> ← the renamed Linux binary
66+
│ └── resources.neu
67+
└── usr
68+
├── bin
69+
│ └── <binary-name> ← the launcher shell script
70+
└── share
71+
├── applications
72+
│ └── <binary-name>.desktop
73+
└── icons
74+
└── hicolor
75+
└── 256x256
76+
└── apps
77+
└── <binary-name>.png
78+
```
79+
80+
You can create all the necessary folders at once with:
81+
82+
```bash
83+
mkdir -p mypkg/DEBIAN
84+
mkdir -p mypkg/opt/<binary-name>
85+
mkdir -p mypkg/usr/bin
86+
mkdir -p mypkg/usr/share/applications
87+
mkdir -p mypkg/usr/share/icons/hicolor/256x256/apps
88+
```
89+
90+
---
91+
92+
## Step 3 — Copy the App Binary and Resources
93+
94+
Copy the Linux x64 binary from the `dist` folder into the package, **renaming it** to just `<binary-name>`:
95+
96+
```bash
97+
cp dist/<binary-name>/<binary-name>-linux_x64 mypkg/opt/<binary-name>/<binary-name>
98+
```
99+
100+
Copy the `resources.neu` file alongside it:
101+
102+
```bash
103+
cp dist/<binary-name>/resources.neu mypkg/opt/<binary-name>/resources.neu
104+
```
105+
106+
Now set the correct permissions on both files:
107+
108+
```bash
109+
chmod 755 mypkg/opt/<binary-name>/<binary-name>
110+
chmod 644 mypkg/opt/<binary-name>/resources.neu
111+
```
112+
113+
---
114+
115+
## Step 4 — Create the Launcher Script
116+
117+
Create the file `mypkg/usr/bin/<binary-name>` with the following content:
118+
119+
```bash
120+
#!/bin/bash
121+
cd /opt/<binary-name>
122+
./<binary-name> "$@"
123+
```
124+
125+
This script ensures the app always runs from its own directory, which Neutralino requires for resolving `resources.neu`.
126+
127+
Make it executable:
128+
129+
```bash
130+
chmod 755 mypkg/usr/bin/<binary-name>
131+
```
132+
133+
---
134+
135+
## Step 5 — Add the App Icon
136+
137+
Copy your 256×256 PNG icon into the icons directory:
138+
139+
```bash
140+
cp resources/icons/appIcon.png mypkg/usr/share/icons/hicolor/256x256/apps/<binary-name>.png
141+
```
142+
143+
> The icon **must** be a 256×256 PNG. The filename must match your `<binary-name>` exactly, as the `.desktop` file references it by name.
144+
145+
---
146+
147+
## Step 6 — Create the Desktop Entry
148+
149+
Create the file `mypkg/usr/share/applications/<binary-name>.desktop` with the following content:
150+
151+
```ini
152+
[Desktop Entry]
153+
Name=My Awesome App
154+
Exec=/usr/bin/<binary-name>
155+
Icon=<binary-name>
156+
Type=Application
157+
Categories=Utility;
158+
Terminal=false
159+
Path=/opt/<binary-name>
160+
```
161+
162+
- **`Name`** — The display name shown in the application menu.
163+
- **`Exec`** — Points to the launcher script in `/usr/bin`.
164+
- **`Icon`** — The icon name (without extension). The system resolves it from the icons directory automatically.
165+
- **`Path`** — The working directory when the app is launched.
166+
167+
---
168+
169+
## Step 7 — Create the DEBIAN Control File
170+
171+
Create the file `mypkg/DEBIAN/control` with the following content:
172+
173+
```
174+
Package: <binary-name>
175+
Version: 1.0.0
176+
Section: base
177+
Priority: optional
178+
Architecture: amd64
179+
Depends: libwebkit2gtk-4.0-37 | libwebkit2gtk-4.1-0, libgtk-3-0
180+
Maintainer: Your Name <your.email@example.com>
181+
Description: Neutralino application.
182+
```
183+
184+
Set the correct permissions on the control file:
185+
186+
```bash
187+
chmod 644 mypkg/DEBIAN/control
188+
```
189+
190+
> **Architecture note:** This guide targets `amd64` (x86_64). If you are packaging for `arm64` or `armhf`, change the `Architecture` field and use the corresponding binary from the `dist` folder.
191+
192+
---
193+
194+
## Step 8 — Verify Your Structure
195+
196+
Before building, double-check that your `mypkg` folder looks exactly like this:
197+
198+
```
199+
mypkg
200+
├── DEBIAN
201+
│ └── control
202+
├── opt
203+
│ └── <binary-name>
204+
│ ├── <binary-name>
205+
│ └── resources.neu
206+
└── usr
207+
├── bin
208+
│ └── <binary-name>
209+
└── share
210+
├── applications
211+
│ └── <binary-name>.desktop
212+
└── icons
213+
└── hicolor
214+
└── 256x256
215+
└── apps
216+
└── <binary-name>.png
217+
```
218+
219+
---
220+
221+
## Step 9 — Build the `.deb` Package
222+
223+
Run the following command from your project root:
224+
225+
```bash
226+
dpkg-deb --build mypkg
227+
```
228+
229+
This will produce `mypkg.deb` in the current directory, ready for distribution.
230+
231+
---
232+
233+
## Installing and Testing
234+
235+
To install and test your package locally:
236+
237+
```bash
238+
sudo dpkg -i mypkg.deb
239+
```
240+
241+
To uninstall:
242+
243+
```bash
244+
sudo dpkg -r <binary-name>
245+
```
246+
247+
---
248+
249+
## Troubleshooting
250+
251+
| Problem | Likely Cause |
252+
|---|---|
253+
| App does not launch after install | Check that the launcher script at `/usr/bin/<binary-name>` is executable (`chmod 755`) |
254+
| `resources.neu` not found error | Confirm `Path=/opt/<binary-name>` is set in the `.desktop` file and the launcher `cd`s into the correct directory |
255+
| Icon not showing in app menu | Ensure the icon filename matches `<binary-name>.png` and is exactly 256×256 |
256+
| `dpkg-deb` permission errors | Ensure `DEBIAN/control` has `644` permissions and the binary has `755` permissions |
257+
| WebKit dependency error on install | Install the dependency manually: `sudo apt install libwebkit2gtk-4.1-0` |

0 commit comments

Comments
 (0)