Browse Source

postfix:
- add -DHAS_DLOPEN to CCARGS instead of patch102.
- use postfix-install in %%install (to prepare main.cf)
- change postfix uid/gid to fixed id. (89 for postfix, 90 for postdrop)
- run postalias on %%post

git-svn-id: http://trac.vinelinux.org/repos/projects/specs@7209 ec354946-7b23-47d6-9f5a-488ba84defc7

daisuke 11 years ago
parent
commit
36a988b48d
1 changed files with 87 additions and 51 deletions
  1. 87 51
      p/postfix/postfix-vl.spec

+ 87 - 51
p/postfix/postfix-vl.spec

@@ -7,6 +7,26 @@
 %define _sysconfdir   /etc
 %define _data_dir     %{_var}/lib/postfix
 
+# postfix user/group
+# changed since 2.9.4-3
+%define postfix_uid     89
+%define postfix_user    postfix
+%define postfix_gid     89
+%define postfix_group   postfix
+%define maildrop_group  postdrop
+%define maildrop_gid    90
+
+# install dirs
+%define postfix_config_dir      %{_sysconfdir}/postfix
+%define postfix_daemon_dir      %{_libdir}/postfix
+%define postfix_command_dir     %{_sbindir}
+%define postfix_queue_dir       %{_var}/spool/postfix
+%define postfix_data_dir        %{_var}/lib/postfix
+%define postfix_doc_dir         %{_docdir}/%{name}-%{version}
+%define postfix_sample_dir      %{postfix_doc_dir}/samples
+%define postfix_readme_dir      %{postfix_doc_dir}/README_FILES
+
+
 %define origversion 2.9.4
 
 # Macro: %{dynmap_add_cmd <name> [-m]}
@@ -17,7 +37,7 @@ Summary:   Postfix Mail Transport Agent
 Summary(ja):   Postfix メールトランスポートエージェント
 Name:      postfix
 Version:   %{origversion}
-Release:   2%{?_dist_release}
+Release:   3%{?_dist_release}
 URL:       http://www.postfix.org/
 License:   Distributable - IBM PUBLIC LICENSE VERSION 1.0 - SECURE MAILER
 Group:     System Environment/Daemons
@@ -33,8 +53,6 @@ Patch0:    postfix-2.9.1-vine.patch
 # patches 100/101 for postfix 2.8.x are from mdk.
 Patch100: postfix-2.9.1-dynamicmaps.diff
 Patch101: postfix-2.9.1-dynamicmaps2.diff
-# add HAS_DLOPEN to definitions for LINUX3.
-Patch102: postfix-2.9.4-dynamicmaps3.diff
 
 # patches 200-299 are imported from rh/fedora
 Patch200: postfix-2.5.7-large-fs.patch	   
@@ -163,7 +181,6 @@ sed -i -e 's|/usr/lib/postfix|/usr/lib64/postfix|g' conf/main.cf
 
 %patch100 -p1 -b .dynamicmaps
 %patch101 -p1 -b .dynamicmaps2
-%patch102 -p0 -b .dynamicmaps3
 
 %patch200 -p1 -b .large-fs
 
@@ -184,6 +201,7 @@ popd
 %build
 make makefiles \
 	CCARGS="-DMAX_DYNAMIC_MAPS \
+	        -DHAS_DLOPEN \
 	        -DUSE_SASL_AUTH -I/usr/include/sasl \
 	        -DUSE_CYRUS_SASL \
 		-DHAS_LDAP \
@@ -228,26 +246,45 @@ install -d $RPM_BUILD_ROOT%{_var}/spool/postfix
 install -d $RPM_BUILD_ROOT%{_var}/spool/postfix/{active,corrupt,deferred,incoming,pid,public}
 install -d $RPM_BUILD_ROOT%{_var}/spool/postfix/{bounce,defer,flush,maildrop,private,saved}
 
-install -m755 bin/* $RPM_BUILD_ROOT%{_sbindir}
-install -m755 libexec/* $RPM_BUILD_ROOT%{_libdir}/postfix
-#install -m755 lib/dict_* $RPM_BUILD_ROOT%{_libdir}/postfix
+# disabled dynmaps
+sed -i -e 's/\(.*dict_cdb.*\)/# \1/g' libexec/postfix-files
+%if ! %build_mysql
+sed -i -e 's/\(.*dict_mysql.*\)/# \1/g' libexec/postfix-files
+%endif
+%if ! %build_pgsql
+sed -i -e 's/\(.*dict_pgsql.*\)/# \1/g' libexec/postfix-files
+%endif
+
+LD_LIBRARY_PATH=./lib \
+sh postfix-install -non-interactive \
+  install_root=$RPM_BUILD_ROOT \
+  config_directory=%{postfix_config_dir} \
+  daemon_directory=%{postfix_daemon_dir} \
+  command_directory=%{postfix_command_dir} \
+  queue_directory=%{postfix_queue_dir} \
+  data_directory=%{postfix_data_dir} \
+  sendmail_path=%{postfix_command_dir}/sendmail \
+  newaliases_path=%{_bindir}/newaliases \
+  mailq_path=%{_bindir}/mailq \
+  mail_owner=%{postfix_user} \
+  setgid_group=%{maildrop_group} \
+  manpage_directory=%{_mandir} \
+  sample_directory=%{postfix_sample_dir} \
+  readme_directory=%{postfix_readme_dir} || exit 1
+
 install -m755 lib/lib*.so.1 $RPM_BUILD_ROOT%{_libdir}
 
-touch conf/dynamicmaps.cf
-for i in main.cf master.cf access aliases canonical header_checks \
-         main.cf.default post-install postfix-files postfix-script \
-	 relocated transport virtual dynamicmaps.cf
-do
-  install -m644 conf/$i $RPM_BUILD_ROOT%{_sysconfdir}/postfix
-done
+install -m644 conf/postfix-files $RPM_BUILD_ROOT%{_sysconfdir}/postfix
 for i in post-install postfix-script
 do
   install -m755 conf/$i $RPM_BUILD_ROOT%{_sysconfdir}/postfix
 done
 
-install -m644 man/man1/*.1 $RPM_BUILD_ROOT%{_mandir}/man1
-install -m644 man/man5/*.5 $RPM_BUILD_ROOT%{_mandir}/man5
-install -m644 man/man8/*.8 $RPM_BUILD_ROOT%{_mandir}/man8
+# install performance benchmark tools by hand
+for i in smtp-sink smtp-source qmqp-sink qmqp-source; do
+  install -c -m 755 bin/$i $RPM_BUILD_ROOT%{postfix_command_dir}/
+  install -c -m 755 man/man1/$i.1 $RPM_BUILD_ROOT%{_mandir}/man1/
+done
 
 install -m644 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/postfix/aliases
 install -m755 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/cron.daily/postfix
@@ -256,44 +293,45 @@ install -m755 %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d/postfix
 ln -sf postfix/aliases $RPM_BUILD_ROOT%{_sysconfdir}/aliases
 ln -sf postfix/aliases.db $RPM_BUILD_ROOT%{_sysconfdir}/aliases.db
 
-( cd $RPM_BUILD_ROOT%{_bindir}
-  ln -sf ../sbin/sendmail mailq
-  ln -sf ../sbin/sendmail newaliases
-)
+#( cd $RPM_BUILD_ROOT%{_bindir}
+#  ln -sf ../sbin/sendmail mailq
+#  ln -sf ../sbin/sendmail newaliases
+#)
 ( cd $RPM_BUILD_ROOT%{_libdir}
   ln -sf ../sbin/sendmail sendmail
 )
 
-for I in etc/postfix/{aliases,access,canonical,header_check,relocated,transport,virtual}
-do
-   touch $RPM_BUILD_ROOT/$I{,.db}
-done
-
 # data dir
 install -d $RPM_BUILD_ROOT%{_data_dir}
 
+# remove unneeded files
+rm -f $RPM_BUILD_ROOT%{postfix_config_dir}/{TLS_,}LICENSE
+
+
 %pre
-if [ `grep postfix %{_sysconfdir}/passwd | wc -l` = 0 ]; then
-   %{_sbindir}/useradd -M -r -d %{_var}/spool/postfix -s "" \
-                     -c "postfix" postfix || :
-fi
-if [ `grep postfix %{_sysconfdir}/group | wc -l` = 0 ]; then
-  %{_sbindir}/groupadd -r postfix
-fi
-if [ `grep postdrop %{_sysconfdir}/group | wc -l` = 0 ]; then
-  %{_sbindir}/groupadd -r postdrop
-fi
-#if [ -f %{_var}/lock/subsys/postfix ]; then
-#   %{_sysconfdir}/rc.d/init.d/postfix stop
-#fi
+# Add user and groups if necessary
+%{_sbindir}/groupadd -g %{maildrop_gid} -r %{maildrop_group} 2>/dev/null
+%{_sbindir}/groupadd -g %{postfix_gid} -r %{postfix_group} 2>/dev/null
+%{_sbindir}/groupadd -g 12 -r mail 2>/dev/null
+%{_sbindir}/useradd -d %{postfix_queue_dir} -s /sbin/nologin -g %{postfix_group} -G mail -M -r -u %{postfix_uid} %{postfix_user} 2>/dev/null
+exit 0
 
 
 %post
 /sbin/ldconfig
+# upgrade configuration files if necessary
+%{_sbindir}/postfix set-permissions upgrade-configuration \
+  daemon_directory=%{postfix_daemon_dir} \
+  command_directory=%{postfix_command_dir} \
+  mail_owner=%{postfix_user} \
+  setgid_group=%{maildrop_group} \
+  manpage_directory=%{_mandir} \
+  sample_directory=%{postfix_sample_dir} \
+  readme_directory=%{postfix_readme_dir} &> /dev/null
 %dynmap_add_cmd tcp
 /sbin/chkconfig --add postfix
 if [ ! -f %{_sysconfdir}/postfix/aliases.db ]; then
-  touch %{_sysconfdir}/postfix/aliases.db
+  %{_sbindir}/postalias %{_sysconfdir}/postfix/aliases
 fi
 %{_sbindir}/postalias %{_sysconfdir}/postfix/aliases ||:
 if [ ! -e %{_libdir}/sendmail ]; then
@@ -318,15 +356,6 @@ fi
 %postun
 /sbin/ldconfig
 if [ $1 = 0 ]; then
-   if [ `grep postfix %{_sysconfdir}/passwd | wc -l` = 1 ]; then
-      %{_sbindir}/userdel postfix
-   fi
-   if [ `grep postfix %{_sysconfdir}/group | wc -l` = 1 ]; then
-      %{_sbindir}/groupdel postfix
-   fi
-   if [ `grep postdrop %{_sysconfdir}/group | wc -l` = 1 ]; then
-      %{_sbindir}/groupdel postdrop
-   fi
    if ! [ -f %{_var}/lock/subsys/postfix ]; then
         rm -rf %{_var}/lock/subsys/postfix
    fi
@@ -372,7 +401,7 @@ rm -rf $RPM_BUILD_ROOT
 
 %files
 %defattr(-,root,root)
-%doc COMPATIBILITY COPYRIGHT HISTORY LICENSE INSTALL PORTING RELEASE_NOTES
+%doc COMPATIBILITY COPYRIGHT HISTORY TLS_LICENSE LICENSE INSTALL PORTING RELEASE_NOTES
 # japanese documant for 2.4.x is not ready.
 # %doc conf.ja
 # %doc html html.ja
@@ -385,10 +414,11 @@ rm -rf $RPM_BUILD_ROOT
 %dir %{_sysconfdir}/postfix
 %config %{_sysconfdir}/postfix/main.cf.default
 %config %{_sysconfdir}/postfix/master.cf
+%config %{_sysconfdir}/postfix/bounce.cf.default
 %config(noreplace) %{_sysconfdir}/postfix/aliases
 %config(noreplace) %{_sysconfdir}/postfix/access
 %config(noreplace) %{_sysconfdir}/postfix/canonical
-%config(noreplace) %{_sysconfdir}/postfix/header_check
+%config(noreplace) %{_sysconfdir}/postfix/generic
 %config(noreplace) %{_sysconfdir}/postfix/header_checks
 %config(noreplace) %{_sysconfdir}/postfix/main.cf
 %config(noreplace) %{_sysconfdir}/postfix/relocated
@@ -474,6 +504,12 @@ rm -rf $RPM_BUILD_ROOT
 %{_libdir}/postfix/dict_pcre.so
 
 %changelog
+* Sun Dec 09 2012 Daisuke SUZUKI <daisuke@linux.or.jp> 2.9.4-3
+- add -DHAS_DLOPEN to CCARGS instead of patch102.
+- use postfix-install in %%install (to prepare main.cf)
+- change postfix uid/gid to fixed id. (89 for postfix, 90 for postdrop)
+- run postalias on %%post
+
 * Fri Nov 30 2012 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.9.4-2
 - added patch102.