Skip to contentSkip to conversation

package/apache: add option to disable server

PATCH New Giulio Benetti 2 participants 2 messages Oct 1, 2023 – Nov 21

lore
Share & tools
lore
#0 lore raw

PATCH v6 1/1 package/apache: add option to disable server

From: Giulio Benetti <[email protected]>

Other packages (e.g. mongoose) can use htdigest and htpasswd, but those are only available with apache.

We don't want to build the whole apache server just for those tools, so we add an option to disable the server; it is enabled by default for legacy purposes (so that existing (def)configs still work).

However, there is no way to tell the apache buildsystem to only build those two tools, so we have to provide custom build and install commands.

Cc Jim Reinhart <[email protected]>
Cc James Autry <[email protected]>
Cc Matthew Maron <[email protected]>

---
V1->V2:
* Hide "External Apache modules" if BR2_PACKAGE_APACHE_UTILS_ONLY is enabled V2->V3:
as suggested by Arnout:
* change negative option BR2_PACKAGE_APACHE_UTILS_ONLY to BR2_PACKAGE_APACHE_DAEMON
* set a common APACHE_CONF_OPTS and only add specific options for BR2_PACKAGE_APACHE_DAEMON enabled or not
V3->V4:
* drop --with-static-* options as suggested by Arnout
V4->V5:
as suggested by Yann:
* drop BR2_PACKAGE_APACHE check in package/Config.in for package/modsecurity2/Config.in
* make BR2_PACKAGE_PHP_SAPI_APACHE depends on BR2_PACKAGE_APACHE_DAEMON
* improve commit log
V5->V6:
as suggested by Romain:
* update apparmor BR2_PACKAGE_APACHE to BR2_PACKAGE_APACHE_DAEMON

---
 package/Config.in              |  2 --
 package/apache/Config.in       |  9 +++++++++
 package/apache/apache.mk       | 20 +++++++++++++++++---
 package/apparmor/apparmor.mk   |  2 +-
 package/modsecurity2/Config.in |  2 +-
 package/php/Config.in          |  2 +-
 6 files changed, 29 insertions(+), 8 deletions(-)
package/Config.in +0 -2
index 90cfe25d05..a037fd50de 100644
@@ -2289,11 +2289,9 @@ menu "Networking applications"
 	source "package/alfred/Config.in"
 	source "package/aoetools/Config.in"
 	source "package/apache/Config.in"
-if BR2_PACKAGE_APACHE
 menu "External Apache modules"
 	source "package/modsecurity2/Config.in"
 endmenu
-endif
 	source "package/argus/Config.in"
 	source "package/arp-scan/Config.in"
 	source "package/arptables/Config.in"
package/apache/Config.in +9 -0
index 270296bce4..5e9e4c5f9d 100644
@@ -17,6 +17,14 @@ config BR2_PACKAGE_APACHE
 
 if BR2_PACKAGE_APACHE
 
+config BR2_PACKAGE_APACHE_DAEMON
+	bool "apache-daemon"
+	default y
+	help
+	  Provide entire Apache daemon, otherwise only htdigest and htpasswd
+	  will be built and installed.
+
+if BR2_PACKAGE_APACHE_DAEMON
 choice
 	prompt "Multi-Processing Module (MPM)"
 	default BR2_PACKAGE_APACHE_MPM_WORKER
@@ -40,6 +48,7 @@ config BR2_PACKAGE_APACHE_MPM_WORKER
 	  Implements a hybrid multi-threaded multi-process web server
 
 endchoice
+endif
 
 endif
 
package/apache/apache.mk +17 -3
index 320a6ad20e..994842b455 100644
@@ -12,8 +12,6 @@ APACHE_LICENSE_FILES = LICENSE
 APACHE_CPE_ID_VENDOR = apache
 APACHE_CPE_ID_PRODUCT = http_server
 APACHE_SELINUX_MODULES = apache
-# Needed for mod_php
-APACHE_INSTALL_STAGING = YES
 # We have a patch touching configure.in and Makefile.in,
 # so we need to autoreconf:
 APACHE_AUTORECONF = YES
@@ -32,10 +30,16 @@ APACHE_MPM = worker
 endif
 
 APACHE_CONF_OPTS = \
-	--sysconfdir=/etc/apache2 \
 	--with-apr=$(STAGING_DIR)/usr \
 	--with-apr-util=$(STAGING_DIR)/usr \
 	--with-pcre=$(STAGING_DIR)/usr/bin/pcre2-config \
+
+ifeq ($(BR2_PACKAGE_APACHE_DAEMON),y)
+# Needed for mod_php
+APACHE_INSTALL_STAGING = YES
+
+APACHE_CONF_OPTS += \
+	--sysconfdir=/etc/apache2 \
 	--enable-http \
 	--enable-dbd \
 	--enable-proxy \
@@ -121,5 +125,15 @@ define APACHE_INSTALL_INIT_SYSTEMD
 	$(INSTALL) -D -m 644 package/apache/apache.service \
 		$(TARGET_DIR)/usr/lib/systemd/system/apache.service
 endef
+else
+define APACHE_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/support htdigest htpasswd
+endef
+
+define APACHE_INSTALL_TARGET_CMDS
+	$(INSTALL) -m 0755 -D $(@D)/support/htdigest $(TARGET_DIR)/usr/bin/htdigest
+	$(INSTALL) -m 0755 -D $(@D)/support/htpasswd $(TARGET_DIR)/usr/bin/htpasswd
+endef
+endif
 
 $(eval $(autotools-package))
package/apparmor/apparmor.mk +1 -1
index eeedd805e6..f3ac27c5ed 100644
@@ -50,7 +50,7 @@ APPARMOR_DEPENDENCIES += linux-pam
 APPARMOR_TOOLS += changehat/pam_apparmor
 endif
 
-ifeq ($(BR2_PACKAGE_APACHE),y)
+ifeq ($(BR2_PACKAGE_APACHE_DAEMON),y)
 APPARMOR_DEPENDENCIES += apache
 APPARMOR_TOOLS += changehat/mod_apparmor
 APPARMOR_MAKE_OPTS += APXS=$(STAGING_DIR)/usr/bin/apxs
package/modsecurity2/Config.in +1 -1
index fb1bfc960e..40c5fc55bc 100644
@@ -1,6 +1,6 @@
 config BR2_PACKAGE_MODSECURITY2
 	bool "modsecurity2"
-	depends on BR2_PACKAGE_APACHE
+	depends on BR2_PACKAGE_APACHE_DAEMON
 	select BR2_PACKAGE_LIBXML2
 	select BR2_PACKAGE_PCRE2
 	help
package/php/Config.in +1 -1
index 69b4268c1d..3a9e37dab6 100644
@@ -36,7 +36,7 @@ if BR2_PACKAGE_PHP
 
 config BR2_PACKAGE_PHP_SAPI_APACHE
 	bool "Apache interface"
-	depends on BR2_PACKAGE_APACHE
+	depends on BR2_PACKAGE_APACHE_DAEMON
 	help
 	  Apache module
 
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

PATCH v7 1/1 package/apache: add option to disable server

From: Giulio Benetti <[email protected]>

Other packages (e.g. mongoose) can use htdigest and htpasswd, but those are only available with apache.

We don't want to build the whole apache server just for those tools, so we add an option to disable the server; it is enabled by default for legacy purposes (so that existing (def)configs still work).

However, there is no way to tell the apache buildsystem to only build those two tools, so we have to provide custom build and install commands.

---
Changes v6 -> v7:
- rebase on master: put the new BR2_PACKAGE_APACHE_MOD_MD option in the daemon block too, as it is a module of the server
- remove the trailing backslash after the common configure options
- wrap the help text to the Config.in line length

Changes v5 -> v6:
- update apparmor BR2_PACKAGE_APACHE to BR2_PACKAGE_APACHE_DAEMON [Romain Naour]

Changes v4 -> v5:
- drop BR2_PACKAGE_APACHE check in package/Config.in for package/modsecurity2/Config.in [Yann E. MORIN]
- make BR2_PACKAGE_PHP_SAPI_APACHE depends on BR2_PACKAGE_APACHE_DAEMON [Yann E. MORIN]
- improve commit log [Yann E. MORIN]

Changes v3 -> v4:
- drop --with-static-* options [Arnout Vandecappelle]

Changes v2 -> v3:
- change negative option BR2_PACKAGE_APACHE_UTILS_ONLY to BR2_PACKAGE_APACHE_DAEMON [Arnout Vandecappelle]
- set a common APACHE_CONF_OPTS and only add specific options for BR2_PACKAGE_APACHE_DAEMON enabled or not [Arnout Vandecappelle]

Changes v1 -> v2:
- hide "External Apache modules" if BR2_PACKAGE_APACHE_UTILS_ONLY is enabled

Supersedes v6: https://patchwork.buildroot.org/project/buildroot/patch/[email protected]/

 package/Config.in              |  2 --
 package/apache/Config.in       | 10 ++++++++++
 package/apache/apache.mk       | 22 ++++++++++++++++++----
 package/apparmor/apparmor.mk   |  2 +-
 package/modsecurity2/Config.in |  2 +-
 package/php/Config.in          |  2 +-
 6 files changed, 31 insertions(+), 9 deletions(-)
package/Config.in +0 -2
index 49659b007e..3f841c60a7 100644
@@ -2425,11 +2425,9 @@ menu "Networking applications"
 	source "package/alfred/Config.in"
 	source "package/aoetools/Config.in"
 	source "package/apache/Config.in"
-if BR2_PACKAGE_APACHE
 menu "External Apache modules"
 	source "package/modsecurity2/Config.in"
 endmenu
