blob: 13354679822e92819507fa77454adf7beab573ec [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001#
2# Copyright (C) 2012-2014 OpenWrt.org
3#
4# This is free software, licensed under the GNU General Public License v2.
5# See /LICENSE for more information.
6
7include $(TOPDIR)/rules.mk
8
9PKG_NAME:=hnetd
10PKG_SOURCE_DATE:=2018-12-21
11PKG_SOURCE_VERSION:=c43766610ed30194b048bc070a3c433aec731c40
12PKG_RELEASE:=1
13
14PKG_SOURCE_PROTO:=git
15PKG_SOURCE_URL:=https://github.com/sbyx/hnetd
16PKG_MIRROR_HASH:=a41baa2e3d7930cc88073b0b3f6e1fa6a4abd9fd663f2577cfde1564fa07f8f2
17
18PKG_MAINTAINER:=Steven Barth <cyrus@openwrt.org>
19PKG_LICENSE:=GPL-2.0-only
20PKG_LICENSE_FILES:=LICENSE
21
22PKG_BUILD_PARALLEL:=1
23
24include $(INCLUDE_DIR)/package.mk
25include $(INCLUDE_DIR)/cmake.mk
26
27# Spammy debug builds for now
28CMAKE_OPTIONS += -DL_LEVEL=7
29
30# OpenWRT target
31CMAKE_OPTIONS += -DBACKEND=openwrt
32
33ifeq ($(BUILD_VARIANT),openssl)
34CMAKE_OPTIONS += -DDTLS_OPENSSL=1
35endif
36
37define Package/hnetd/Default
38 SECTION:=net
39 CATEGORY:=Network
40 TITLE:=HNCP Homenet daemon - $(2)
41 URL:=https://github.com/sbyx/hnetd
42 DEPENDS:=+odhcpd +odhcp6c +netifd $(3)
43 DEPENDS+=@IPV6
44 VARIANT:=$1
45endef
46
47Package/hnetd-nossl=$(call Package/hnetd/Default,nossl,no authentication)
48Package/hnetd-openssl=$(call Package/hnetd/Default,openssl,authentication via OpenSSL,+libopenssl)
49
50define Package/hnet-full
51 SECTION:=net
52 CATEGORY:=Network
53 TITLE:=HNCP Homenet metapackage
54 URL:=https://github.com/sbyx/hnetd
55 DEPENDS:=+hnetd-nossl +luci-app-hnet +ip
56 # Routing
57 DEPENDS+=+babeld
58 # Service discovery
59 DEPENDS+=+ohybridproxy +zonestitcher
60 # Distributed PCP support
61 DEPENDS+=+miniupnpd +minimalist-pcproxy
62endef
63
64define Package/hnet-full-secure
65 SECTION:=net
66 CATEGORY:=Network
67 TITLE:=HNCP Homenet metapackage (w/ SSL)
68 URL:=https://github.com/sbyx/hnetd
69 DEPENDS:=+hnetd-openssl +luci-app-hnet +ip
70 # Routing
71 DEPENDS+=+babeld
72 # Service discovery
73 DEPENDS+=+ohybridproxy +zonestitcher
74 # Distributed PCP support
75 DEPENDS+=+miniupnpd +minimalist-pcproxy
76endef
77
78define Package/hnet-full-l2tp
79 SECTION:=net
80 CATEGORY:=Network
81 TITLE:=HNCP Homenet metapackage (w/ L2TP)
82 URL:=https://github.com/sbyx/hnetd
83 DEPENDS:=+hnetd-nossl +luci-app-hnet +ip-full +kmod-l2tp-eth
84 # Routing
85 DEPENDS+=+babeld
86 # Service discovery
87 DEPENDS+=+ohybridproxy +zonestitcher
88 # Distributed PCP support
89 DEPENDS+=+miniupnpd +minimalist-pcproxy
90endef
91
92define Package/luci-app-hnet
93 SECTION:=luci
94 CATEGORY:=LuCI
95 SUBMENU:=3. Applications
96 TITLE:=HNCP Homenet configuration and visualization
97# DEPENDS:=+hnetd
98# TBD - how to express dependency on 'some' hnetd?
99endef
100
101define Package/hnetd-$(BUILD_VARIANT)/description
102This package provides a daemon which implementats distributed prefix assignment
103and service discovery for a home network consisting of multiple routers
104connected to multiple service providers. It provides a netifd protocol "hnet"
105for use in /etc/config/network.
106endef
107
108define Package/hnetd-$(BUILD_VARIANT)/install
109 $(INSTALL_DIR) $(1)/usr/sbin/
110 $(INSTALL_BIN) $(PKG_BUILD_DIR)/hnetd $(1)/usr/sbin/
111 $(INSTALL_DIR) $(1)/lib/netifd/proto
112 $(INSTALL_BIN) $(PKG_BUILD_DIR)/openwrt/hnet.sh $(1)/lib/netifd/proto
113 ln -s hnetd $(1)/usr/sbin/hnet-ifresolve
114 ln -s hnetd $(1)/usr/sbin/hnet-trust
115 ln -s hnetd $(1)/usr/sbin/hnet-dump
116 $(INSTALL_DIR) $(1)/etc/init.d
117 $(INSTALL_BIN) ./files/hnetd.init $(1)/etc/init.d/hnetd
118 $(INSTALL_DIR) $(1)/etc/config
119 $(INSTALL_DATA) ./files/hnet.config $(1)/etc/config/hnet
120 $(INSTALL_BIN) $(PKG_BUILD_DIR)/generic/ohp.script $(1)/usr/sbin/hnetd-ohp-script
121 $(INSTALL_BIN) $(PKG_BUILD_DIR)/generic/ddz.script $(1)/usr/sbin/hnetd-ddz-script
122 $(INSTALL_BIN) $(PKG_BUILD_DIR)/generic/pcp.script $(1)/usr/sbin/hnetd-pcp-script
123 $(INSTALL_BIN) $(PKG_BUILD_DIR)/generic/hnetd-routing $(1)/usr/sbin/hnetd-routing
124 $(INSTALL_DIR) $(1)/etc/uci-defaults
125 $(INSTALL_BIN) ./files/hnetd.defaults $(1)/etc/uci-defaults/x-hnetd.defaults
126 $(INSTALL_BIN) $(PKG_BUILD_DIR)/generic/multicast.script $(1)/usr/sbin/hnet-multicast
127 $(INSTALL_BIN) $(PKG_BUILD_DIR)/openwrt/autowifi.script $(1)/usr/sbin/autowifi
128endef
129
130define Package/hnet-full/install
131 true
132endef
133
134define Package/hnet-full-secure/install
135 true
136endef
137
138define Package/hnet-full-l2tp/install
139 $(INSTALL_DIR) $(1)/usr/sbin/
140 $(INSTALL_BIN) $(PKG_BUILD_DIR)/generic/tunnel.script $(1)/usr/sbin/hnetd-tunnel
141endef
142
143define Package/luci-app-hnet/install
144 $(INSTALL_DIR) $(1)/usr/lib/lua/luci
145 $(INSTALL_DIR) $(1)/www
146 $(CP) -R $(PKG_BUILD_DIR)/openwrt/luci/luasrc/* $(1)/usr/lib/lua/luci/
147 $(CP) -R $(PKG_BUILD_DIR)/openwrt/luci/htdocs/* $(1)/www/
148endef
149
150define Package/hnetd-$(BUILD_VARIANT)/postinst
151#!/bin/sh
152[ -n "$${IPKG_INSTROOT}" ] || {
153 (. /etc/uci-defaults/x-hnetd.defaults) && rm -f /etc/uci-defaults/x-hnetd.defaults
154 [ -x /etc/init.d/dnsmasq ] && /etc/init.d/dnsmasq restart
155 /etc/init.d/hnetd enable
156 /etc/init.d/hnetd start
157}
158endef
159
160$(eval $(call BuildPackage,hnetd-nossl))
161$(eval $(call BuildPackage,hnetd-openssl))
162$(eval $(call BuildPackage,hnet-full))
163$(eval $(call BuildPackage,hnet-full-secure))
164$(eval $(call BuildPackage,hnet-full-l2tp))
165$(eval $(call BuildPackage,luci-app-hnet))