Skip to content

Commit c07d7a6

Browse files
committed
Switch to C-based mini init process
Signed-off-by: Cong Wang <cwang@multikernel.io>
1 parent c28b971 commit c07d7a6

8 files changed

Lines changed: 493 additions & 15 deletions

File tree

.github/workflows/lint_and_test.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ jobs:
2626
virtualenvs-path: .venv
2727
installer-parallel: true
2828

29+
- name: Install musl-tools
30+
run: |
31+
sudo apt-get update
32+
sudo apt-get install -y musl-tools
33+
34+
- name: Build init binary
35+
run: |
36+
make
37+
2938
- name: Install dependencies
3039
run: |
3140
poetry install --no-interaction

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
__pycache__/
2+
3+
# Built artifacts
4+
src/init/kerf-init
5+
src/kerf/data/kerf-init

Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Top-level Makefile for kerf
2+
# Builds the C init binary and copies it to package data
3+
4+
all: init
5+
6+
init:
7+
$(MAKE) -C src/init
8+
mkdir -p src/kerf/data
9+
cp src/init/kerf-init src/kerf/data/
10+
11+
clean:
12+
$(MAKE) -C src/init clean
13+
rm -f src/kerf/data/kerf-init
14+
15+
.PHONY: all init clean

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ description = "Multikernel Management CLI tool"
99
authors = ["Cong Wang"]
1010
readme = "README.md"
1111
packages = [{include = "kerf", from = "src"}]
12+
include = [
13+
{ path = "src/kerf/data/kerf-init", format = ["sdist", "wheel"] },
14+
]
1215

1316
[tool.poetry.dependencies]
1417
python = "^3.9"

src/init/Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Makefile for kerf-init
2+
# Builds a statically-linked init binary using musl-gcc
3+
4+
CC = musl-gcc
5+
CFLAGS = -Wall -Wextra -Werror -O2 -static
6+
TARGET = kerf-init
7+
8+
all: $(TARGET)
9+
10+
$(TARGET): init.c
11+
$(CC) $(CFLAGS) -o $@ $<
12+
13+
clean:
14+
rm -f $(TARGET)
15+
16+
.PHONY: all clean

0 commit comments

Comments
 (0)