Skip to content

Commit 9f75240

Browse files
committed
0.3.1 version
Signed-off-by: roots666 <m0980701299@gmail.com>
1 parent 281897f commit 9f75240

13 files changed

Lines changed: 227 additions & 13 deletions

File tree

.github/workflows/release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ jobs:
7070
name: Test arm64 (native runner)
7171
runs-on: ubuntu-24.04-arm
7272
timeout-minutes: 15
73+
# Run on all PRs, pushes to main, and tags to ensure ARM64 compatibility
74+
# This validates the full epoll/signalfd path (not QEMU fallback)
7375
steps:
7476
- name: Checkout
7577
uses: actions/checkout@v4

CHANGELOG.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,32 @@
1+
<!-- markdownlint-disable MD024 -->
12
# Changelog
23

4+
## 0.3.1 - 2026-01-11
5+
6+
### Fixed
7+
8+
- Fix `debian/control` Architecture field: changed from `any` to `amd64 arm64` to prevent FTBFS on unsupported architectures.
9+
- Add explicit `make` to Build-Depends for reproducible builds across all environments.
10+
11+
### Improved
12+
13+
- Implement VERSION single source of truth: version now controlled by `VERSION` file at repository root.
14+
- Auto-generate arch-specific version include files (`include/version_amd64.inc`, `include/version_arm64.inc`) during build.
15+
- Version string length now calculated dynamically (no hardcoded lengths).
16+
- Version bumps now require changing only 1 file instead of 4 separate locations.
17+
18+
### Tests/Docs
19+
20+
- Add restart-on-crash test to `debian/tests/smoke`: validates `EP_RESTART_ENABLED` and `EP_MAX_RESTARTS` functionality.
21+
- Add PGID signal fan-out test to `debian/tests/smoke`: verifies signals reach both child and grandchild processes.
22+
- Autopkgtest now validates 5 critical behaviors (was 3).
23+
- Document that `EP_ARM64_FALLBACK` mode is NOT suitable for production (CI testing stub only).
24+
- List features NOT available in fallback mode: signal forwarding, graceful shutdown, restart, custom EP_SIGNALS.
25+
- Add restart configuration best practices: guidance on backoff delays and restart limits to prevent tight CPU loops.
26+
- Add Debian packaging guide section with build instructions, autopkgtest usage, lintian checks, and supported architectures.
27+
- Update man page date and version metadata to match VERSION file.
28+
- Document that ARM64 native tests run on every PR (validates full epoll/signalfd path).
29+
330
## 0.3.0 - 2026-01-06
431

532
- Real-time signals: `EP_SIGNALS=RT*` now requires explicit `EP_SIGRTMIN`/`EP_SIGRTMAX` (avoids hardcoded SIGRTMIN/SIGRTMAX assumptions).

Makefile

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# Build configuration
2+
VERSION := $(shell cat VERSION 2>/dev/null || echo "unknown")
3+
24
BUILD_DIR ?= build
35
INC_DIR := include
46

@@ -17,14 +19,25 @@ LDFLAGS := -nostdlib -z noexecstack -z relro -z now --build-id=sha1
1719

1820
ARM64_AS ?= $(shell command -v aarch64-linux-gnu-as 2>/dev/null || echo as)
1921
ARM64_LD ?= $(shell command -v aarch64-linux-gnu-ld 2>/dev/null || echo ld)
20-
ARM64_ASFLAGS ?=
22+
ARM64_ASFLAGS ?= -I$(INC_DIR)
2123
ARM64_LDFLAGS ?= -nostdlib -z noexecstack -z relro -z now --build-id=sha1
2224

2325
ifeq ($(DEBUG),1)
2426
NASMFLAGS += -g -F dwarf
2527
ARM64_ASFLAGS += -g
2628
endif
2729

