No rule to make target 'install' during wrapper package creation

Hi everyone,

This is my first topic, so I hope I will respect the rules :slight_smile:

I am trying to make a "wrapper" package for adguardhome based on the OpenWRT wiki for this package: https://openwrt.org/docs/guide-user/services/dns/adguard-home
The package would also update to the latest version during install.

I was able to do that "manually" by creating the proper postinst and prerm script and wrapping all that in an ipk archive with the "opkg-build -c" command.

However, since this is based on scripts which come from the OpenWRT wiki, I would like to put that in a public repository with GPLv2 licensing. I thought I could write a simple Makefile like the following to achieve the goal:

include $(TOPDIR)/rules.mk

PKG_NAME:=adguardhome-wrapper
PKG_VERSION:=1.0
PKG_RELEASE:=1

PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
PKG_INSTALL:=1

include $(INCLUDE_DIR)/package.mk

define Package/$(PKG_NAME)
  SECTION:=net
  CATEGORY:=Network
  TITLE:=Wrapper package for AdGuard Home with custom DHCP settings
  DEPENDS:=+adguardhome +curl
endef

define Package/$(PKG_NAME)/description
  This package is a wrapper for AdGuard Home that applies custom DHCP settings and ensures cleanup upon removal.
endef

define Build/Prepare
	mkdir -p $(PKG_BUILD_DIR)
endef

define Build/Compile
	# Nothing to compile
endef

define Package/$(PKG_NAME)/install
	$(INSTALL_DIR) $(1)/CONTROL
	$(INSTALL_BIN) ./files/postinst $(1)/CONTROL/postinst
	$(INSTALL_BIN) ./files/prerm $(1)/CONTROL/prerm
endef

$(eval $(call BuildPackage,$(PKG_NAME)))

However, when trying to build it via make package/adguardhome-wrapper/compile V=s , I am getting this error:

make[3]: Entering directory '/home/openwrt/build_dir/target-arm/adguardhome-wrapper'
make[3]: *** No rule to make target 'install'.  Stop.
make[3]: Leaving directory '/home/openwrt/build_dir/target-arm/adguardhome-wrapper'
Makefile:37: recipe for target '/home/openwrt/build_dir/target-arm/adguardhome-wrapper/.built' failed

So I guess I am doing womething wrong, but I do not know what. If there is another acceptable way of sharing the content of the script which would make the community happy, I am fine with any other method too.

You set PKG_INSTALL:=1 which causes the default build recipe to invoke a make install in the build directory which seems to fail in your case since there‘s no actual inner Makefile. Dropping the PKG_INSTALL variable should do the trick.

Thanks a lot.
I applied your recommandation. I also changed the Makefile, providing the postinst and prerm scripts directly in the Makefile and that works perfectly.
I am just providing the working Makefile in case someone else would like to achieve something similar:

include $(TOPDIR)/rules.mk

PKG_NAME:=adguardhome-wrapper
PKG_VERSION:=1.0
PKG_RELEASE:=1

PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)

include $(INCLUDE_DIR)/package.mk

define Package/$(PKG_NAME)
  SECTION:=net
  CATEGORY:=Network
  TITLE:=Wrapper package for AdGuard Home with custom DHCP settings
  DEPENDS:=+adguardhome
endef

define Package/$(PKG_NAME)/description
  This package is a wrapper for AdGuard Home that applies custom DHCP settings and ensures cleanup upon removal.
endef

define Build/Prepare
        mkdir -p $(PKG_BUILD_DIR)
endef

define Build/Compile
        # Nothing to compile
endef

define Package/$(PKG_NAME)/install
        $(INSTALL_DIR) $(1)/control
endef

define Package/$(PKG_NAME)/postinst
#!/bin/sh

curl -L -S -o '/tmp/AdGuardHome_linux_armv7.tar.gz' -s 'https://github.com/AdguardTeam/AdGuardHome/releases/download/v0.107.50/AdGuardHome_linux_armv7.tar.gz'

