b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | include $(TOPDIR)/rules.mk |
| 2 | |
| 3 | PKG_NAME:=nginx-util |
| 4 | PKG_VERSION:=1.6 |
| 5 | PKG_RELEASE:=1 |
| 6 | PKG_MAINTAINER:=Peter Stadler <peter.stadler@student.uibk.ac.at> |
| 7 | |
| 8 | include $(INCLUDE_DIR)/package.mk |
| 9 | include $(INCLUDE_DIR)/cmake.mk |
| 10 | |
| 11 | CMAKE_OPTIONS+= -DUBUS=y |
| 12 | CMAKE_OPTIONS+= -DVERSION=$(PKG_VERSION) |
| 13 | |
| 14 | |
| 15 | define Package/nginx-ssl-util/default |
| 16 | SECTION:=net |
| 17 | CATEGORY:=Network |
| 18 | SUBMENU:=Web Servers/Proxies |
| 19 | TITLE:=Nginx configurator including SSL |
| 20 | DEPENDS:=+libstdcpp +libuci +libubus +libubox +libpthread +libopenssl |
| 21 | # TODO: remove after a transition period (together with below and pkg nginx): |
| 22 | # It actually removes nginx-util (replacing it by a dummy pkg) to avoid |
| 23 | # conflicts with nginx-ssl-util* |
| 24 | DEPENDS+= +nginx-util |
| 25 | EXTRA_DEPENDS:=nginx-util (>=1.4-2) |
| 26 | endef |
| 27 | |
| 28 | |
| 29 | define Package/nginx-ssl-util |
| 30 | $(Package/nginx-ssl-util/default) |
| 31 | TITLE+= (using PCRE) |
| 32 | DEPENDS+= +libpcre |
| 33 | CONFLICTS:=nginx-ssl-util-nopcre, |
| 34 | endef |
| 35 | |
| 36 | |
| 37 | define Package/nginx-ssl-util-nopcre |
| 38 | $(Package/nginx-ssl-util/default) |
| 39 | TITLE+= (using <regex>) |
| 40 | CONFLICTS:=nginx-ssl-util |
| 41 | endef |
| 42 | |
| 43 | |
| 44 | define Package/nginx-ssl-util/default/description |
| 45 | Utility that builds dynamically LAN listen directives for Nginx. |
| 46 | Furthermore, it manages SSL directives for its server parts and can create |
| 47 | corresponding (self-signed) certificates. |
| 48 | endef |
| 49 | |
| 50 | |
| 51 | Package/nginx-ssl-util/description = \ |
| 52 | $(Package/nginx-ssl-util/default/description) \ |
| 53 | It uses the PCRE library for performance. |
| 54 | |
| 55 | |
| 56 | Package/nginx-ssl-util-nopcre/description = \ |
| 57 | $(Package/nginx-ssl-util/default/description) \ |
| 58 | It uses the standard regex library of C++. |
| 59 | |
| 60 | |
| 61 | define Package/nginx-ssl-util/install/default |
| 62 | $(INSTALL_DIR) $(1)/etc/nginx/conf.d/ |
| 63 | |
| 64 | $(INSTALL_CONF) ./files/uci.conf.template $(1)/etc/nginx/ |
| 65 | $(LN) /var/lib/nginx/uci.conf $(1)/etc/nginx/uci.conf |
| 66 | |
| 67 | $(INSTALL_CONF) ./files/restrict_locally $(1)/etc/nginx/ |
| 68 | |
| 69 | $(INSTALL_DIR) $(1)/etc/config/ |
| 70 | $(INSTALL_CONF) ./files/nginx.config $(1)/etc/config/nginx |
| 71 | |
| 72 | ifneq ($(CONFIG_IPV6),y) # the used IPv6 directives have `::` in them: |
| 73 | $(SED) "/::/d" $(1)/etc/nginx/restrict_locally |
| 74 | $(SED) "/::/d" $(1)/etc/config/nginx |
| 75 | endif |
| 76 | endef |
| 77 | |
| 78 | |
| 79 | define Package/nginx-ssl-util/install |
| 80 | $(call Package/nginx-ssl-util/install/default, $(1)) |
| 81 | $(INSTALL_DIR) $(1)/usr/bin |
| 82 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/nginx-ssl-util $(1)/usr/bin/nginx-util |
| 83 | endef |
| 84 | |
| 85 | |
| 86 | define Package/nginx-ssl-util-nopcre/install |
| 87 | $(call Package/nginx-ssl-util/install/default, $(1)) |
| 88 | $(INSTALL_DIR) $(1)/usr/bin |
| 89 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/nginx-ssl-util-nopcre \ |
| 90 | $(1)/usr/bin/nginx-util |
| 91 | endef |
| 92 | |
| 93 | |
| 94 | define Package/nginx-ssl-util/prerm |
| 95 | #!/bin/sh |
| 96 | |
| 97 | [ -n "$${IPKG_INSTROOT}" ] && exit 0 |
| 98 | [ "$${PKG_UPGRADE}" = "1" ] && exit 0 |
| 99 | case "$$(/sbin/uci get "nginx.global.uci_enable" 2>/dev/null)" in |
| 100 | 1|on|true|yes|enabled) ;; |
| 101 | *) exit 0;; |
| 102 | esac |
| 103 | |
| 104 | eval "$$(/usr/bin/nginx-util get_env)" && |
| 105 | [ "$$(/sbin/uci get "nginx.$${LAN_NAME}.$${MANAGE_SSL}" 2>/dev/null)" = \ |
| 106 | "self-signed" ] && |
| 107 | cd "/etc/nginx" && |
| 108 | rm -f "$$(/sbin/uci get "nginx.$${LAN_NAME}.ssl_certificate")" \ |
| 109 | "$$(/sbin/uci get "nginx.$${LAN_NAME}.ssl_certificate_key")" |
| 110 | |
| 111 | exit 0 |
| 112 | endef |
| 113 | |
| 114 | |
| 115 | Package/nginx-ssl-util-nopcre/prerm = $(Package/nginx-ssl-util/prerm) |
| 116 | |
| 117 | |
| 118 | $(eval $(call BuildPackage,nginx-ssl-util)) |
| 119 | $(eval $(call BuildPackage,nginx-ssl-util-nopcre)) |
| 120 | |
| 121 | |
| 122 | # TODO: remove after a transition period (together with above and pkg nginx): |
| 123 | # It replaces nginx-util by a dummy pkg for a smooth upgrade of nginx* |
| 124 | |
| 125 | define Package/nginx-util |
| 126 | TITLE:=Dummy package for removing nginx-util when upgrading. |
| 127 | DEPENDS:=+libstdcpp +libubus +libubox +libpthread |
| 128 | PKGARCH:=all |
| 129 | endef |
| 130 | |
| 131 | define Package/nginx-util/install |
| 132 | $(INSTALL_DIR) $(1)/usr/bin |
| 133 | endef |
| 134 | |
| 135 | $(eval $(call BuildPackage,nginx-util)) |