30+
# Generate version include files for both architectures
31+
$(INC_DIR)/version_amd64.inc: VERSION
32+
@echo '; Auto-generated version file' > $@
33+
@echo 'version_msg_str: db "mini-init-amd64 $(VERSION)", 10, 0' >> $@
34+
@echo 'version_msg_len_val: equ $$ - version_msg_str - 1' >> $@
35+
36+
$(INC_DIR)/version_arm64.inc: VERSION
37+
@echo '// Auto-generated version file' > $@
38+
@echo 'version_msg_arm64: .asciz "mini-init-arm64 $(VERSION)\n"' >> $@
39+
@echo '.equ version_msg_arm64_len, . - version_msg_arm64 - 1' >> $@
40+
2841
AMD64_BUILD_DIR := $(BUILD_DIR)/amd64
2942
ARM64_BUILD_DIR := $(BUILD_DIR)/arm64
3043

@@ -70,11 +83,11 @@ $(AMD64_BUILD_DIR):
7083
$(ARM64_BUILD_DIR):
7184
mkdir -p $@
7285

73-
$(AMD64_BUILD_DIR)/%.o: $(AMD64_SRC_DIR)/%.asm $(INC_DIR)/*.inc | $(AMD64_BUILD_DIR)
86+
$(AMD64_BUILD_DIR)/%.o: $(AMD64_SRC_DIR)/%.asm $(INC_DIR)/*.inc $(INC_DIR)/version_amd64.inc | $(AMD64_BUILD_DIR)
7487
$(NASM) $(NASMFLAGS) $< -o $@
7588

76-
$(ARM64_BUILD_DIR)/%.o: $(ARM64_SRC_DIR)/%.S $(INC_DIR)/*.inc | $(ARM64_BUILD_DIR)
77-
$(ARM64_AS) $(ARM64_ASFLAGS) -I$(INC_DIR) $< -o $@
89+
$(ARM64_BUILD_DIR)/%.o: $(ARM64_SRC_DIR)/%.S $(INC_DIR)/*.inc $(INC_DIR)/version_arm64.inc | $(ARM64_BUILD_DIR)
90+
$(ARM64_AS) $(ARM64_ASFLAGS) $< -o $@
7891

7992
# Helper objects
8093
$(ARM64_BUILD_DIR)/helpers/%.o: $(ARM64_SRC_DIR)/helpers/%.S $(INC_DIR)/*.inc | $(ARM64_BUILD_DIR)

README.md

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,18 @@ Numeric env vars are parsed as **non-negative decimal**. If a value is invalid/o
266266
- `EP_ARM64_FALLBACK` (ARM64/QEMU only)
267267
If set to `1`, ARM64 builds skip the epoll/signalfd path and use a simpler
268268
`wait4` loop. Intended as a workaround for QEMU user-mode flakiness in CI smoke tests.
269-
This mode does **not** provide the full signal-forwarding/grace-timer behavior; it primarily verifies spawn + exit-code propagation.
269+
270+
**WARNING:** This mode is a CI testing stub and is **NOT suitable for production use**.
271+
It does **NOT** provide:
272+
- Signal forwarding to child process group
273+
- Graceful shutdown with grace period escalation
274+
- Restart-on-crash functionality
275+
- Custom signal monitoring (EP_SIGNALS)
276+
277+
Fallback mode only verifies basic spawn and exit code propagation. Use it **only**
278+
for CI smoke testing under QEMU user-mode emulation. For production, run the full
279+
binary on native ARM64 hardware or use full-system emulation.
280+
270281
In fallback mode, verbose logs may omit timestamps to avoid QEMU-user emulation issues.
271282
Default: `0` (CI jobs typically set this).
272283

@@ -307,6 +318,34 @@ EP_RESTART_ENABLED=1 EP_MAX_RESTARTS=0 EP_RESTART_BACKOFF_SECONDS=0 \
307318
./build/mini-init-amd64 -- ./your-app
308319
```
309320

321+
### Best Practices
322+
323+
#### Restart Configuration
324+
325+
When enabling restart-on-crash (`EP_RESTART_ENABLED=1`):
326+
327+
- **Always set a backoff delay** (`EP_RESTART_BACKOFF_SECONDS`) to prevent tight restart loops
328+
- Recommended minimum: `1` second (default)
329+
- For flaky apps: `5-10` seconds
330+
331+
- **Set a restart limit** (`EP_MAX_RESTARTS`) to prevent infinite loops on persistent failures
332+
- Recommended: `3-5` restarts for transient errors
333+
- Use `0` (unlimited) only for long-running services with rare crashes
334+
335+
**Example - Good configuration:**
336+
```bash
337+
# Bounded restarts with backoff (recommended)
338+
EP_RESTART_ENABLED=1 EP_MAX_RESTARTS=3 EP_RESTART_BACKOFF_SECONDS=5 \
339+
./build/mini-init-amd64 -- ./my-app
340+
```
341+
342+
**Example - Dangerous configuration:**
343+
```bash
344+
# Unlimited restarts with no delay (tight loop on immediate crash - avoid!)
345+
EP_RESTART_ENABLED=1 EP_MAX_RESTARTS=0 EP_RESTART_BACKOFF_SECONDS=0 \
346+
./build/mini-init-amd64 -- ./my-app
347+
```
348+
310349
### Exit code semantics
311350

312351
- Child exits normally → `mini-init-asm` returns the **child exit code**.
@@ -477,6 +516,52 @@ bash scripts/test_diagnostics.sh build/mini-init-arm64
477516

478517
---
479518

519+
## Debian Packaging
520+
521+
### Package Information
522+
523+
The Debian package `mini-init-asm` provides a unified binary:
524+
- **Installed at:** `/usr/bin/mini-init-asm`
525+
- **Architecture-specific:** Built for `amd64` and `arm64` only
526+
- **Statically linked:** No runtime dependencies (libc-free)
527+
528+
### Building the Debian Package
529+
530+
```bash
531+
# Install build dependencies
532+
sudo apt-get install debhelper-compat binutils nasm make
533+
534+
# Build binary package
535+
dpkg-buildpackage -us -uc -b
536+
537+
# Install locally
538+
sudo dpkg -i ../mini-init-asm_*.deb
539+
```
540+
541+
### Running Autopkgtest
542+
543+
```bash
544+
# After installing package
545+
autopkgtest . -- null
546+
547+
# Or from source tree with schroot
548+
autopkgtest -B . -- schroot unstable-amd64
549+
```
550+
551+
### Lintian Check
552+
553+
```bash
554+
lintian --fail-on warning --display-info ../mini-init-asm_*.deb
555+
```
556+
557+
### Supported Architectures
558+
559+
Currently supported: **amd64**, **arm64**
560+
561+
Other architectures are not supported due to the assembly implementation.
562+
563+
---
564+
480565
## Security notes
481566

482567
- No privilege dropping, seccomp profiles, or capabilities tuning are implemented here.

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.3.1

debian/changelog

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
mini-init-asm (0.3.1-1) unstable; urgency=medium
2+
3+
* Debian packaging fixes:
4+
- Fix Architecture field (any → amd64 arm64) to prevent FTBFS
5+
- Add explicit make to Build-Depends for reproducible builds
6+
* Implement VERSION single source of truth for version strings
7+
* Enhanced autopkgtest coverage:
8+
- Add restart-on-crash validation test
9+
- Add PGID signal fan-out test
10+
* Documentation improvements:
11+
- Add EP_ARM64_FALLBACK production usage warning
12+
- Add restart configuration best practices
13+
- Add Debian packaging guide section
14+
* Update man page date and version metadata
15+
* All changes verified: make test-all, dpkg-buildpackage, lintian clean
16+
17+
-- Debian Maintainer <debian-maint@example.org> Sun, 11 Jan 2026 00:00:00 +0000
18+
119
mini-init-asm (0.3.0-1) unstable; urgency=medium
220

321
* Initial Debian packaging skeleton. (Closes: #1122134)

debian/control

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Priority: optional
44
Maintainer: Debian Maintainer <debian-maint@example.org>
55
Build-Depends:
66
debhelper-compat (= 13),
7+
make,
78
binutils,
89
nasm [amd64]
910
Standards-Version: 4.6.2
@@ -13,7 +14,7 @@ Vcs-Browser: https://github.com/roots666/mini-init-asm
1314
Vcs-Git: https://github.com/roots666/mini-init-asm.git
1415

1516
Package: mini-init-asm
16-
Architecture: any
17+
Architecture: amd64 arm64
1718
Depends: ${misc:Depends}
1819
Description: tiny PID 1 init for containers (pure assembly)
1920
mini-init-asm is a tiny init intended for container entrypoints.

debian/tests/smoke

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,62 @@ sleep 0.5
3131
kill -TRAP "$pid"
3232
wait "$pid"
3333

34+
echo "[autopkgtest] 4) restart on crash"
35+
# Create a script that exits on first run, succeeds on second run
36+
cat > /tmp/crash_once.sh <<'CRASHEOF'
37+
#!/bin/sh
38+
if [ -f /tmp/restart_marker ]; then
39+
# Second run: exit normally
40+
exit 0
41+
else
42+
# First run: create marker and crash
43+
touch /tmp/restart_marker
44+
exit 1
45+
fi
46+
CRASHEOF
47+
chmod +x /tmp/crash_once.sh
48+
rm -f /tmp/restart_marker
49+
rm -f /tmp/restart.log
50+
set +e
51+
EP_RESTART_ENABLED=1 EP_MAX_RESTARTS=1 "$BIN" -v -- /tmp/crash_once.sh 2>&1 | tee /tmp/restart.log
52+
rc=$?
53+
set -e
54+
# Should see "DEBUG: restarting child" in logs
55+
if grep -q "DEBUG: restarting child" /tmp/restart.log; then
56+
echo " ✓ Restart triggered"
57+
else
58+
echo " ✗ Restart not found in logs" >&2
59+
exit 1
60+
fi
61+
# Final exit code should be 0 (second run succeeded)
62+
test "$rc" -eq 0
63+
rm -f /tmp/crash_once.sh /tmp/restart_marker /tmp/restart.log
64+
65+
echo "[autopkgtest] 5) PGID fan-out (signal reaches grandchild)"
66+
# Child spawns grandchild, both trap TERM, both should receive signal
67+
cat > /tmp/pgid_test.sh <<'PGIDEOF'
68+
#!/bin/sh
69+
trap 'echo "grandchild got TERM" >> /tmp/pgid_test.log; exit 0' TERM
70+
sleep 1000 &
71+
GRANDCHILD_PID=$!
72+
trap 'echo "child got TERM" >> /tmp/pgid_test.log; wait $GRANDCHILD_PID; exit 0' TERM
73+
sleep 1000
74+
PGIDEOF
75+
chmod +x /tmp/pgid_test.sh
76+
rm -f /tmp/pgid_test.log
77+
"$BIN" -- /tmp/pgid_test.sh &
78+
pid=$!
79+
sleep 0.5
80+
kill -TERM "$pid"
81+
wait "$pid"
82+
# Both child and grandchild should have logged
83+
if grep -q "child got TERM" /tmp/pgid_test.log && grep -q "grandchild got TERM" /tmp/pgid_test.log; then
84+
echo " ✓ Both child and grandchild received TERM"
85+
else
86+
echo " ✗ PGID fan-out failed" >&2
87+
cat /tmp/pgid_test.log >&2
88+
exit 1
89+
fi
90+
rm -f /tmp/pgid_test.sh /tmp/pgid_test.log
91+
3492
echo "[autopkgtest] OK"

include/version_amd64.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
; Auto-generated version file
2+
version_msg_str: db "mini-init-amd64 0.3.1", 10, 0
3+
version_msg_len_val: equ $ - version_msg_str - 1

include/version_arm64.inc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Auto-generated version file
2+
version_msg_arm64: .asciz "mini-init-arm64 0.3.1
3+
"
4+
.equ version_msg_arm64_len, . - version_msg_arm64 - 1

0 commit comments

Comments
 (0)