Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 17 Feb 2018 12:45:19 +0000 (UTC)
From:      Matthias Andree <mandree@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r462151 - in head: . mail/mailman mail/mailman/files
Message-ID:  <201802171245.w1HCjJ15007736@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mandree
Date: Sat Feb 17 12:45:18 2018
New Revision: 462151
URL: https://svnweb.freebsd.org/changeset/ports/462151

Log:
  Overhaul default hosts configuration.
  
  - When no virtualhosts are defined, and the default localhost/localhost is
    effective, the post-install script now adds DEFAULT_EMAIL_HOST,
    DEFAULT_URL_HOST, and add_virtualhost() lines to mm_cfg.py.
  
    Add corresponding support to remove unchanged configurations to the
    deinstall script.
  
  - While here, overhaul crontab configuration to only request a merge if the
    crontab had been modified, and unify progress reports.
  
  - Merge pkg-deinstall into pkg-install, to avoid duplication of code
    that might be missed in later maintenance.
  
  PR:		225961
  Reported by:	Terry Kennedy

Deleted:
  head/mail/mailman/files/pkg-deinstall.in
Modified:
  head/UPDATING
  head/mail/mailman/Makefile
  head/mail/mailman/files/FreeBSD-post-install-notes
  head/mail/mailman/files/mailman.in
  head/mail/mailman/files/pkg-install.in

Modified: head/UPDATING
==============================================================================
--- head/UPDATING	Sat Feb 17 12:34:08 2018	(r462150)
+++ head/UPDATING	Sat Feb 17 12:45:18 2018	(r462151)
@@ -70,11 +70,17 @@ you update your ports collection, before attempting an
   and DEFAULT_URL_HOST to "localhost" statically, and the rc script
   will check this and refuse to start on next boot.
 
-  Users must configure DEFAULT_EMAIL_HOST and DEFAULT_URL_HOST in 
-  Mailman/mm_cfg.py properly.
+  Users must configure DEFAULT_EMAIL_HOST and DEFAULT_URL_HOST in
+  Mailman/mm_cfg.py properly and add this line below:
+  add_virtualhost(DEFAULT_URL_HOST, DEFAULT_EMAIL_HOST)
 
   A short example has been added to:
   ${PREFIX}/local/share/doc/mailman/FreeBSD-post-install-notes.
+
+  As of 2.1.26_3, the post-install script will add back the prior
+  default settings to mm_cfg.py (instead of Defaults.py) if no
+  virtual hosts have been defined, to cover the normal use cases
+  and initial installation.
 
 20180201:
   AFFECTS: users of editors/emacs* and all ports using Emacs via USES=emacs

Modified: head/mail/mailman/Makefile
==============================================================================
--- head/mail/mailman/Makefile	Sat Feb 17 12:34:08 2018	(r462150)
+++ head/mail/mailman/Makefile	Sat Feb 17 12:45:18 2018	(r462151)
@@ -3,7 +3,7 @@
 
 PORTNAME=	mailman
 DISTVERSION=	2.1.26
-PORTREVISION=	2
+PORTREVISION=	3
 CATEGORIES=	mail
 MASTER_SITES=	GNU \
 		SF/${PORTNAME}/Mailman%202.1%20%28stable%29/${PORTVERSION} \
@@ -57,8 +57,9 @@ GROUPS=		${MM_GROUPNAME}
 
 MAILMANDIR=	${PREFIX}/${MM_DIR}
 PLIST_SUB=	MMDIR=${MM_DIR} IMGDIR=${IMGDIR} MM_USERNAME=${MM_USERNAME} MM_GROUPNAME=${MM_GROUPNAME}
-SUB_FILES=	pkg-message pkg-install pkg-deinstall mailman.newsyslog.sample
+SUB_FILES=	pkg-message pkg-install mailman.newsyslog.sample
 SUB_LIST=	MAILMANDIR=${MAILMANDIR} USER=${MM_USERNAME} GROUP=${MM_GROUPNAME} PYTHON_CMD="${PYTHON_CMD}"
+PKGDEINSTALL=	${PKGINSTALL}
 
 PORTDOCS=	ACKNOWLEDGMENTS BUGS FAQ INSTALL NEWS README README-I18N.en \
 		README.CONTRIB README.NETSCAPE \

Modified: head/mail/mailman/files/FreeBSD-post-install-notes
==============================================================================
--- head/mail/mailman/files/FreeBSD-post-install-notes	Sat Feb 17 12:34:08 2018	(r462150)
+++ head/mail/mailman/files/FreeBSD-post-install-notes	Sat Feb 17 12:45:18 2018	(r462151)
@@ -38,11 +38,11 @@ package) can help with that.
    many of the steps you may read about in these files.  Also, not everything
    in these files is necessarily relevant to the FreeBSD port.
 
-   In most cases, you will want to override the host name settings (which
-   default to 'localhost') by adding these lines to Mailman/mm_cfg.py:
-   (the documentation is in Mailman/Defaults.py, but you need to override
-   the defaults in mm_cfg.py instead, changes to Defaults.py are lost on
-   upgrades):
+   In most cases, you need to override the host name settings (which
+   default to 'localhost') by adding or changing these lines to/in
+   Mailman/mm_cfg.py: (the documentation is in Mailman/Defaults.py, but you
+   need to override the defaults in mm_cfg.py instead, changes to Defaults.py
+   are lost on upgrades):
 
    # adjust and add this to Mailman/mm_cfg.py:
    DEFAULT_URL_HOST = 'CHANGE_ME.example.org'

Modified: head/mail/mailman/files/mailman.in
==============================================================================
--- head/mail/mailman/files/mailman.in	Sat Feb 17 12:34:08 2018	(r462150)
+++ head/mail/mailman/files/mailman.in	Sat Feb 17 12:45:18 2018	(r462151)
@@ -51,8 +51,8 @@ mailman_prestart() {
 	### check if the default configuration is plausible
 	vhosts=$(PYTHONPATH="%%MAILMANDIR%%/bin" "%%PYTHON_CMD%%" -c 'import paths;from Mailman import mm_cfg;_x=dict(mm_cfg.VIRTUAL_HOSTS);print repr(_x);')
 	if [ "${vhosts}" = "{'localhost': 'localhost'}" ] ; then
-		warn 'Be sure to change the default hosts in Mailman/mm_cfg.py!'
-		warn 'Review %%DOCSDIR%%/FreeBSD-post-install-notes for instructions.'
+		warn 'No DEFAULT or virtual hosts configured.'
+		warn 'Review %%DOCSDIR%%/FreeBSD-post-install-notes #1 for instructions.'
 		if ! checkyesno mailman_run_localhost ; then
 			err 78 "Start of mailman refused due to insufficient configuration."
 		fi

Modified: head/mail/mailman/files/pkg-install.in
==============================================================================
--- head/mail/mailman/files/pkg-install.in	Sat Feb 17 12:34:08 2018	(r462150)
+++ head/mail/mailman/files/pkg-install.in	Sat Feb 17 12:45:18 2018	(r462151)
@@ -19,18 +19,28 @@ check_rcfile_fix_perms() {
     )
 }
 
+add_default_virtuals() {
+    cat >>"$1" <<_EOF
+
+# This and the next three lines added by FreeBSD's post-install script
+DEFAULT_EMAIL_HOST="$(hostname -f)"
+DEFAULT_URL_HOST="$(hostname -f)"
+add_virtualhost(DEFAULT_URL_HOST, DEFAULT_EMAIL_HOST)
+
+_EOF
+}
+
 set -e
-case "$2" in
+MYTMP="$(mktemp -d "${TMPDIR-/tmp}/mminstall.XXXXXXXXXX")"
+trap "rm -rf \"$MYTMP\"" EXIT
 
+case "$2" in
 POST-INSTALL)
   echo "---> Starting post-install script"
   LC_ALL=C
   export LC_ALL
 
-  MYTMP="$(mktemp -d "${TMPDIR-/tmp}/mminstall.XXXXXXXXXX")"
-  trap "rm -rf \"$MYTMP\"" EXIT
-
-  # fix up permissions - this is under investigation; pkg or libarchive
+ # fix up permissions - this is under investigation; pkg or libarchive
   # goof up the group writable and/or setgid bits
   /usr/bin/find "%%MAILMANDIR%%/qfiles" -maxdepth 1 -type d -exec \
     /bin/chmod u+rwx,g+rwsx,o-w "{}" +
@@ -83,17 +93,18 @@ POST-INSTALL)
       printf '%s\n' "%%USER%%" >> /var/cron/allow
   fi
 
-  if /usr/bin/crontab -u "%%USER%%" -l >"$MYTMP/crontab" 2>&1 ; then
-      if test -s "$MYTMP/crontab"; then
-          echo "---> \"%%USER%%\" already has a crontab.  Not overwriting it"
-          echo "---> Please merge any changes from the standard crontab file"
+  if /usr/bin/crontab -u "%%USER%%" -l >"$MYTMP/crontab" ; then
+      if test -s "$MYTMP/crontab" && ! cmp -s "$MYTMP/crontab" "%%MAILMANDIR%%/cron/crontab.in"; then
+          echo "---> User \"%%USER%%\" already has a non-default crontab."
+	  echo "---> Not overwriting it."
+          echo "---> Please review and merge any changes from the standard crontab file"
           echo "--->     %%MAILMANDIR%%/cron/crontab.in"
       else
           echo "---> Installing crontab(5) file for user \"%%USER%%\""
           /usr/bin/crontab -u "%%USER%%" "%%MAILMANDIR%%/cron/crontab.in"
       fi
   else
-      echo "---> Creating crontab(5) file for user \"%%USER%%\""
+      echo "---> Installing crontab(5) file for user \"%%USER%%\""
       /usr/bin/crontab -u "%%USER%%" "%%MAILMANDIR%%/cron/crontab.in"
   fi
   rm -f "$MYTMP/crontab"
@@ -106,6 +117,14 @@ POST-INSTALL)
     echo "---> rcfile sets mailman_fix_perms to no, skipping check_perms"
   fi
 
+  # check if we need to add our hostname to the configuration:
+  if cmp -s "%%MAILMANDIR%%/Mailman/mm_cfg.py" "%%MAILMANDIR%%/Mailman/mm_cfg.py.dist" \
+    || test "{'localhost': 'localhost'}" = "$(PYTHONPATH="%%MAILMANDIR%%/bin" "%%PYTHON_CMD%%" -c 'import paths;from Mailman import mm_cfg;_x=dict(mm_cfg.VIRTUAL_HOSTS);print repr(_x);')"
+  then
+    echo "---> adding default host configuration to %%MAILMANDIR%%/Mailman/mm_cfg.py."
+    add_default_virtuals "%%MAILMANDIR%%/Mailman/mm_cfg.py"
+  fi
+
   echo "---> Running assorted other checks"
   if egrep -q "^[ \t]*MTA.*=.*Postfix" "%%MAILMANDIR%%/Mailman/mm_cfg.py" ; then
       # run Postfix-specific checks
@@ -121,5 +140,68 @@ POST-INSTALL)
 	  echo ""
       fi
   fi
+  ;;
+
+  ####### DEINSTALLATION PART #######
+
+DEINSTALL)
+  echo "---> Starting deinstall script"
+
+  if /usr/bin/crontab -u "%%USER%%" -l | \
+      /usr/bin/diff -B -b - "%%MAILMANDIR%%/cron/crontab.in" >/dev/null 2>&1 ; then
+      echo "---> Zeroing unchanged crontab for \"%%USER%%\""
+      /usr/bin/crontab -u "%%USER%%" -r </dev/null
+      if [ -e /var/cron/allow ]; then
+         grep -v "^%%USER%%$" /var/cron/allow > /var/cron/allow.new$$
+         mv /var/cron/allow.new$$ /var/cron/allow
+      fi
+  else
+      echo "---> Crontab for \"%%USER%%\" modified, not removed: please deinstall"
+      echo "---> it manually if you no longer wish to use Mailman. E.g.:"
+      echo "--->     /usr/bin/crontab -u \"%%USER%%\" -r"
+  fi
+
+  echo "---> Preserving the \"last_mailman_version\" file"
+  /bin/mv -f "%%MAILMANDIR%%/data/last_mailman_version" /var/tmp/ || :
+
+  # If the errorlog is the only existing logfile, delete it.  (If Mailman's
+  # qrunner had not been running, then the process of trying to stop the
+  # qrunner (above) will cause the errorlog to be written to.  Hence, even if
+  # the Mailman port/package is installed and immediately deinstalled, the
+  # errorlog will exist.)
+  if [ "`echo %%MAILMANDIR%%/logs/*`" = "%%MAILMANDIR%%/logs/error" ]; then
+    echo "---> Deleting errorlog (It is the only existing logfile.)"
+    /bin/rm -f "%%MAILMANDIR%%/logs/error"
+  fi
+
+  # attempt removal, but do not care if it is not empty
+  /bin/rmdir "%%MAILMANDIR%%/archives/private/" 2>/dev/null || :
+  
+  # if configuration is unchanged, remove it explicitly,
+  # @sample wouldn't work because we added our hostname
+  cat "%%MAILMANDIR%%/Mailman/mm_cfg.py.dist" >"$MYTMP/mm_cfg.tmp"
+  add_default_virtuals "$MYTMP/mm_cfg.tmp"
+  if cmp -s "%%MAILMANDIR%%/Mailman/mm_cfg.py" "$MYTMP/mm_cfg.tmp" ; then
+    echo "---> Removing default configuration file."
+    rm -f "%%MAILMANDIR%%/Mailman/mm_cfg.py"
+  fi
+  ;;
+
+POST-DEINSTALL)
+  echo "---> Starting post-deinstall script"
+
+  set -- "%%MAILMANDIR%%/lists"/*
+  if [ $# -gt 1 ] || [ "x$1" != "x%%MAILMANDIR%%/lists/*" ] ; then
+    echo '---> %%MAILMANDIR%%/lists is not empty - this installation may have active lists! Listing max. 10:'
+    find "%%MAILMANDIR%%/lists" -mindepth 1 -maxdepth 1 | head -n 10 || :
+    echo "---> Restoring \"last_mailman_version\" file"
+    if test -d "%%MAILMANDIR%%" ; then 
+	/bin/mkdir -p "%%MAILMANDIR%%/data" && \
+        /bin/mv -f /var/tmp/last_mailman_version "%%MAILMANDIR%%/data/"
+    else
+	/bin/rm -f /var/tmp/last_mailman_version
+    fi
+  fi
+
   ;;
 esac



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201802171245.w1HCjJ15007736>