🎁 Sync 2026-11-03 22:44:23

This commit is contained in:
github-actions[bot] committed 2026-11-03 22:44:23 +08:00
1 parent c98c555863
commit b064eba78c
13 files changed
+428 -57

No files matched your search

+17 -22
View File
@@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=honk
PKG_VERSION:=2026.11.03~77176ff
PKG_RELEASE:=27
PKG_RELEASE:=28
HONK_SRC_URL:=https://github.com/daeuniverse/honk.git
HONK_SRC_VERSION:=77176ff8e8cc2b75385a7030dc376536c382574a
@@ -55,36 +55,31 @@ define Package/honk/conffiles
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
mkdir -p "$(PKG_BUILD_DIR)"
endef
define Build/Compile
@if [ -f $(CURDIR)/files/honk-core.bin ]; then \
$(INSTALL_DIR) $(PKG_INSTALL_DIR)/bin; \
$(INSTALL_BIN) $(CURDIR)/files/honk-core.bin $(PKG_INSTALL_DIR)/bin/honk-core; \
else \
echo "ERROR: $(CURDIR)/files/honk-core.bin missing!" >&2; \
echo "Compile it first via: ./scripts/build_honk_core.sh <arch>" >&2; \
exit 1; \
fi
"$(CURDIR)/build_honk_core.sh" --if-needed "$(ARCH)" "$(CURDIR)/files/honk-core.bin"
$(INSTALL_DIR) "$(PKG_INSTALL_DIR)/bin"
$(INSTALL_BIN) "$(CURDIR)/files/honk-core.bin" "$(PKG_INSTALL_DIR)/bin/honk-core"
endef
define Package/honk/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/bin/honk-core $(1)/usr/bin/honk-core
$(INSTALL_DIR) "$(1)/usr/bin"
$(INSTALL_BIN) "$(PKG_INSTALL_DIR)/bin/honk-core" "$(1)/usr/bin/honk-core"
$(INSTALL_DIR) $(1)/etc/honk/config.d
$(INSTALL_CONF) $(CURDIR)/files/config.dae $(1)/etc/honk/config.dae
$(INSTALL_CONF) $(CURDIR)/files/config.d/node.dae $(1)/etc/honk/config.d/node.dae
$(INSTALL_CONF) $(CURDIR)/files/config.d/route.dae $(1)/etc/honk/config.d/route.dae
$(INSTALL_CONF) $(CURDIR)/files/config.d/dns.dae $(1)/etc/honk/config.d/dns.dae
$(INSTALL_CONF) $(CURDIR)/files/config.d/api.dae $(1)/etc/honk/config.d/api.dae
$(INSTALL_DIR) "$(1)/etc/honk/config.d"
$(INSTALL_CONF) "$(CURDIR)/files/config.dae" "$(1)/etc/honk/config.dae"
$(INSTALL_CONF) "$(CURDIR)/files/config.d/node.dae" "$(1)/etc/honk/config.d/node.dae"
$(INSTALL_CONF) "$(CURDIR)/files/config.d/route.dae" "$(1)/etc/honk/config.d/route.dae"
$(INSTALL_CONF) "$(CURDIR)/files/config.d/dns.dae" "$(1)/etc/honk/config.d/dns.dae"
$(INSTALL_CONF) "$(CURDIR)/files/config.d/api.dae" "$(1)/etc/honk/config.d/api.dae"
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) $(CURDIR)/files/honk.config $(1)/etc/config/honk
$(INSTALL_DIR) "$(1)/etc/config"
$(INSTALL_CONF) "$(CURDIR)/files/honk.config" "$(1)/etc/config/honk"
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) $(CURDIR)/files/honk.init $(1)/etc/init.d/honk
$(INSTALL_DIR) "$(1)/etc/init.d"
$(INSTALL_BIN) "$(CURDIR)/files/honk.init" "$(1)/etc/init.d/honk"
endef
$(eval $(call BuildPackage,honk))
+164
View File
@@ -0,0 +1,164 @@
#!/usr/bin/env bash
# Build honk-core for an OpenWrt arch/target triple.
#
# ./honk/build_honk_core.sh [--if-needed] <arch|target_triple> [output_file] [source_dir]
#
# --if-needed: skip when the output exists and its .stamp matches the target
# (or has no stamp, i.e. a prebuilt artifact); rebuild on a target mismatch.
set -euo pipefail
IF_NEEDED=0
while [ $# -gt 0 ]; do
case "$1" in
--if-needed) IF_NEEDED=1; shift ;;
*) break ;;
esac
done
TARGET_IN="${1:?usage: $0 [--if-needed] <arch|target_triple> [output_file] [source_dir]}"
OUT_FILE="${2:-}"
SRC_DIR="${3:-}"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [ -f "${HOME:-}/.cargo/env" ]; then
. "${HOME:-}/.cargo/env"
fi
export PATH="${HOME:-}/.cargo/bin:/usr/local/bin:/usr/bin:/bin:${PATH:-}"
case "$TARGET_IN" in
x86_64|x86_64-unknown-linux-musl)
RUST_TARGET=x86_64-unknown-linux-musl
ZIG_TARGET=x86_64-linux-musl
;;
aarch64|aarch64_generic|aarch64-unknown-linux-musl)
RUST_TARGET=aarch64-unknown-linux-musl
ZIG_TARGET=aarch64-linux-musl
;;
*)
echo "ERROR: unsupported arch: $TARGET_IN" >&2
exit 1
;;
esac
OUT_FILE="${OUT_FILE:-$SCRIPT_DIR/files/honk-core.bin}"
case "$OUT_FILE" in
/*) ;;
*) OUT_FILE="$PWD/$OUT_FILE" ;;
esac
if [ "$IF_NEEDED" = 1 ] && [ -f "$OUT_FILE" ]; then
if [ ! -f "$OUT_FILE.stamp" ]; then
echo "==> using prebuilt honk-core (no stamp): $OUT_FILE"
exit 0
fi
if [ "$(cat "$OUT_FILE.stamp")" = "$RUST_TARGET" ]; then
echo "==> honk-core is up to date: $OUT_FILE"
exit 0
fi
echo "==> honk-core target changed, rebuilding: $OUT_FILE"
fi
# Building: drop the old artifact so a failed build cannot be reused.
rm -f "$OUT_FILE" "$OUT_FILE.stamp"
MAKEFILE="${HONK_MAKEFILE:-$SCRIPT_DIR/Makefile}"
if [ -n "$SRC_DIR" ]; then
eval "$("$SCRIPT_DIR/honk_toolchain.sh" --src "$SRC_DIR" "$MAKEFILE")"
else
eval "$("$SCRIPT_DIR/honk_toolchain.sh" "$MAKEFILE")"
SRC_DIR="$SCRIPT_DIR/honk-src"
CACHED_REV=$(git -C "$SRC_DIR" rev-parse HEAD 2>/dev/null || true)
if [ -d "$SRC_DIR/crates/honk-core" ] && [ "$CACHED_REV" = "$HONK_SRC_VERSION" ]; then
echo "==> Reusing $SRC_DIR at ${HONK_SRC_VERSION}"
else
if [ -n "$CACHED_REV" ]; then
echo "==> honk-src is at ${CACHED_REV}, expected ${HONK_SRC_VERSION}; refetching..."
fi
rm -rf "$SRC_DIR"
echo "==> Fetching honk source (${HONK_SRC_URL} @ ${HONK_SRC_VERSION})..."
git init -q "$SRC_DIR"
git -C "$SRC_DIR" remote add origin "$HONK_SRC_URL"
git -C "$SRC_DIR" fetch --depth 1 origin "$HONK_SRC_VERSION"
git -C "$SRC_DIR" checkout -q --detach FETCH_HEAD
fi
fi
SRC_DIR="$(cd "$SRC_DIR" && pwd)"
echo "==> Source: $SRC_DIR"
echo "==> Target: $RUST_TARGET (zig: $ZIG_TARGET)"
command -v zig >/dev/null 2>&1 || { echo "ERROR: zig not found in PATH" >&2; exit 1; }
command -v bpf-linker >/dev/null 2>&1 || { echo "ERROR: bpf-linker not found in PATH" >&2; exit 1; }
command -v cargo >/dev/null 2>&1 || { echo "ERROR: cargo not found in PATH" >&2; exit 1; }
ZIG_ACTUAL="$(zig version)"
if [ "$ZIG_ACTUAL" != "$ZIG_VERSION" ]; then
echo "ERROR: zig ${ZIG_ACTUAL} does not match the honk pin ${ZIG_VERSION}" >&2
exit 1
fi
echo "==> zig ${ZIG_ACTUAL}"
# bpf-linker 0.11.0 reports 0.0.0; its tarball is checked by sha256 at install time.
echo "==> $(bpf-linker --version 2>/dev/null | head -n 1)"
cd "$SRC_DIR"
EBPF_CHANNEL=$(sed -n 's/^channel[[:space:]]*=[[:space:]]*"\(.*\)"/\1/p' crates/honk-ebpf/rust-toolchain.toml 2>/dev/null | head -n 1)
EBPF_CHANNEL="${EBPF_CHANNEL:-nightly}"
if command -v rustup >/dev/null 2>&1; then
rustup target add "$RUST_TARGET"
rustup toolchain install "$EBPF_CHANNEL" --component rust-src,llvm-tools
fi
echo "==> Building honk-ebpf object..."
(
cd crates/honk-ebpf
cargo "+${EBPF_CHANNEL}" build --release -Zbuild-std=core --target bpfel-unknown-none
)
EBPF_OBJ="crates/honk-ebpf/target/bpfel-unknown-none/release/honk-ebpf"
[ -f "$EBPF_OBJ" ] || { echo "ERROR: eBPF object not found at $EBPF_OBJ" >&2; exit 1; }
if command -v readelf >/dev/null 2>&1; then
readelf -S "$EBPF_OBJ" | grep -q '\.BTF' || { echo "ERROR: $EBPF_OBJ has no .BTF section" >&2; exit 1; }
fi
export ZIGCC_TARGET="$ZIG_TARGET"
L=$(printf '%s' "$RUST_TARGET" | tr '-' '_')
U=$(printf '%s' "$RUST_TARGET" | tr 'a-z-' 'A-Z_')
export "CC_${L}=$SRC_DIR/ci/zigcc"
export "CXX_${L}=$SRC_DIR/ci/zigcxx"
export "CARGO_TARGET_${U}_LINKER=$SRC_DIR/ci/zigcc"
if [[ "$RUST_TARGET" == *-musl ]]; then
export "CARGO_TARGET_${U}_RUSTFLAGS=-C link-self-contained=no"
fi
export BINDGEN_EXTRA_CLANG_ARGS="$("$SRC_DIR/ci/zig-bindgen-env" "$ZIGCC_TARGET")"
echo "==> Building honk-core for $RUST_TARGET..."
cargo build --release --locked \
-p honk-core \
--no-default-features \
--features ebpf,rprx,clash-api,native-api,mimalloc \
--target "$RUST_TARGET"
BUILT_BIN="$SRC_DIR/target/$RUST_TARGET/release/honk-core"
[ -f "$BUILT_BIN" ] || { echo "ERROR: expected output not found at $BUILT_BIN" >&2; exit 1; }
FILE_DESC=$(file -b "$BUILT_BIN")
case "$FILE_DESC" in
ELF*) ;;
*) echo "ERROR: output is not an ELF binary: $FILE_DESC" >&2; exit 1 ;;
esac
if [[ "$RUST_TARGET" == *-musl ]] && [[ "$FILE_DESC" != *"statically linked"* ]]; then
echo "ERROR: $RUST_TARGET binary is not statically linked: $FILE_DESC" >&2
exit 1
fi
mkdir -p "$(dirname "$OUT_FILE")"
cp -f "$BUILT_BIN" "$OUT_FILE"
chmod +x "$OUT_FILE"
printf '%s\n' "$RUST_TARGET" > "$OUT_FILE.stamp"
echo "==> Build succeeded: $OUT_FILE"
echo "==> $FILE_DESC"
ls -lh "$OUT_FILE"
+73
View File
@@ -0,0 +1,73 @@
#!/usr/bin/env bash
# Resolve the toolchain pins for the honk commit pinned by the package Makefile.
#
# ./honk/honk_toolchain.sh [--src DIR] [Makefile]
#
# Prints HONK_SRC_URL / HONK_SRC_VERSION plus BPF_LINKER_VERSION / SHA256 and
# ZIG_VERSION, read from that commit's .github/ci/pins.env and release.yml (or
# from --src when the source is already checked out).
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SRC_DIR=""
MAKEFILE=""
while [ $# -gt 0 ]; do
case "$1" in
--src) SRC_DIR="${2:?--src needs a directory}"; shift 2 ;;
*) MAKEFILE="$1"; shift ;;
esac
done
MAKEFILE="${MAKEFILE:-${HONK_MAKEFILE:-$SCRIPT_DIR/Makefile}}"
[ -f "$MAKEFILE" ] || { echo "ERROR: Makefile not found: $MAKEFILE" >&2; exit 1; }
URL=$(sed -n 's/^[[:space:]]*HONK_SRC_URL:=//p' "$MAKEFILE" | head -n 1)
REV=$(sed -n 's/^[[:space:]]*HONK_SRC_VERSION:=//p' "$MAKEFILE" | head -n 1)
[ -n "$URL" ] && [ -n "$REV" ] || {
echo "ERROR: HONK_SRC_URL / HONK_SRC_VERSION missing in $MAKEFILE" >&2
exit 1
}
if [ -n "$SRC_DIR" ]; then
SRC_DIR="$(cd "$SRC_DIR" && pwd)"
PINS_FILE="$SRC_DIR/.github/ci/pins.env"
RELEASE_FILE="$SRC_DIR/.github/workflows/release.yml"
[ -f "$PINS_FILE" ] && [ -f "$RELEASE_FILE" ] || {
echo "ERROR: $SRC_DIR is not a honk checkout with .github metadata" >&2
exit 1
}
else
REPO_PATH="${URL#https://github.com/}"
REPO_PATH="${REPO_PATH%.git}"
RAW="https://raw.githubusercontent.com/${REPO_PATH}/${REV}"
fetch() {
curl -fsSL --retry 3 "$1" || { echo "ERROR: failed to fetch $1" >&2; exit 1; }
}
PINS_FILE="$(mktemp)"
RELEASE_FILE="$(mktemp)"
trap 'rm -f "$PINS_FILE" "$RELEASE_FILE"' EXIT
fetch "${RAW}/.github/ci/pins.env" > "$PINS_FILE"
fetch "${RAW}/.github/workflows/release.yml" > "$RELEASE_FILE"
fi
BPF_LINKER_VERSION=$(sed -n 's/^BPF_LINKER_VERSION=//p' "$PINS_FILE" | head -n 1)
BPF_LINKER_SHA256=$(sed -n 's/^BPF_LINKER_SHA256=//p' "$PINS_FILE" | head -n 1)
[ -n "$BPF_LINKER_VERSION" ] && [ -n "$BPF_LINKER_SHA256" ] || {
echo "ERROR: BPF_LINKER_VERSION / BPF_LINKER_SHA256 missing in $PINS_FILE" >&2
exit 1
}
ZIG_VERSION=$(awk '
/setup-zig/ { seen = 1; next }
seen && /^[[:space:]]*version:[[:space:]]*/ {
sub(/^[[:space:]]*version:[[:space:]]*/, "")
gsub(/[[:space:]"]/, "")
print
exit
}
' "$RELEASE_FILE")
[ -n "$ZIG_VERSION" ] || { echo "ERROR: no setup-zig version in $RELEASE_FILE" >&2; exit 1; }
printf 'HONK_SRC_URL=%s\nHONK_SRC_VERSION=%s\nBPF_LINKER_VERSION=%s\nBPF_LINKER_SHA256=%s\nZIG_VERSION=%s\n' \
"$URL" "$REV" "$BPF_LINKER_VERSION" "$BPF_LINKER_SHA256" "$ZIG_VERSION"