############################################################################
# The below script is taken from OpenWRT website at the following address: #
# https://openwrt.org/docs/guide-user/services/dns/adguard-home            #
############################################################################

# Get the first IPv4 and IPv6 Address of router and store them in following variables for use during the script.
NET_ADDR=$$(/sbin/ip -o -4 addr list br-lan | awk 'NR==1{ split($$4, ip_addr, "/"); print ip_addr[1] }')
NET_ADDR6=$$(/sbin/ip -o -6 addr list br-lan scope global | awk 'NR==1{ split($$4, ip_addr, "/"); print ip_addr[1] }')

echo "Router IPv4 : ""$${NET_ADDR}"
echo "Router IPv6 : ""$${NET_ADDR6}"

# Apply new dnsmasq and DHCP settings
uci set dhcp.@dnsmasq[0].noresolv="0"
uci set dhcp.@dnsmasq[0].cachesize="1000"
uci set dhcp.@dnsmasq[0].rebind_protection="0"
uci set dhcp.@dnsmasq[0].port="54"
uci -q delete dhcp.@dnsmasq[0].server
uci add_list dhcp.@dnsmasq[0].server="$${NET_ADDR}"

# Delete existing config ready to install new options.
uci -q delete dhcp.lan.dhcp_option
uci -q delete dhcp.lan.dns

# DHCP option 6: which DNS (Domain Name Server) to include in the IP configuration for name resolution
uci add_list dhcp.lan.dhcp_option="6,$${NET_ADDR}"

# DHCP option 3: default router or last resort gateway for this interface
uci add_list dhcp.lan.dhcp_option="3,$${NET_ADDR}"

# Set IPv6 Announced DNS
for OUTPUT in $$(ip -o -6 addr list br-lan scope global | awk '{ split($$4, ip_addr, "/"); print ip_addr[1] }')
do
    echo "Adding $$OUTPUT to IPV6 DNS"
    uci add_list dhcp.lan.dns=$$OUTPUT
done

uci commit dhcp
/etc/init.d/dnsmasq restart

# Upgrade AdGuardHome to the latest version
/etc/init.d/adguardhome stop
tar -C /tmp/ -f /tmp/AdGuardHome_linux_armv7.tar.gz -x -v -z
cp /usr/bin/AdGuardHome /root/AdGuardHome_orig
cp /tmp/AdGuardHome/AdGuardHome /usr/bin/AdGuardHome
/etc/init.d/adguardhome start
endef

define Package/$(PKG_NAME)/prerm
#!/bin/sh

############################################################################
# The below script is taken from OpenWRT website at the following address: #
# https://openwrt.org/docs/guide-user/services/dns/adguard-home            #
############################################################################

# 1. Reverts AdGuard Home configuration and resets settings to default.
# 2. Enable rebind protection.
# 3. Remove DHCP options for IPv4 and IPv6
uci -q delete dhcp.@dnsmasq[0].noresolv
uci -q delete dhcp.@dnsmasq[0].cachesize
uci set dhcp.@dnsmasq[0].rebind_protection='1'
uci -q delete dhcp.@dnsmasq[0].server
uci -q delete dhcp.@dnsmasq[0].port
uci -q delete dhcp.lan.dhcp_option
uci -q delete dhcp.lan.dns

# Network Configuration
# Disable peer/ISP DNS
uci set network.wan.peerdns="0"
uci set network.wan6.peerdns="0"

# Configure DNS provider to Google DNS
uci -q delete network.wan.dns
uci add_list network.wan.dns="8.8.8.8"
uci add_list network.wan.dns="8.8.4.4"

# Configure IPv6 DNS provider to Google DNS
uci -q delete network.wan6.dns
uci add_list network.wan6.dns="2001:4860:4860::8888"
uci add_list network.wan6.dns="2001:4860:4860::8844"

# Save and apply
uci commit dhcp
uci commit network
/etc/init.d/network restart
/etc/init.d/dnsmasq restart
/etc/init.d/odhcpd restart
endef

$(eval $(call BuildPackage,$(PKG_NAME)))

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