Makefile 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. # netpulse-agent — OpenWrt Makefile (Fase 7.4)
  2. # Empaqueta el binario Go estático precompilado para arm64/armv7/amd64.
  3. #
  4. # Uso (desde el SDK o buildroot de OpenWrt):
  5. # cp -r netpulse-agent package/utils/
  6. # make menuconfig # seleccionar Utilities → netpulse-agent
  7. # make package/netpulse-agent/compile V=s
  8. #
  9. # O con el feed propio:
  10. # echo "src-git netpulse https://github.com/gnacho/netpulse.git" >> feeds.conf
  11. # ./scripts/feeds update netpulse && ./scripts/feeds install netpulse-agent
  12. include $(TOPDIR)/rules.mk
  13. PKG_NAME:=netpulse-agent
  14. PKG_VERSION:=2.6.0
  15. PKG_RELEASE:=1
  16. PKG_SOURCE_PROTO:=git
  17. PKG_SOURCE_URL:=https://github.com/gnacho/netpulse.git
  18. PKG_SOURCE_VERSION:=main
  19. PKG_MIRROR_HASH:=skip
  20. PKG_LICENSE:=AGPL-3.0-only
  21. PKG_MAINTAINER:=Nacho <netpulse@example.com>
  22. include $(INCLUDE_DIR)/package.mk
  23. # Go binario estático — sin dependencias de librerías C
  24. # Construido con CGO_ENABLED=0; arquitecturas soportadas:
  25. # aarch64 (arm64) — GL-MT6000, Redmi AX6 y la mayoría de routers modernos
  26. # arm (armv7) — routers Cortex-A7/A9 más antiguos
  27. # x86_64 (amd64) — PCs/x86 corriendo OpenWrt
  28. define Package/netpulse-agent
  29. SECTION:=utils
  30. CATEGORY:=Utilities
  31. TITLE:=NetPulse native agent for OpenWrt
  32. URL:=https://github.com/gnacho/netpulse
  33. DEPENDS:=+iw @(aarch64||arm||x86_64)
  34. endef
  35. define Package/netpulse-agent/description
  36. Native OpenWrt agent for NetPulse network monitor. Probes the local
  37. router (system, wireless, DHCP, FDB) and pushes data to a NetPulse
  38. server. Listens for nl80211 events (assoc/disassoc) in real time and
  39. receives commands from the server via SSE. Stateless: no writes to
  40. flash; logs go to syslog via stderr.
  41. endef
  42. # ---------------------------------------------------------------------------
  43. # Build — el binario se compila desde el código fuente del repo con Go.
  44. # Requiere golang y UPX en el host de compilación (el SDK de OpenWrt incluye Go).
  45. # Si no quieres compilar, sustituye esta sección por la descarga del binario
  46. # precompilado de la release.
  47. # ---------------------------------------------------------------------------
  48. GO_ARCH_DETECT:=$(shell echo $(ARCH) | sed 's/aarch64/arm64/;s/arm_cortex-a7/armv7/;s/arm_cortex-a9/armv7/;s/arm_cortex-a53/arm64/;s/arm_cortex-a55/arm64/;s/x86_64/amd64/')
  49. define Build/Compile
  50. rm -f $(PKG_BUILD_DIR)/netpulse-agent
  51. (cd $(PKG_BUILD_DIR)/agent && \
  52. CGO_ENABLED=0 GOOS=linux GOARCH=$(GO_ARCH_DETECT) \
  53. go build -trimpath -ldflags "-s -w -X main.Version=$(PKG_VERSION)" \
  54. -o $(PKG_BUILD_DIR)/netpulse-agent ./cmd/netpulse-agent)
  55. upx --best --lzma $(PKG_BUILD_DIR)/netpulse-agent
  56. upx -t $(PKG_BUILD_DIR)/netpulse-agent
  57. endef
  58. define Package/netpulse-agent/install
  59. $(INSTALL_DIR) $(1)/usr/sbin
  60. $(INSTALL_BIN) $(PKG_BUILD_DIR)/netpulse-agent $(1)/usr/sbin/netpulse-agent
  61. $(INSTALL_DIR) $(1)/etc/init.d
  62. $(INSTALL_BIN) ./files/netpulse-agent.init $(1)/etc/init.d/netpulse-agent
  63. $(INSTALL_DIR) $(1)/etc/config
  64. $(INSTALL_CONF) ./files/netpulse-agent.config $(1)/etc/config/netpulse-agent
  65. $(INSTALL_DIR) $(1)/etc/uci-defaults
  66. $(INSTALL_BIN) ./files/netpulse-agent.defaults $(1)/etc/uci-defaults/90-netpulse-agent
  67. endef
  68. $(eval $(call BuildPackage,netpulse-agent))