Skip to contentSkip to conversation

package/apache: add option BR2_PACKAGE_APACHE_DAEMON

PATCH Superseded Giulio Benetti 2 participants 3 messages Sep 21, 2023 – Sep 22, 2023

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 package/apache: add option BR2_PACKAGE_APACHE_DAEMON

From: Giulio Benetti <[email protected]>

With option BR2_PACKAGE_APACHE_DAEMON disabled only htdigest and htpasswd are built and installed. By default BR2_PACKAGE_APACHE_DAEMON is enabled and entire apache daemon is built. This is useful for Mongoose credentials handling.

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

---
 package/Config.in        |  2 +-
 package/apache/Config.in |  9 +++++++++
 package/apache/apache.mk | 24 +++++++++++++++++++++---
 3 files changed, 31 insertions(+), 4 deletions(-)
package/Config.in +1 -1
index e8dbadadf3..aa5e9b5a98 100644
@@ -2278,7 +2278,7 @@ menu "Networking applications"
 	source "package/alfred/Config.in"
 	source "package/aoetools/Config.in"
 	source "package/apache/Config.in"
-if BR2_PACKAGE_APACHE
+if BR2_PACKAGE_APACHE_DAEMON
 menu "External Apache modules"
 	source "package/modsecurity2/Config.in"
 endmenu
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 +21 -3
index 320a6ad20e..83df3854a3 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,19 @@ define APACHE_INSTALL_INIT_SYSTEMD
 	$(INSTALL) -D -m 644 package/apache/apache.service \
 		$(TARGET_DIR)/usr/lib/systemd/system/apache.service
 endef
+else
+APACHE_CONF_OPTS += \
+	--with-static-htdigest \
+	--with-static-htpasswd
+
+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))
Signature · 6 lines
2.34.1

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

Giulio, All,

