#
# Copyright (C) 2023 IOPSYS
#

include $(TOPDIR)/rules.mk

PKG_NAME:=packet-capture-diagnostics
PKG_VERSION:=1.0.4

LOCAL_DEV:=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/bbf/packet-capture-diagnostics.git
PKG_SOURCE_VERSION:=d1115ed0c129614192b9c4e68e7b81b52e08ea4f
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.zst
PKG_MIRROR_HASH:=skip
endif

PKG_LICENSE:=BSD-3-Clause
PKG_LICENSE_FILES:=LICENSE

include $(INCLUDE_DIR)/package.mk
include ../bbfdm/bbfdm.mk

define Package/packet-capture-diagnostics
  SECTION:=utils
  CATEGORY:=Utilities
  SUBMENU:=TRx69
  TITLE:=PacketCaptureDiagnostics datamodel
  DEPENDS:=+tcpdump
  DEPENDS+=+libbbfdm-api +libbbfdm-ubus +dm-service
  MENU:=1
endef

MAKE_PATH:=src

define Package/packet-capture-diagnostics/description
  Package to add Device.PacketCaptureDiagnostics. datamodel support using bbfdm
endef

ifeq ($(LOCAL_DEV),1)
define Build/Prepare
	$(CP) -rf ~/git/packet-capture-diagnostics/* $(PKG_BUILD_DIR)/
endef
endif

define Package/packet-capture-diagnostics/install
	$(BBFDM_INSTALL_SCRIPT) ./files/scripts/packetcapture $(1)
	$(BBFDM_INSTALL_MS_PLUGIN) $(PKG_BUILD_DIR)/src/libpackcapture.so $(1) core 12
endef

$(eval $(call BuildPackage,packet-capture-diagnostics))
