[Pkg-apache-commits] [SCM] Debian packaging for apache2 (Apache HTTPD 2.x) branch, next, updated. a09a06d61d7ed855e78f392f322f76c6a1d2eb43

Arno Töll debian at toell.net
Sun Mar 25 21:33:48 UTC 2012


The following commit has been merged in the next branch:
commit a09a06d61d7ed855e78f392f322f76c6a1d2eb43
Author: Arno Töll <debian at toell.net>
Date:   Sun Mar 25 23:32:16 2012 +0200

    apache2-maintscript-helper: Add apache2_msg call, switch back to true in
    dh_apache2 as the default conditional.

diff --git a/debian/changelog b/debian/changelog
index 83941f7..14d6ff3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -12,15 +12,19 @@ apache2 (2.4.1-3) experimental; urgency=low
   * Changes in dh_apache2:
     + Invoke the maintscript helper postrm action for simple package removals, too.
     + Fix a bug which accidentally called "en{mod,site,conf}" instead of "di{mod,site,conf}"
+    + Set the default conditional back to "true", now the maintainer script is
+      expected to cope itself with upgrades correctly
   * Changes in apache2_maintscript_helper
-    + Provide apache2_is_upgrade and apache2_is_fresh_installation functions
+    + Provide apache2_is_upgrade, apache2_msg and apache2_is_fresh_installation
+      functions
     + Parse maintainer script arguments to find out which script called us
+    + Support APACHE2_MAINTSCRIPT_HELPER_QUIET which, when set, omits any visible output
 
   [ Stefan Fritsch ]
   * Move /usr/share/doc alias to separate config file and don't enable it
     by default.
 
- -- Arno Töll <debian at toell.net>  Sun, 25 Mar 2012 20:26:37 +0200
+ -- Arno Töll <debian at toell.net>  Sun, 25 Mar 2012 23:31:09 +0200
 
 apache2 (2.4.1-2) experimental; urgency=low
 
diff --git a/debian/debhelper/apache2-maintscript-helper b/debian/debhelper/apache2-maintscript-helper
index df92ed9..fb88730 100644
--- a/debian/debhelper/apache2-maintscript-helper
+++ b/debian/debhelper/apache2-maintscript-helper
@@ -43,6 +43,9 @@ else
 		;;
 	esac
 
+	APACHE2_MAINTSCRIPT_PACKAGE="$0"
+	APACHE2_MAINTSCRIPT_PACKAGE=$(echo "$APACHE2_MAINTSCRIPT_PACKAGE" | sed -re 's#^.+/(.*)\.\w+$#\1#'  )
+
 	APACHE2_MAINTSCRIPT_METHOD="$1"
 	APACHE2_MAINTSCRIPT_ARGUMENT="$2"
 
@@ -51,14 +54,7 @@ fi
 
 
 #### XXX: TODOS:
-# To cope with updates / fresh installations maintscript helper needs to parse
-# $@. From our discussion:
-# For that, the maint-script-helper needs to store $@ somewhere when it is first
-# sourced. Document somewhere that $@ must be intact at that time. Complain if $1
-# is empty (that's meant as sanity check because $1 contains the maintainer script
-# argument and is guaranteed to be set by dpkg).
-#
-#
+
 # Moreover it needs to remember if a module/web app was disabled (or enabled) by
 # a maintainer script or by the user. Again, from our discussion:
 # The rembering could be done like:
@@ -72,14 +68,46 @@ fi
 #   module/conf per invocation, this would allow adding optional parameters later)
 # - change dh_apache2 accordingly (which is not that trivial as there is no easy
 #   way to source script fragments in autoscripts)
-# - If the complexity overboards, the maint-helper can be changed to a shell
-# - the maint helper should log problems into some dedicated log file in
-#    /var/log/apache2
-#    (in addition to printing them to the screen unless the maintainer set
-#     APACHE2_MAINTSCRIPT_HELPER_QUIET=1)
 
 
 
+
+#
+# Function apache2_msg
+#	print out a warning to both, the syslog and a local standard output.
+#	This function should generally be used to display messages related to
+#	the web server in maintainer scripts.
+# Parameters:
+#	priority
+#		The message priority. Recognized values are the same as defined
+#		by syslog(3), thus: one among debug, info, notice, warning,
+#		err, crit, alert, emerg.
+#		If no known priority is recognized, the priority is set to
+#		"warning".
+#	message
+#		The message as a string. It is printed out verbatim.
+# Behavior:
+#	No message is displayed if APACHE2_MAINTSCRIPT_HELPER_QUIET is defined
+# Returns:
+#	this function always returns 0
+# Since: 2.4.1-3
+apache2_msg()
+{
+	local PRIORITY="$1"
+	local MSG="$2"
+	[ -z "$APACHE2_MAINTSCRIPT_HELPER_QUIET" ] && echo "$MSG"
+	[ -x /usr/bin/logger ] || return 0
+	case "$PRIORITY" in
+		debug|info|notice|warning|err|crit|alert|emerg)
+		;;
+		*)
+			PRIORITY="warning"
+		;;
+	esac
+	local LOGGER="/usr/bin/logger -p daemon.$PRIORITY -t $APACHE2_MAINTSCRIPT_PACKAGE "
+	$LOGGER "$MSG" || return 0
+}
+
 #
 # Function apache2_is_upgrade
 # 	succeeds if the package invoking the maintscript helper
@@ -198,6 +226,7 @@ apache2_switch_mpm()
 	MPM=$(echo "$MPM" | sed -e 's/^mpm_//')
 
 	if [ ! -e "/etc/apache2/mods-available/mpm_$MPM.load" ] ; then
+		apache2_msg "err" "apache2_switch_mpm: MPM $MPM not found"
 		return 1
 	fi
 
@@ -240,23 +269,28 @@ apache2_invoke()
 	shift
 	local invoke_rcd=0
 	local check_switch=""
+	local invoke_string=""
 
 	[ -x "/usr/sbin/a2$CMD" ] || return 1
 	[ -x "/usr/sbin/a2query" ] || return 1
 
 	if apache2_is_upgrade && [ $APACHE2_MAINTSCRIPT_NAME = 'postinst' ] ; then
+		apache2_msg "info" "apache2_invoke: Doing nothing upon upgrade"
 		return 0
 	fi
 
 	case "$CMD" in
 		*conf)
 			check_switch="-c"
+			invoke_string="configuration"
 			;;
 		*mod)
 			check_switch="-m"
+			invoke_string="module"
 			;;
 		*site)
 			check_switch="-s"
+			invoke_string="site"
 			;;
 		*)
 			;;
@@ -269,12 +303,14 @@ apache2_invoke()
 					continue
 				fi
 				invoke_rcd=1
-				a2$CMD -q "$CONF" || return 1
+				a2$CMD -q "$CONF" > /dev/null 2>&1 || return 1
+				apache2_msg "info" "apache2_invoke: Enable $invoke_string $CONF"
 				;;
 			disconf|dismod|dissite)
 				if a2query $check_switch $CONF > /dev/null 2>&1 ; then
 					invoke_rcd=1
-					a2$CMD -q "$CONF" || return 1
+					a2$CMD -q "$CONF" > /dev/null 2>&1 || return 1
+					apache2_msg "info" "apache2_invoke: Disable $invoke_string $CONF"
 				else
 					continue
 				fi
@@ -307,6 +343,6 @@ apache2_reload()
 	if apache2ctl configtest 2>/dev/null; then
 		invoke-rc.d apache2 force-reload || true
 	else
-		echo "Your configuration is broken. Not restarting Apache 2."
+		apache2_msg "err" "apache2_reload: Your configuration is broken. Not restarting Apache 2"
 	fi
 }
diff --git a/debian/debhelper/dh_apache2.in b/debian/debhelper/dh_apache2.in
index e5b706c..b79dda4 100755
--- a/debian/debhelper/dh_apache2.in
+++ b/debian/debhelper/dh_apache2.in
@@ -293,7 +293,7 @@ init(options => {
 
 if (!$dh{CONDITIONAL})
 {
-	$dh{CONDITIONAL} = 'test -n "$2"';
+	$dh{CONDITIONAL} = 'true';
 }
 
 foreach my $package (getpackages())

-- 
Debian packaging for apache2 (Apache HTTPD 2.x)



More information about the Pkg-apache-commits mailing list