-endif
 	source "package/argus/Config.in"
 	source "package/arp-scan/Config.in"
 	source "package/arptables/Config.in"
package/apache/Config.in +10 -0
index 6b21428c2c..f59c387f71 100644
@@ -17,6 +17,14 @@ config BR2_PACKAGE_APACHE
 
 if BR2_PACKAGE_APACHE
 
+config BR2_PACKAGE_APACHE_DAEMON
+	bool "apache-daemon"
+	default y
+	help
+	  Provide entire Apache daemon, otherwise only htdigest and
+	  htpasswd will be built and installed.
+
+if BR2_PACKAGE_APACHE_DAEMON
 choice
 	prompt "Multi-Processing Module (MPM)"
 	default BR2_PACKAGE_APACHE_MPM_WORKER
@@ -55,6 +63,8 @@ config BR2_PACKAGE_APACHE_MOD_MD
 
 endif
 
+endif
+
 comment "apache needs a toolchain w/ dynamic library, threads"
 	depends on BR2_USE_MMU
 	depends on BR2_STATIC_LIBS || !BR2_TOOLCHAIN_HAS_THREADS
package/apache/apache.mk +18 -4
index d6ba7fa4f5..b601f08e7d 100644
@@ -12,8 +12,6 @@ APACHE_LICENSE_FILES = LICENSE
 APACHE_CPE_ID_VENDOR = apache
 APACHE_CPE_ID_PRODUCT = http_server
 APACHE_SELINUX_MODULES = apache
-# Needed for mod_php
-APACHE_INSTALL_STAGING = YES
 # We have a patch touching configure.in and Makefile.in,
 # so we need to autoreconf:
 APACHE_AUTORECONF = YES
@@ -32,10 +30,16 @@ APACHE_MPM = worker
 endif
 
 APACHE_CONF_OPTS = \
-	--sysconfdir=/etc/apache2 \
 	--with-apr=$(STAGING_DIR)/usr \
 	--with-apr-util=$(STAGING_DIR)/usr \
-	--with-pcre=$(STAGING_DIR)/usr/bin/pcre2-config \
+	--with-pcre=$(STAGING_DIR)/usr/bin/pcre2-config
+
+ifeq ($(BR2_PACKAGE_APACHE_DAEMON),y)
+# Needed for mod_php
+APACHE_INSTALL_STAGING = YES
+
+APACHE_CONF_OPTS += \
+	--sysconfdir=/etc/apache2 \
 	--enable-http \
 	--enable-dbd \
 	--enable-proxy \
@@ -134,5 +138,15 @@ define APACHE_INSTALL_INIT_SYSTEMD
 	$(INSTALL) -D -m 644 package/apache/apache.service \
 		$(TARGET_DIR)/usr/lib/systemd/system/apache.service
 endef
+else
+define APACHE_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/support htdigest htpasswd
+endef
+
+define APACHE_INSTALL_TARGET_CMDS
+	$(INSTALL) -m 0755 -D $(@D)/support/htdigest $(TARGET_DIR)/usr/bin/htdigest
+	$(INSTALL) -m 0755 -D $(@D)/support/htpasswd $(TARGET_DIR)/usr/bin/htpasswd
+endef
+endif
 
 $(eval $(autotools-package))
package/apparmor/apparmor.mk +1 -1
index ba63344bd2..9f35485c57 100644
@@ -51,7 +51,7 @@ APPARMOR_DEPENDENCIES += linux-pam
 APPARMOR_TOOLS += changehat/pam_apparmor
 endif
 
-ifeq ($(BR2_PACKAGE_APACHE),y)
+ifeq ($(BR2_PACKAGE_APACHE_DAEMON),y)
 APPARMOR_DEPENDENCIES += apache
 APPARMOR_TOOLS += changehat/mod_apparmor
 APPARMOR_MAKE_OPTS += APXS=$(STAGING_DIR)/usr/bin/apxs
package/modsecurity2/Config.in +1 -1
index df5634bf89..0538521ddc 100644
@@ -1,6 +1,6 @@
 config BR2_PACKAGE_MODSECURITY2
 	bool "modsecurity2"
-	depends on BR2_PACKAGE_APACHE
+	depends on BR2_PACKAGE_APACHE_DAEMON
 	select BR2_PACKAGE_LIBXML2
 	select BR2_PACKAGE_PCRE2
 	help
package/php/Config.in +1 -1
index af8574ac75..6c69ffa005 100644
@@ -39,7 +39,7 @@ if BR2_PACKAGE_PHP
 
 config BR2_PACKAGE_PHP_SAPI_APACHE
 	bool "Apache interface"
-	depends on BR2_PACKAGE_APACHE
+	depends on BR2_PACKAGE_APACHE_DAEMON
 	help
 	  Apache module
 
Signature · 6 lines
2.53.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot