Skip to content

Commit 5de86e0

Browse files
janos-rEucladia
authored andcommitted
Generate a .deb file (helix-editor#12453)
1 parent db48b71 commit 5de86e0

File tree

6 files changed

+88
-18
lines changed

6 files changed

+88
-18
lines changed

.github/workflows/release.yml

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -147,16 +147,8 @@ jobs:
147147
if: "!matrix.skip_tests"
148148
run: ${{ env.CARGO }} test --release --locked --target ${{ matrix.target }} --workspace
149149

150-
- name: Set profile.release.strip = true
151-
shell: bash
152-
run: |
153-
cat >> .cargo/config.toml <<EOF
154-
[profile.release]
155-
strip = true
156-
EOF
157-
158150
- name: Build release binary
159-
run: ${{ env.CARGO }} build --release --locked --target ${{ matrix.target }}
151+
run: ${{ env.CARGO }} build --profile opt --locked --target ${{ matrix.target }}
160152

161153
- name: Build AppImage
162154
shell: bash
@@ -183,7 +175,7 @@ jobs:
183175
184176
mkdir -p "$APP.AppDir"/usr/{bin,lib/helix}
185177
186-
cp "target/${{ matrix.target }}/release/hx" "$APP.AppDir/usr/bin/hx"
178+
cp "target/${{ matrix.target }}/opt/hx" "$APP.AppDir/usr/bin/hx"
187179
rm -rf runtime/grammars/sources
188180
cp -r runtime "$APP.AppDir/usr/lib/helix/runtime"
189181
@@ -206,14 +198,25 @@ jobs:
206198
mv "$APP-$VERSION-$ARCH.AppImage" \
207199
"$APP-$VERSION-$ARCH.AppImage.zsync" dist
208200
201+
- name: Build Deb
202+
shell: bash
203+
if: matrix.build == 'x86_64-linux'
204+
run: |
205+
cargo install cargo-deb
206+
mkdir -p target/release
207+
cp target/${{ matrix.target }}/opt/hx target/release/
208+
cargo deb --no-build
209+
mkdir -p dist
210+
mv target/debian/*.deb dist/
211+
209212
- name: Build archive
210213
shell: bash
211214
run: |
212215
mkdir -p dist
213216
if [ "${{ matrix.os }}" = "windows-2019" ]; then
214-
cp "target/${{ matrix.target }}/release/hx.exe" "dist/"
217+
cp "target/${{ matrix.target }}/opt/hx.exe" "dist/"
215218
else
216-
cp "target/${{ matrix.target }}/release/hx" "dist/"
219+
cp "target/${{ matrix.target }}/opt/hx" "dist/"
217220
fi
218221
if [ -d runtime/grammars/sources ]; then
219222
rm -rf runtime/grammars/sources
@@ -241,6 +244,7 @@ jobs:
241244
set -ex
242245
243246
source="$(pwd)"
247+
tag=${GITHUB_REF_NAME//\//}
244248
mkdir -p runtime/grammars/sources
245249
tar xJf grammars/grammars.tar.xz -C runtime/grammars/sources
246250
rm -rf grammars
@@ -254,7 +258,7 @@ jobs:
254258
if [[ $platform =~ "windows" ]]; then
255259
exe=".exe"
256260
fi
257-
pkgname=helix-$GITHUB_REF_NAME-$platform
261+
pkgname=helix-$tag-$platform
258262
mkdir -p $pkgname
259263
cp $source/LICENSE $source/README.md $pkgname
260264
mkdir $pkgname/contrib
@@ -265,6 +269,7 @@ jobs:
265269
266270
if [[ "$platform" = "x86_64-linux" ]]; then
267271
mv bins-$platform/helix-*.AppImage* dist/
272+
mv bins-$platform/*.deb dist/
268273
fi
269274
270275
if [ "$exe" = "" ]; then
@@ -274,7 +279,7 @@ jobs:
274279
fi
275280
done
276281
277-
tar cJf dist/helix-$GITHUB_REF_NAME-source.tar.xz -C $source .
282+
tar cJf dist/helix-$tag-source.tar.xz -C $source .
278283
mv dist $source/
279284
280285
- name: Upload binaries to release

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,12 @@ default-members = [
2222

2323
[profile.release]
2424
lto = "thin"
25-
# debug = true
2625

2726
[profile.opt]
2827
inherits = "release"
2928
lto = "fat"
3029
codegen-units = 1
31-
# strip = "debuginfo" # TODO: or strip = true
30+
strip = true
3231
opt-level = 3
3332

3433
[profile.integration]

book/src/building-from-source.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- [Note to packagers](#note-to-packagers)
88
- [Validating the installation](#validating-the-installation)
99
- [Configure the desktop shortcut](#configure-the-desktop-shortcut)
10+
- [Building the Debian package](#building-the-debian-package)
1011

1112
Requirements:
1213

@@ -162,3 +163,39 @@ file. For example, to use `kitty`:
162163
sed -i "s|Exec=hx %F|Exec=kitty hx %F|g" ~/.local/share/applications/Helix.desktop
163164
sed -i "s|Terminal=true|Terminal=false|g" ~/.local/share/applications/Helix.desktop
164165
```
166+
167+
### Building the Debian package
168+
169+
If the `.deb` file provided on the release page uses a `libc` version higher
170+
than that used by your Debian, Ubuntu, or Mint system, you can build the package
171+
from source to match your system's dependencies.
172+
173+
Install `cargo-deb`, the tool used for building the `.deb` file:
174+
175+
```sh
176+
cargo install cargo-deb
177+
```
178+
179+
After cloning and entering the Helix repository as previously described,
180+
use the following command to build the release binary and package it into a `.deb` file in a single step.
181+
182+
```sh
183+
cargo deb -- --locked
184+
```
185+
186+
> 💡 This locks you into the `--release` profile. But you can also build helix in any way you like.
187+
> As long as you leave a `target/release/hx` file, it will get packaged with `cargo deb --no-build`
188+
189+
> 💡 Don't worry about the repeated
190+
> ```
191+
> warning: Failed to find dependency specification
192+
> ```
193+
> warnings. Cargo deb just reports which packaged files it didn't derive dependencies for. But
194+
> so far the dependency deriving seams very good, even if some of the grammar files are skipped.
195+
196+
You can find the resulted `.deb` in `target/debian/`. It should contain everything it needs, including the
197+
198+
- completions for bash, fish, zsh
199+
- .desktop file
200+
- icon (though desktop environments might use their own since the name of the package is correctly `helix`)
201+
- launcher to the binary with the runtime

book/src/package-managers.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
## Package managers
22

33
- [Linux](#linux)
4-
- [Ubuntu](#ubuntu)
4+
- [Ubuntu/Debian](#ubuntudebian)
5+
- [Ubuntu (PPA)](#ubuntu-ppa)
56
- [Fedora/RHEL](#fedorarhel)
67
- [Arch Linux extra](#arch-linux-extra)
78
- [NixOS](#nixos)
@@ -23,7 +24,14 @@
2324

2425
The following third party repositories are available:
2526

26-
### Ubuntu
27+
### Ubuntu/Debian
28+
29+
Install the Debian package from the release page.
30+
31+
If you are running a system older than Ubuntu 22.04, Mint 21, or Debian 12, you can build the `.deb` file locally
32+
[from source](./building-from-source.md#building-the-debian-package).
33+
34+
### Ubuntu (PPA)
2735

2836
Add the `PPA` for Helix:
2937

contrib/hx_launcher.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env sh
2+
3+
HELIX_RUNTIME=/usr/lib/helix/runtime exec /usr/lib/helix/hx "$@"

helix-term/Cargo.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,24 @@ categories.workspace = true
1212
repository.workspace = true
1313
homepage.workspace = true
1414

15+
[package.metadata.deb]
16+
# generate a .deb in target/debian/ with the command: cargo deb --no-build
17+
name = "helix"
18+
assets = [
19+
{ source = "target/release/hx", dest = "/usr/lib/helix/", mode = "755" },
20+
{ source = "../contrib/hx_launcher.sh", dest = "/usr/bin/hx", mode = "755" },
21+
{ source = "../runtime/*", dest = "/usr/lib/helix/runtime/", mode = "644" },
22+
{ source = "../runtime/grammars/*", dest = "/usr/lib/helix/runtime/grammars/", mode = "644" }, # to avoid sources/
23+
{ source = "../runtime/queries/**/*", dest = "/usr/lib/helix/runtime/queries/", mode = "644" },
24+
{ source = "../runtime/themes/**/*", dest = "/usr/lib/helix/runtime/themes/", mode = "644" },
25+
{ source = "../README.md", dest = "/usr/share/doc/helix/", mode = "644" },
26+
{ source = "../contrib/completion/hx.bash", dest = "/usr/share/bash-completion/completions/hx", mode = "644" },
27+
{ source = "../contrib/completion/hx.fish", dest = "/usr/share/fish/vendor_completions.d/hx.fish", mode = "644" },
28+
{ source = "../contrib/completion/hx.zsh", dest = "/usr/share/zsh/vendor-completions/_hx", mode = "644" },
29+
{ source = "../contrib/Helix.desktop", dest = "/usr/share/applications/Helix.desktop", mode = "644" },
30+
{ source = "../contrib/helix.png", dest = "/usr/share/icons/hicolor/256x256/apps/helix.png", mode = "644" },
31+
]
32+
1533
[features]
1634
default = ["git"]
1735
unicode-lines = ["helix-core/unicode-lines", "helix-view/unicode-lines"]

0 commit comments

Comments
 (0)