TBH, I am not too fond of this two-in-one package... :-( However, it is not that ugly, so let's give it a look. See below...

On 2023-09-21 21:31 +0200, Giulio Benetti spake thusly:

Quoted 23 lines

From: Giulio Benetti <[email protected]> With option BR2_PACKAGE_APACHE_DAEMON disabled only htdigest and htpasswd are built and installed. By default BR2_PACKAGE_APACHE_DAEMON is enabled and entire apache daemon is built. This is useful for Mongoose credentials handling.

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

package/Config.in +0 -0
index e8dbadadf3..aa5e9b5a98 100644

package/Config.in menu "Networking applications" · line 2283

Quoted 7 lines
package/Config.in +1 -1
@@ -2278,7 +2278,7 @@  menu "Networking applications"
 	source "package/alfred/Config.in"
 	source "package/aoetools/Config.in"
 	source "package/apache/Config.in"
-if BR2_PACKAGE_APACHE
+if BR2_PACKAGE_APACHE_DAEMON
 menu "External Apache modules"
 	source "package/modsecurity2/Config.in"

package/modsecurity2/Config.in also has a redundant dependency on BR2_PACKAGE_APACHE, which is now even less relevant.

package/apache/Config.in config BR2_PACKAGE_APACHE · line 20

Quoted 11 lines
package/Config.in +0 -0
 endmenu
package/apache/Config.in +1 -0
index 270296bce4..5e9e4c5f9d 100644
@@ -17,6 +17,14 @@ config BR2_PACKAGE_APACHE
 
 if BR2_PACKAGE_APACHE
 
+config BR2_PACKAGE_APACHE_DAEMON

This new config... [0]

[--SNIP--]

package/apache/apache.mk

Quoted 4 lines
package/apache/apache.mk +0 -0
index 320a6ad20e..83df3854a3 100644

[--SNIP--]

package/apache/apache.mk APACHE_MPM = worker · line 39

Quoted 12 lines
package/apache/apache.mk +4 -1
@@ -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

[0] ... means that BR2_PACKAGE_PHP_SAPI_APACHE will have to be made dependent on it rather than on plain BR2_PACKAGE_APACHE.

Beside modsecurity2 and php, there are no other package that refer to apache;

    $ git grep -E '(select|depends on) BR2_PACKAGE_APACHE'
    package/modsecurity2/Config.in: depends on BR2_PACKAGE_APACHE
    package/php/Config.in:  depends on BR2_PACKAGE_APACHE

package/apache/apache.mk define APACHE_INSTALL_INIT_SYSTEMD · line 131

Quoted 13 lines
package/apache/apache.mk +6 -0
+APACHE_CONF_OPTS += \
+	--sysconfdir=/etc/apache2 \
 	--enable-http \
 	--enable-dbd \
 	--enable-proxy \
@@ -121,5 +125,19 @@ define APACHE_INSTALL_INIT_SYSTEMD
 	$(INSTALL) -D -m 644 package/apache/apache.service \
 		$(TARGET_DIR)/usr/lib/systemd/system/apache.service
 endef
+else
+APACHE_CONF_OPTS += \
+	--with-static-htdigest \
+	--with-static-htpasswd

Why don't you --disable-http --disable-dbd and so on?

package/apache/apache.mk define APACHE_INSTALL_INIT_SYSTEMD · line 134

Quoted 2 lines
package/apache/apache.mk +2 -0
+define APACHE_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/support htdigest htpasswd

If it is possible to properly disable everything else, then we would not need custom commands, neither for build...

package/apache/apache.mk define APACHE_INSTALL_INIT_SYSTEMD · line 140

Quoted 6 lines
package/apache/apache.mk +6 -0
+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

... nor for install.

And thus this would look less than two-packages-in-one, and more like how we handle libcurl, so that would be even better.

Regards,
Yann E. MORIN.

Quoted 10 lines
package/apache/apache.mk +1 -0
+endif
 
 $(eval $(autotools-package))
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw

Hi Yann, All,

Quoted 31 lines · Yann E. MORIN

Giulio, All,

TBH, I am not too fond of this two-in-one package... :-( However, it is not that ugly, so let's give it a look. See below...

On 2023-09-21 21:31 +0200, Giulio Benetti spake thusly:

Quoted 25 lines

From: Giulio Benetti <[email protected]> With option BR2_PACKAGE_APACHE_DAEMON disabled only htdigest and htpasswd are built and installed. By default BR2_PACKAGE_APACHE_DAEMON is enabled and entire apache daemon is built. This is useful for Mongoose credentials handling.

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

package/Config.in +0 -0
index e8dbadadf3..aa5e9b5a98 100644
@@ -2278,7 +2278,7 @@  menu "Networking applications"
  	source "package/alfred/Config.in"
  	source "package/aoetools/Config.in"
Quoted 8 lines

package/Config.in menu "Networking applications" · line 2283

Quoted 5 lines
package/Config.in +1 -1
  	source "package/apache/Config.in"
-if BR2_PACKAGE_APACHE
+if BR2_PACKAGE_APACHE_DAEMON
  menu "External Apache modules"
  	source "package/modsecurity2/Config.in"

package/modsecurity2/Config.in also has a redundant dependency on BR2_PACKAGE_APACHE, which is now even less relevant.

you're right, so I remove it,

Quoted 23 lines

package/apache/Config.in config BR2_PACKAGE_APACHE · line 20

Quoted 11 lines
package/Config.in +0 -0
  endmenu
package/apache/Config.in +1 -0
index 270296bce4..5e9e4c5f9d 100644
@@ -17,6 +17,14 @@ config BR2_PACKAGE_APACHE
 
  if BR2_PACKAGE_APACHE
 
+config BR2_PACKAGE_APACHE_DAEMON

This new config... [0]

[--SNIP--]

package/apache/apache.mk

Quoted 4 lines
package/apache/apache.mk +0 -0
index 320a6ad20e..83df3854a3 100644

[--SNIP--]

Quoted 3 lines
package/apache/apache.mk +0 -0
@@ -32,10 +30,16 @@ APACHE_MPM = worker
  endif
 
Quoted 12 lines

package/apache/apache.mk APACHE_MPM = worker · line 39

Quoted 9 lines
package/apache/apache.mk +4 -1
  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

[0] ... means that BR2_PACKAGE_PHP_SAPI_APACHE will have to be made dependent on it rather than on plain BR2_PACKAGE_APACHE.

going to change it,

Quoted 29 lines

Beside modsecurity2 and php, there are no other package that refer to apache;

     $ git grep -E '(select|depends on) BR2_PACKAGE_APACHE'
     package/modsecurity2/Config.in: depends on BR2_PACKAGE_APACHE
     package/php/Config.in:  depends on BR2_PACKAGE_APACHE

package/apache/apache.mk define APACHE_INSTALL_INIT_SYSTEMD · line 131

Quoted 13 lines
package/apache/apache.mk +6 -0
+APACHE_CONF_OPTS += \
+	--sysconfdir=/etc/apache2 \
  	--enable-http \
  	--enable-dbd \
  	--enable-proxy \
@@ -121,5 +125,19 @@ define APACHE_INSTALL_INIT_SYSTEMD
  	$(INSTALL) -D -m 644 package/apache/apache.service \
  		$(TARGET_DIR)/usr/lib/systemd/system/apache.service
  endef
+else
+APACHE_CONF_OPTS += \
+	--with-static-htdigest \
+	--with-static-htpasswd

Why don't you --disable-http --disable-dbd and so on?

package/apache/apache.mk define APACHE_INSTALL_INIT_SYSTEMD · line 134

Quoted 2 lines
package/apache/apache.mk +2 -0
+define APACHE_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/support htdigest htpasswd

If it is possible to properly disable everything else, then we would not need custom commands, neither for build...

Quoted 8 lines

package/apache/apache.mk define APACHE_INSTALL_INIT_SYSTEMD · line 140

Quoted 6 lines
package/apache/apache.mk +6 -0
+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

... nor for install.

Unfortunately after many tries I've seen that httpd is always built using autotools, that's why I've end up using a custom build

Thank you for the review and
Best regards

Signature · 6 lines
Giulio Benetti
CEO&CTO@Benetti Engineering sas
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot