Skip to content

Commit 1519838

Browse files
committed
refinements and following packaging best practices
1 parent af4c59b commit 1519838

File tree

6 files changed

+60
-15
lines changed

6 files changed

+60
-15
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,8 @@ install-cargo-deb:
355355
## Build .deb package using cargo-deb with reproducible settings
356356
deb-cargo: install-cargo-deb build-reproducible
357357
@echo "Building .deb package with cargo-deb..."
358-
@if [ ! -f "lighthouse/lighthouse.service" ]; then \
359-
echo "❌ lighthouse.service not found in lighthouse/ directory"; \
358+
@if [ ! -f "lighthouse/debian/lighthouse.service" ]; then \
359+
echo "❌ lighthouse.service not found in lighthouse/debian/ directory"; \
360360
exit 1; \
361361
fi
362362
@if [ ! -f "README.md" ]; then \

lighthouse/Cargo.toml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,31 +95,24 @@ name = "lighthouse_tests"
9595
path = "tests/main.rs"
9696

9797
[package.metadata.deb]
98-
# Package metadata
9998
maintainer = "Sigma Prime <[email protected]>"
10099
extended-description = """\
101100
Lighthouse is a Rust implementation of the Ethereum beacon chain, \
102101
built by Sigma Prime. It implements the official Ethereum 2.0 specification."""
103102

104-
# Dependencies
105103
depends = "$auto, systemd"
106104
section = "net"
107105
priority = "optional"
106+
maintainer-scripts = "debian/" # This tells cargo-deb where to find scripts
108107

109108
# System integration
110109
systemd-units = { enable = false, start = false }
111110

112111
# Assets to include in the package
113112
assets = [
114-
# Binary - use target/release/ prefix (cargo-deb will replace with actual path)
115113
["target/release/lighthouse", "usr/bin/", "755"],
116-
117-
# Systemd service (in lighthouse directory)
118-
["lighthouse.service", "lib/systemd/system/", "644"],
119-
120-
# Documentation (in parent directory)
114+
["debian/lighthouse.service", "lib/systemd/system/", "644"],
121115
["../README.md", "usr/share/doc/lighthouse/", "644"],
122116
]
123117

124-
# Use default features - let Makefile handle the building
125118
default-features = false

lighthouse/lighthouse.service renamed to lighthouse/debian/lighthouse.service

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
[Unit]
2-
Description=Lighthouse Ethereum Beacon Chain Client
3-
Documentation=https://lighthouse-book.sigmaprime.io/
2+
Description=Lighthouse Ethereum Beacon Node
43
After=network.target
54
Wants=network.target
65

76
[Service]
87
Type=simple
9-
DynamicUser=true
108
User=lighthouse
11-
Group=eth
9+
Group=lighthouse
1210
Restart=always
1311
RestartSec=5
1412
TimeoutStopSec=180

lighthouse/debian/postinst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh
2+
set -e
3+
4+
# Create lighthouse user if it doesn't exist
5+
if ! getent passwd lighthouse >/dev/null 2>&1; then
6+
adduser --system --group --home /var/lib/lighthouse \
7+
--shell /bin/false --gecos "Lighthouse Beacon Node" lighthouse
8+
fi
9+
10+
# Create data directory
11+
mkdir -p /var/lib/lighthouse
12+
chown lighthouse:lighthouse /var/lib/lighthouse
13+
chmod 750 /var/lib/lighthouse
14+
15+
# Create log directory
16+
mkdir -p /var/log/lighthouse
17+
chown lighthouse:lighthouse /var/log/lighthouse
18+
chmod 750 /var/log/lighthouse
19+
20+
# Reload systemd
21+
systemctl daemon-reload || true
22+
23+
#DEBHELPER#
24+
25+
exit 0

lighthouse/debian/postrm

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh
2+
set -e
3+
4+
if [ "$1" = "purge" ]; then
5+
# Remove user (optional - some prefer to keep it)
6+
if getent passwd lighthouse >/dev/null 2>&1; then
7+
deluser lighthouse || true
8+
fi
9+
10+
# Remove data directory (be careful!)
11+
# rm -rf /var/lib/lighthouse || true
12+
# rm -rf /var/log/lighthouse || true
13+
fi
14+
15+
#DEBHELPER#
16+
17+
exit 0

lighthouse/debian/prerm

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
set -e
3+
4+
if [ "$1" = "remove" ]; then
5+
# Stop service if running
6+
systemctl stop lighthouse || true
7+
systemctl disable lighthouse || true
8+
fi
9+
10+
#DEBHELPER#
11+
12+
exit 0

0 commit comments

Comments
 (0)