Host/xxxx in package doesn't run during build?

I'm working on a package (Rust-lang) that runs/installs/etc if I call it directly (make package/feeds/packages/rust/host/compile), but does NOT get called from another package with HOST_BUILD_DEPENDS:=rust/host

I do not have Build/xxxx sections because, for now, it's host-only. Below is the Makefile I'm using for my rust package and for the suricata6 pacakge

rust

# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk

PKG_NAME:=rust
PKG_VERSION:=1.49.0
PKG_RELEASE:=1
PKG_LICENSE:=Apache-2.0 MIT
PKG_LICENSE_FILES:=LICENSE-APACHE LICENSE-MIT

PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/rust-lang/rust.git
PKG_SOURCE_DATE:=2020-11-11
#PKG_SOURCE_VERSION:=b2d115f6db5172c961dfeb50de15f35784dbc7c9
#PKG_SOURCE_VERSION:=5a6a41e7847ff5f85a31b87431ce2af29c567f1d
PKG_SOURCE_VERSION:=fa55f668e5ea5388ec98b9340969527252239151
PKG_HASH:=skip
PKG_HOST_ONLY:=1

include $(INCLUDE_DIR)/cmake.mk
include $(INCLUDE_DIR)/host-build.mk
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/download.mk
include ./rustc-triple.mk

HOST_BUILD_DEPENDS:=rust/host ninja/host python3/host
CMAKE_INSTALL:=1

#gen_sha256sum=$(shell mkhash sha256 $(DL_DIR)/$(1))
#fixup_rust_hash=$(shell $(SCRIPT_DIR)/fixup-makefile.pl $(1) fix-hash $(2) $(3))

# Basic Configuration Args that are used across all builds.
# Other build arguments are found in ./rustc-config.mk
#
# Default CONFIGURE_ARGS introduces unknown options - Use this instead
CONFIGURE_ARGS = \
  --host=$(RUSTC_HOST_ARCH) \
  --build=$(RUSTC_HOST_ARCH) \
  --target=$(RUSTC_TARGET_ARCH) \
  --prefix=$(CARGO_HOME) \
  --bindir=$(CARGO_HOME)/bin \
  --libdir=$(CARGO_HOME)/lib \
  --sysconfdir=$(CARGO_HOME)/etc \
  --datadir=$(CARGO_HOME)/share \
  --mandir=$(CARGO_HOME)/man \
  --infodir=$(CARGO_HOME)/info \
  --localstatedir=/var \
  --release-channel=nightly \
  --enable-lld \
  --set=target.$(RUSTC_TARGET_ARCH).linker=$(TARGET_CC_NOCACHE) \
  --set=target.$(RUSTC_TARGET_ARCH).cc=$(TARGET_CC_NOCACHE) \
  --set=target.$(RUSTC_TARGET_ARCH).cxx=$(TARGET_CXX_NOCACHE) \
  --set=target.$(RUSTC_TARGET_ARCH).ar=$(TARGET_AR) \
  --set=target.$(RUSTC_TARGET_ARCH).ranlib=$(TARGET_RANLIB)

# Because we override CONFIGURE_ARGS, this needs to go here.
include ./rustc-config.mk

RUST_TMP_DIR:=$(TMP_DIR)/rust-install
RUST_INSTALL_FILE_NAME:=$(PKG_NAME)-$(PKG_VERSION)-$(RUSTC_HOST_ARCH)_$(RUSTC_TARGET_ARCH)-install.tar.xz
RUST_INSTALL_FILE_VERIFY:=$(call check_hash,$(RUST_INSTALL_FILE_NAME),$(RUST_INSTALL_FILE_HASH),RUST_INSTALL_FILE_HASH)
RUST_INSTALL_UNINSTALL:=$(CARGO_HOME)/lib/rustlib/uninstall.sh
RUST_INSTALL_BINARIES:=$(CURDIR)/install_binaries.sh $(RUST_TMP_DIR) $(DL_DIR)/$(RUST_INSTALL_FILE_NAME) $(CARGO_HOME)
RUST_INSTALL_FILE_HASH:=skip

RUST_BINARY=$(or $(and $(wildcard $(DL_DIR)/$(RUST_INSTALL_FILE_NAME)),true),false)

define Host/Clean
	$(call Host/Clean/Default)

	[ -f $(RUST_INSTALL_UNINSTALL) ] && \
	    $(RUST_INSTALL_UNINSTALL) || echo No Uninstall Found

	rm -rf $(BUILD_DIR_HOST)/rust
endef

define Host/InstallDev
	[ $(RUST_BINARY) = true ] && ( sh $(RUST_INSTALL_BINARIES) )
endef

define Host/Configure
	# Required because OpenWrt Default CONFIGURE_ARGS contain extra
	# args that cause errors
	[ $(RUST_BINARY) = true ] && \
	( true ) || \
	  ( cd $(HOST_BUILD_DIR) && \
	     RUST_BACKTRACE=full \
		./configure $(CONFIGURE_ARGS) )
endef

define Host/Compile
	[ $(RUST_BINARY) = true ] && ( true ) || \
	  ( cd $(HOST_BUILD_DIR) && \
	     ( RUST_BACKTRACE=full \
		$(PYTHON) x.py --config ./config.toml dist cargo extended \
		   library/std llvm-tools miri rust-dev rustc-dev src \
		   src/librustc src/lldb_batchmode.py src/tools/build-manifest ))
endef

define Host/CreateBinaries
	cd $(HOST_BUILD_DIR)/build/dist && \
	   $(RM) *.gz && \
	   $(call dl_tar_pack,$(DL_DIR)/$(RUST_INSTALL_FILE_NAME),.)

	$(eval $(call fixup_rust_hash, $(CURDIR)/Makefile, \
	   RUST_INSTALL_FILE_HASH, \
	   $(call gen_sha256sum,$(RUST_INSTALL_FILE_NAME))))
endef


define Host/Install
	[ $(RUST_BINARY) = true ] && ( sh $(RUST_INSTALL_BINARIES) ) || \
	( cd $(HOST_BUILD_DIR)/build/dist && \
	   $(RM) *.gz && \
	   $(call dl_tar_pack,$(DL_DIR)/$(RUST_INSTALL_FILE_NAME),.) && \
	cd $(RUST_TMP_DIR) && \
	   $(TAR) -xJf $(DL_DIR)/$(RUST_INSTALL_FILE_NAME) && \
	   find -iname "*.xz" -exec $(TAR) -x -J -f {} ";" && \
	   find ./* -type f -name install.sh -execdir sh {} --prefix=$(CARGO_HOME) --disable-ldconfig \; && \
	$(RM) -rf $(RUST_TMP_DIR))
endef

define Host/Prepare
	# Allows outside packages to call $$(BUILD_DIR_HOST)/rust as the dir
	# rather than needing the version number.
	[ -L $(BUILD_DIR_HOST)/rust ] || \
	   (cd $(BUILD_DIR_HOST); ln -s "$(PKG_NAME)-$(PKG_VERSION)" rust)

	[ -d $(RUST_TMP_DIR) ] || \
	   mkdir -p $(RUST_TMP_DIR)

	$(call Host/Prepare/Default)
endef

define Package/rust
  SECTION:=lang
  CATEGORY:=Languages
  TITLE:=Rust Programming Language Compiler
  URL:=https://www.rust-lang.org/
  DEPENDS:=+python3 +ninja +pkg-config +libopenssl +libyaml \
    +libyaml-cpp +libunwind +openssl-util +python3-yaml
endef

define Package/rust/description
  Rust lang
endef

define Package/rust/config
	source "$(SOURCE)/Config.in"
endef

$(eval $(call HostBuild))
$(eval $(call BuildPackage,rust))

Suricata

#
# Copyright (C) 2006-2015 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk

PKG_NAME:=suricata
PKG_VERSION:=6.0.0-beta1

PKG_SOURCE_PROTO:=git
PKG_SOURCE_DATE:=2020-10-08
PKG_SOURCE_VERSION:=95729e923f39b5adda31e4843a1b6ee06edbb0c8
PKG_SOURCE_URL:=https://github.com/OISF/suricata.git
PKG_HASH:=skip

SURICATA-UPDATE_SOURCE_DATE:=2020-10-05
SURICATA-UPDATE_SOURCE_VERSION:=86e530cbbfc78ac327072750a12edf888e6b8cae
SURICATA-UPDATE_SOURCE_URL:=https://github.com/OISF/suricata-update.git
SURICATA-UPDATE_HASH:=skip

PKG_FIXUP:=autoreconf
PKG_FIXUP:=patch-libtool

PKG_INSTALL:=1
HOST_BUILD_DEPENDS:=rust/host python3/host luajit/host

include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/nls.mk
include ../../lang/rust/rustc-triple.mk

define Package/suricata6
    SUBMENU:=Firewall
    SECTION:=net
    CATEGORY:=Network
    DEPENDS:=+rust +jansson +libcap-ng +libevent2 +libhiredis +liblz4 \
      +libmagic +libpcap +libpcre +libmaxminddb +libnet-1.2.x \
	 +libnetfilter-log +libnetfilter-queue +libnfnetlink +libnss \
	 +libopenssl +luajit +python3 +python3-pip +python3-yaml \
	 +python3-yaml-src +zlib $(ICONV_DEPENDS)
    TITLE:=OISF Suricata IDS
    URL:=https://www.openinfosecfoundation.org/
endef

CONFIGURE_VARS += \
	CARGO_HOME=$(CARGO_HOME) \
	ac_cv_path_CARGO="$(CARGO_HOME)/bin/cargo" \
	ac_cv_path_RUSTC="$(CARGO_HOME)/bin/rustc"
#	RUSTFLAGS="-C linker=$(TARGET_CC_NOCACHE) -C ar=$(TARGET_AR)"

CONFIGURE_ARGS = \
  	--prefix="/usr" \
  	--sysconfdir="/etc" \
  	--localstatedir="/var" \
  	--enable-nfqueue \
     --enable-af-packet \
     --enable-unittests \
	--enable-luajit \
	--enable-geoip \
     --enable-debug \
	--enable-hiredis \
     --enable-profiling \
     --enable-profiling-locks \
	--host=$(RUSTC_TARGET_ARCH) \
	--build=$(RUSTC_HOST_ARCH) \
	--with-suricata-update

#	--enable-non-bundled-htp \
#	--enable-ebpf-build \
#     --enable-profiling \
#     --enable-profiling-locks \
#     --enable-af-packet \
#	--enable-luajit \
#	--enable-geoip \
#	--enable-unittests \
#	--enable-hiredis \
#	--enable-ipfw

define Build/InstallDev
	$(call HostPython3/Run,,$(HOST_PYTHON3_PIP_INSTALL_HOST) PyYAML)
endef

define Build/Prepare
	$(call Build/Prepare/Default)
	cd $(PKG_BUILD_DIR) && git clone https://github.com/OISF/libhtp.git
	$(CONFIGURE_VARS) cargo install cbindgen
endef

define Build/Configure
	cd $(PKG_BUILD_DIR) && $(CONFIGURE_VARS) ./autogen.sh
	$(call Build/Configure/Default)
endef

define Package/suricata6/install
	$(INSTALL_DIR) $(1)/usr/bin
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/suricata $(1)/usr/bin/suricata
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/suricatactl $(1)/usr/bin/suricatactl
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/suricatasc $(1)/usr/bin/suricatasc

	$(INSTALL_DIR) $(1)/usr/lib
	$(CP) -r $(PKG_INSTALL_DIR)/usr/lib/* $(1)/usr/lib/

	$(INSTALL_DIR) $(1)/usr/include
	$(CP) -r $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/

	$(INSTALL_DIR) $(1)/usr/share
	$(CP) -r $(PKG_INSTALL_DIR)/usr/share/* $(1)/usr/share/

	$(INSTALL_DIR) $(1)/etc/suricata
	$(CP) $(PKG_BUILD_DIR)/suricata.yaml \
	$(PKG_BUILD_DIR)/etc/classification.config \
	$(PKG_BUILD_DIR)/threshold.config \
	$(PKG_BUILD_DIR)/etc/reference.config \
	$(1)/etc/suricata/

#	$(INSTALL_DIR) $(1)/etc/suricata/rules
#	$(CP) $(PKG_BUILD_DIR)/rules/*.rules $(1)/etc/suricata/rules/
#	$(INSTALL_DIR) $(1)/etc/init.d
#	$(INSTALL_BIN) ./files/suricata.init $(1)/etc/init.d/suricata
endef

$(eval $(call BuildPackage,suricata6))

As suricata doesn't have a host build, HOST_BUILD_DEPENDS doesn't have any effect there. I guess you meant to use

PKG_BUILD_DEPENDS:=rust/host python3/host luajit/host
1 Like

I'm sure that is going to be the correct fix. I'm still testing it, but since it's exposed a LuaJIT host error that i wasn't getting before, I'm expecting it to work.

Thanks again :slight_smile:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.