Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] package/postfix: add postfix 3.11.4 package
@ 2026-07-01 17:16 Love Fogelström
  2026-08-16 17:29 ` Thomas Petazzoni via buildroot
  0 siblings, 1 reply; 2+ messages in thread
From: Love Fogelström @ 2026-07-01 17:16 UTC (permalink / raw)
  To: buildroot; +Cc: Love Fogelström, Thomas Petazzoni, ljfogelstrom

From: ljfogelstrom <ljfogelstrom@protonmail.com>

Signed-off-by: ljfogelstrom <ljfogelstrom@protonmail.com>
---
 DEVELOPERS                                   |   3 +
 package/Config.in                            |   1 +
 package/postfix/0001-makedefs.patch          | 203 +++++++++++++++++++
 package/postfix/Config.in                    |  27 +++
 package/postfix/init/systemd/postfix.service |  26 +++
 package/postfix/init/sysv/S51postfix         |  45 ++++
 package/postfix/postfix.mk                   |  94 +++++++++
 7 files changed, 399 insertions(+)
 create mode 100644 package/postfix/0001-makedefs.patch
 create mode 100644 package/postfix/Config.in
 create mode 100644 package/postfix/init/systemd/postfix.service
 create mode 100644 package/postfix/init/sysv/S51postfix
 create mode 100644 package/postfix/postfix.mk

diff --git a/DEVELOPERS b/DEVELOPERS
index 5a09be9bff..3992e9012d 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -2160,6 +2160,9 @@ F:	package/python-huepy/
 F:	package/python-tqdm/
 F:	package/rtl8189es/
 
+N:	Love Fogelström <ljfogelstrom@protonmail.com>
+F:	package/postfix/
+
 N:	Luca Ceresoli <luca.ceresoli@bootlin.com>
 F:	board/olimex/a20_olinuxino/
 F:	board/zynq/
diff --git a/package/Config.in b/package/Config.in
index 27f61ca7bc..3f701c23ff 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -2352,6 +2352,7 @@ menu "Mail"
 	source "package/libesmtp/Config.in"
 	source "package/msmtp/Config.in"
 	source "package/mutt/Config.in"
+	source "package/postfix/Config.in"
 endmenu
 
 menu "Miscellaneous"
diff --git a/package/postfix/0001-makedefs.patch b/package/postfix/0001-makedefs.patch
new file mode 100644
index 0000000000..f54e98d982
--- /dev/null
+++ b/package/postfix/0001-makedefs.patch
@@ -0,0 +1,203 @@
+From a0cf1c49eb846a55d014ae91c24810c340e4e85a Mon Sep 17 00:00:00 2001
+From: ljfogelstrom <ljfogelstrom@protonmail.com>
+Date: Thu, 25 Jun 2026 11:56:40 +0200
+Subject: [PATCH] makedefs+install
+
+Signed-off-by: ljfogelstrom <ljfogelstrom@protonmail.com>
+---
+ Makefile.in     |  2 +-
+ makedefs        | 57 ++++++-------------------------------------------
+ postfix-install | 54 +++++++++++++++++++++++-----------------------
+ 3 files changed, 35 insertions(+), 78 deletions(-)
+
+diff --git a/Makefile.in b/Makefile.in
+index 8d7501a..550462f 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -31,7 +31,7 @@ default: update
+ # setting directly from the latest makedefs.out result.
+ 
+ makefiles Makefiles conf/makedefs.out:
+-	(echo "# Do not edit -- this file documents how Postfix was built for your machine."; $(SHELL) makedefs) >makedefs.tmp
++	(echo "# Do not edit -- this file documents how Postfix was built for your machine."; $(SHELL) makedefs Linux $(pf_linux_release)) >makedefs.tmp
+ 	set +e; if cmp makedefs.tmp conf/makedefs.out; then rm makedefs.tmp; \
+ 	else mv makedefs.tmp conf/makedefs.out; fi >/dev/null 2>/dev/null
+ 	set -e; for i in $(DIRS); do \
+diff --git a/makedefs b/makedefs
+index d5103ce..d21ad06 100644
+--- a/makedefs
++++ b/makedefs
+@@ -877,53 +877,8 @@ esac
+ # if used wisely (that is: almost never, just like signals).
+ # Unfortunately some implementations have been buggy in the past.
+ #
+-case "$CCARGS" in
+- *-DNO_SIGSETJMP*) ;;
+-		*) trap 'rm -f makedefs.test makedefs.test.[co]' 1 2 3 15
+-		   cat >makedefs.test.c <<'EOF'
+-#include <setjmp.h>
+-#include <stdlib.h>
+-#include <stdio.h>
+-
+-static int count = 0;
+-
+-int     main(int argc, char **argv)
+-{
+-    sigjmp_buf env;
+-    int     retval;
+-
+-    switch (retval = sigsetjmp(env, 1)) {
+-    case 0:
+-	siglongjmp(env, 12345);
+-    case 12345:
+-	break;
+-    default:
+-	fprintf(stderr, "Error: siglongjmp ignores second argument\n");
+-	exit(1);
+-    }
+ 
+-    switch (retval = sigsetjmp(env, 1)) {
+-    case 0:
+-	if (count++ > 0) {
+-	    fprintf(stderr, "Error: not overriding siglongjmp(env, 0)\n");
+-	    exit(1);
+-	}
+-	siglongjmp(env, 0);
+-    case 1:
+-	break;
+-    default:
+-	fprintf(stderr, "Error: overriding siglongjmp(env, 0) with %d\n",
+-		retval);
+-	exit(1);
+-    }
+-    exit(0);
+-}
+-EOF
+-		   ${CC-gcc} -o makedefs.test makedefs.test.c || exit 1
+-		   ./makedefs.test 2>/dev/null ||
+-			CCARGS="$CCARGS -DNO_SIGSETJMP"
+-		   rm -f makedefs.test makedefs.test.[co]
+-esac
++# BUILDROOT: we assume sig*jmp() is working correctly
+ 
+ #
+ # Look for the ICU library and enable unicode email if available.
+@@ -957,9 +912,9 @@ int main(int argc, char **argv)
+ 				  &error) != 14);
+ }
+ EOF
+-		    ${CC-gcc} -o makedefs.test makedefs.test.c $icu_cppflags \
++		    if ${CC-gcc} -o makedefs.test makedefs.test.c $icu_cppflags \
+ 			$icu_ldflags >/dev/null 2>&1
+-		    if ./makedefs.test 2>/dev/null ; then
++                    then # BUILDROOT: only check if compilation is successful
+ 			CCARGS="$CCARGS $icu_cppflags"
+ 			SYSLIBS="$SYSLIBS $icu_ldflags"
+ 		    else
+@@ -1093,7 +1048,8 @@ int     main(void)
+     exit(ferror(stdout) ? 1 : 0);
+ }
+ EOF
+-    eval ${CC-gcc} ${CCARGS} -o makedefs.test makedefs.test.c || exit 1
++    eval gcc ${CCARGS} -o makedefs.test makedefs.test.c 2>/dev/null || exit 1
++    # BUILDROOT: use host gcc
+     ./makedefs.test || exit 1
+     rm -f makedefs.test makedefs.test.[co]
+ }
+@@ -1250,7 +1206,8 @@ int     main(void)
+     exit(ferror(stdout) ? 1 : 0);
+ }
+ EOF
+-	eval ${CC-gcc} ${CCARGS} -o makedefs.test makedefs.test.c || exit 1
++	eval gcc ${CCARGS} -o makedefs.test makedefs.test.c 2>/dev/null || exit 1
++        # BUILDROOT: use host gcc
+ 	parm_val=`./makedefs.test` || exit 1
+ 	rm -f makedefs.test makedefs.test.[co]
+ 	eval ${parm_name}=\""\$parm_val"\"
+diff --git a/postfix-install b/postfix-install
+index 563ee27..b32e5e5 100644
+--- a/postfix-install
++++ b/postfix-install
+@@ -518,6 +518,12 @@ grep setgid_group $CONFIG_DIRECTORY/main.cf >/dev/null 2>&1 || {
+ 
+ # Extract parameter settings from the installed main.cf file.
+ 
++# BUILDROOT: this function should be sufficient for single line settings
++# such as paths
++br_get_params() {
++    grep -E -m 1 "^$1" $CONFIG_DIRECTORY/main.cf | sed -E "s/^$1 ?= ?//"
++}
++
+ test -f $CONFIG_DIRECTORY/main.cf && {
+     for name in $CONFIG_PARAMS sample_directory
+     do
+@@ -525,21 +531,23 @@ test -f $CONFIG_DIRECTORY/main.cf && {
+ 	case "$junk" in
+ 	"") eval unset $name;;
+ 	esac
+-	eval : \${$name=\`bin/postconf -qc $CONFIG_DIRECTORY -hx $name\`} ||
++	eval : \${$name=\`br_get_params $name\`} ||
+ 	    exit 1
+     done
+ }
+ 
+ # Use built-in defaults as the final source of parameter settings.
+-
+-for name in $CONFIG_PARAMS sample_directory
+-do
+-    eval junk=\$$name
+-    case "$junk" in
+-    "") eval unset $name;;
+-    esac
+-    eval : \${$name=\`bin/postconf -c conf -d -hx $name\`} || exit 1
+-done
++# BUILDROOT: this check is redundant as we have already supplied the
++# defaults on the command line
++#
++# for name in $CONFIG_PARAMS sample_directory
++# do
++#     eval junk=\$$name
++#     case "$junk" in
++#     "") eval unset $name;;
++#     esac
++#     eval : \${$name=\`bin/postconf -c conf -d -hx $name\`} || exit 1
++# done
+ 
+ # Override settings manually.
+ 
+@@ -866,23 +874,15 @@ do
+     esac
+ done
+ 
+-bin/postconf -qc $CONFIG_DIRECTORY -e \
+-    "daemon_directory = $daemon_directory" \
+-    "data_directory = $data_directory" \
+-    "command_directory = $command_directory" \
+-    "queue_directory = $queue_directory" \
+-    "mail_owner = $mail_owner" \
+-    "setgid_group = $setgid_group" \
+-    "sendmail_path = $sendmail_path" \
+-    "mailq_path = $mailq_path" \
+-    "newaliases_path = $newaliases_path" \
+-    "html_directory = $html_directory" \
+-    "manpage_directory = $manpage_directory" \
+-    "sample_directory = $sample_directory" \
+-    "readme_directory = $readme_directory" \
+-    "shlib_directory = $shlib_directory" \
+-    "meta_directory = $meta_directory" \
+-|| exit 1
++# bin/postconf -qc $CONFIG_DIRECTORY -e \
++# BUILDROOT: try to emulate bin/postconf
++cp -a $CONFIG_DIRECTORY/main.cf.proto $CONFIG_DIRECTORY/main.cf
++for name in $CONFIG_PARAMS
++do
++    val=$(eval "echo \$$name")
++    sed -Ei "s,^$name.*$,$name = $val," \
++	$CONFIG_DIRECTORY/main.cf || echo "$name not found in main.cf"
++done
+ 
+ # If Postfix is being installed locally from source code, do the
+ # post-install processing now.
+-- 
+2.53.0
+
diff --git a/package/postfix/Config.in b/package/postfix/Config.in
new file mode 100644
index 0000000000..9305ce09cc
--- /dev/null
+++ b/package/postfix/Config.in
@@ -0,0 +1,27 @@
+config BR2_PACKAGE_POSTFIX
+	bool "postfix"
+	depends on BR2_USE_MMU
+	select BR2_PACKAGE_BERKELEYDB
+	select BR2_PACKAGE_PCRE2
+	help
+	  Postfix Mail Transfer Agent
+
+	   http://postfix.org
+
+if BR2_PACKAGE_POSTFIX
+
+	config BR2_PACKAGE_POSTFIX_ICU
+		bool "UTF-8 support"
+		select BR2_PACKAGE_ICU
+		help
+		  Enable support for SMTPUTF8 with the ICU library
+		  which allows international characters
+		  in email addresses and headers.
+	comment "icu needs a toolchain w/ C++, wchar, threads, gcc >= 7, host gcc >= 7"
+		depends on !BR2_BINFMT_FLAT
+		depends on !BR2_INSTALL_LIBSTDCPP || !BR2_USE_WCHAR || \
+			!BR2_TOOLCHAIN_HAS_THREADS || \
+			!BR2_TOOLCHAIN_GCC_AT_LEAST_7 || \
+			!BR2_HOST_GCC_AT_LEAST_7
+
+endif
diff --git a/package/postfix/init/systemd/postfix.service b/package/postfix/init/systemd/postfix.service
new file mode 100644
index 0000000000..7a72aaa8e5
--- /dev/null
+++ b/package/postfix/init/systemd/postfix.service
@@ -0,0 +1,26 @@
+[Unit]
+Description=Postfix Mail Transport Agent
+After=network.target
+
+[Service]
+Type=forking
+ExecStartPre=-/usr/bin/newaliases
+ExecStart=/usr/sbin/postfix start
+ExecStop=/usr/sbin/postfix stop
+ExecReload=/usr/sbin/postfix reload
+# Hardening
+PrivateTmp=yes
+PrivateDevices=yes
+ProtectSystem=full
+ReadWritePaths=-/etc/mail/aliases.db -/etc/mail/aliases.cdb -/etc/mail/aliases.lmdb
+CapabilityBoundingSet=~ CAP_NET_ADMIN CAP_SYS_ADMIN CAP_SYS_BOOT CAP_SYS_MODULE
+MemoryDenyWriteExecute=true
+ProtectKernelModules=true
+ProtectKernelTunables=true
+ProtectControlGroups=true
+RestrictAddressFamilies=AF_INET AF_INET6 AF_NETLINK AF_UNIX
+RestrictNamespaces=true
+RestrictRealtime=true
+
+[Install]
+WantedBy=multi-user.target
diff --git a/package/postfix/init/sysv/S51postfix b/package/postfix/init/sysv/S51postfix
new file mode 100644
index 0000000000..d3e6d61648
--- /dev/null
+++ b/package/postfix/init/sysv/S51postfix
@@ -0,0 +1,45 @@
+#!/bin/sh
+
+PIDFILE=/var/spool/postfix/pid/master.pid
+DAEMON=/sbin/postfix
+
+start() {
+    echo -n "Starting Postfix: "
+
+    start-stop-daemon --exec "$DAEMON" --start --background \
+		--pidfile "$PIDFILE" -- "start"
+
+    status=$?
+    if [ $status -eq 0 ]; then
+		echo "OK"
+    else
+		echo "FAIL"
+    fi
+    return $status
+}
+
+stop() {
+    echo -n "Stopping Postfix: "
+    start-stop-daemon --pidfile "$PIDFILE" \
+		--exec "$DAEMON" -- "stop"
+    status=$?
+    if [ $status -eq 0 ]; then
+		echo "OK"
+    else
+		echo "FAIL"
+    fi
+
+    while ! master -t ; do
+		sleep 0.2
+    done
+    rm -f "$PIDFILE"
+    return $status
+}
+
+reload() {
+    $DAEMON reload
+}
+
+[ "$(type -t ${1})" = "function" ] && "${1}" || {
+		echo "Usage: $0 (start|stop|reload)"; exit 1; }
+
diff --git a/package/postfix/postfix.mk b/package/postfix/postfix.mk
new file mode 100644
index 0000000000..e2cda4e85f
--- /dev/null
+++ b/package/postfix/postfix.mk
@@ -0,0 +1,94 @@
+################################################################################
+#
+# postfix
+#
+################################################################################
+
+POSTFIX_VERSION = 3.11.4
+POSTFIX_SITE = https://www.artfiles.org/postfix.org/postfix-release/official
+POSTFIX_DEPENDENCIES = berkeleydb pcre2
+
+ifdef BR2_PACKAGE_POSTFIX_ICU
+POSTFIX_DEPENDENCIES += icu
+endif
+
+ifdef BR2_LINUX_KERNEL_VERSION
+export pf_linux_release != echo $(call qstrip,$(BR2_LINUX_KERNEL_VERSION)) | grep -Eo \
+	"[1-7]\.[0-9]{1,3}(\.[0-9]{1,3})?"
+else
+export pf_linux_release = 6.12 # assuming we're building for linux, default version shouldn't matter
+endif
+
+pf_ccargs = -DNO_NIS -DNO_NISPLUS -DHAS_DEV_URANDOM $(strip $(TARGET_CFLAGS))
+ifneq "$(strip $(TARGET_LDFLAGS))" ""
+pf_ccargs += -Wl,$(TARGET_LDFLAGS:$() $()=,)
+endif
+
+pf_shared = $(if $(BR2_STATIC_LIBS),no,yes)
+
+pf_default_settings = config_directory=/etc/postfix \
+			 command_directory=/usr/sbin \
+			 daemon_directory=/usr/libexec/postfix \
+			 data_directory=/var/lib/postfix \
+			 html_directory=no \
+			 mail_owner=postfix \
+			 mailq_path=/usr/bin/mailq \
+			 manpage_directory=/usr/local/man \
+			 newaliases_path=/usr/bin/newaliases \
+			 queue_directory=/var/spool/postfix \
+			 readme_directory=no \
+			 sendmail_path=/usr/sbin/sendmail \
+			 setgid_group=postdrop \
+			 shlib_directory=/usr/lib/postfix \
+			 meta_directory=/etc/postfix \
+			 sample_directory=/etc/postfix \
+			 mail_version=$(POSTFIX_VERSION)
+
+# Replace definitions in the 'makedefs' script to enable cross-compilation.
+define POSTFIX_CONFIGURE_CMDS
+	[ ! -f $(@D)/makedefs.orig ] && mv -v $(@D)/makedefs $(@D)/makedefs.orig;:
+	/usr/bin/sed -E -e "s,/usr/,$(STAGING_DIR)/usr/,g" \
+			 -e "s,\s/lib(32|64)?, $(STAGING_DIR)/lib\1,g" \
+			 -e "s,(pcre2|icu|pkg)-config,$(STAGING_DIR)/bin/\1-config,g" \
+			 -e "s,pkgconf,$(STAGING_DIR)/bin/pkgconf,g" \
+			$(@D)/makedefs.orig >$(@D)/makedefs
+	$(MAKE) $(TARGET_CONFIGURE_OPTS) \
+		CCARGS+="$(pf_ccargs)" \
+		OPT=$(shell echo $(TARGET_CFLAGS) | grep -Eo "\-O([0-3gsz]|fast)?") \
+		DEBUG=$(shell echo $(TARGET_CFLAGS) | grep -Eo "\-g[a-z0-9]*") \
+		SHELL="/bin/sh" \
+		shared=$(pf_shared) makefiles -C $(@D)
+	/usr/bin/sed -Ei -e "s,bin/postconf,:,g" \
+			$(@D)/Makefile;: just in case
+endef
+
+define POSTFIX_BUILD_CMDS
+	$(MAKE) -C $(@D)
+endef
+
+define POSTFIX_INSTALL_TARGET_CMDS
+	$(MAKE) POSTFIX_INSTALL_OPTS="install_root=$(TARGET_DIR) $(strip $(pf_default_settings))" \
+		non-interactive-package -C $(@D)
+endef
+
+define POSTFIX_INSTALL_INIT_SYSV
+	$(INSTALL) -m 755 $(POSTFIX_PKGDIR)/init/sysv/*postfix $(TARGET_DIR)/etc/init.d
+	if [ "$(BR2_INIT_OPENRC)" ] ; then \
+		if ! find -P $(TARGET_DIR)/etc/init.d -type f -name "sysv-rcs" ;\
+		then \
+			ln -st $(TARGET_DIR)/etc/runlevels/default \
+				$(TARGET_DIR)/etc/init.d/*postfix ;\
+		fi ;\
+	fi
+endef
+
+define POSTFIX_INSTALL_INIT_SYSTEMD
+	$(INSTALL) -m 644 $(POSTFIX_PKGDIR)/init/systemd/postfix.service $(TARGET_DIR)/etc/systemd/system
+endef
+
+define POSTFIX_USERS
+	postfix -1 postfix -1 ! - - - Postfix Mail Transfer Agent
+	postdrop -1 postdrop -1 ! - - -
+endef
+
+$(eval $(generic-package))
-- 
2.53.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-16 17:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-01 17:16 [Buildroot] [PATCH 1/1] package/postfix: add postfix 3.11.4 package Love Fogelström
2026-08-16 17:29 ` Thomas Petazzoni via buildroot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox