[Pkg-apache-commits] [SCM] Debian packaging for apache2 (Apache HTTPD 2.x) branch, next, updated. 73146c8e170259bf9751e047e18ba5bae84c08a7
Arno Töll
debian at toell.net
Sun Mar 25 18:23:45 UTC 2012
The following commit has been merged in the next branch:
commit 73146c8e170259bf9751e047e18ba5bae84c08a7
Author: Arno Töll <debian at toell.net>
Date: Sun Mar 25 20:19:59 2012 +0200
* Add some upgrade functions to apache2-maintscript-helper
* Provide maintainer script details in variables to functions
* Invoke the maintscript-helper for "remove" invokations in postrm, too.
* Fix dh_apache2 - the last last minute fix broke postrm scripts, they
accidentally had enmod instead of dismod as action
diff --git a/debian/a2query.in b/debian/a2query.in
index 1308659..ed970a1 100755
--- a/debian/a2query.in
+++ b/debian/a2query.in
@@ -132,7 +132,7 @@ sub fail
sub load_defaults
{
- my @out = `$APACHE2 -V`;
+ my @out = `$APACHE2 -V 2>/dev/null`;
return if $?;
for (my $line; $line <= $#out; $line++)
{
diff --git a/debian/debhelper/apache2-maintscript-helper b/debian/debhelper/apache2-maintscript-helper
index 6be9b9d..7864f5f 100644
--- a/debian/debhelper/apache2-maintscript-helper
+++ b/debian/debhelper/apache2-maintscript-helper
@@ -18,11 +18,34 @@
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+set -x
+
if [ -n "${EXPORT_APACHE2_MAINTSCRIPT_HELPER:-}" ] ; then
return
-fi
-EXPORT_APACHE2_MAINTSCRIPT_HELPER=1
+else
+ EXPORT_APACHE2_MAINTSCRIPT_HELPER=1
+
+ if [ -z "$1" ] ; then
+ echo "You must invoke apache2-maintscript-helper with an nmodified environment when sourcing it"
+ return 1
+ fi
+
+ APACHE2_MAINTSCRIPT_NAME="$0"
+ APACHE2_MAINTSCRIPT_NAME=$(echo "$APACHE2_MAINTSCRIPT_NAME" | sed -re 's#^.*?\.(\w+)#\1#' )
+ case "$APACHE2_MAINTSCRIPT_NAME" in
+ preinst|prerm|postrm|postinst)
+ # yay - recognized script
+ ;;
+ *)
+ echo "Invoked from an unrecognized maintainer script: exiting"
+ return 1
+ ;;
+ esac
+
+ APACHE2_MAINTSCRIPT_METHOD="$1"
+ APACHE2_MAINTSCRIPT_ARGUMENT="$2"
+fi
@@ -56,7 +79,74 @@ EXPORT_APACHE2_MAINTSCRIPT_HELPER=1
+#
+# Function apache2_is_upgrade
+# succeeds if the package invoking the maintscript helper
+# is being upgraded. This is useful to find out whether the maintainer
+# script logic was already invoked once.
+# Parameters:
+# none
+# Returns:
+# 0 if an older version of the maintainer script invoking the helper is
+# already installed
+# 1 otherwise
+# Since: 2.4.1-3
+apache2_is_upgrade()
+{
+
+ # For postinst scripts we're upgrading if we're invoked in "postins configure <most recently installed version>"
+ if [ -n "$APACHE2_MAINTSCRIPT_NAME" ] && [ "$APACHE2_MAINTSCRIPT_NAME" = 'postinst' ] ; then
+ case "$APACHE2_MAINTSCRIPT_METHOD" in
+ configure)
+ if [ -n "$APACHE2_MAINTSCRIPT_ARGUMENT" ] ; then
+ return 0
+ fi
+
+ return 1
+ ;;
+ *)
+ return 1
+ ;;
+ esac
+ fi
+ # For preinst scripts we're upgrading if we're invoked as "preinst install|upgrade <most recently installed version>"
+ if [ -n "$APACHE2_MAINTSCRIPT_NAME" ] && [ "$APACHE2_MAINTSCRIPT_NAME" = 'preinst' ] ; then
+ case "$APACHE2_MAINTSCRIPT_METHOD" in
+ install|upgrade)
+ if [ -n "$APACHE2_MAINTSCRIPT_ARGUMENT" ] ; then
+ return 0
+ fi
+
+ return 1
+ ;;
+ *)
+ return 1
+ ;;
+ esac
+ fi
+
+ return 1
+}
+
+#
+# Function apache2_is_fresh_installation
+# succeeds if the package invoking the maintscript helper
+# is being newly installed. This is useful to find out whether the maintainer
+# script logic was already invoked once.
+# Parameters:
+# none
+# Returns:
+# 0 if no older version of the package was previously installed
+# 1 otherwise
+# Since: 2.4.1-3
+apache2_is_fresh_installation()
+{
+ if apache2_is_upgrade ; then
+ return 1
+ fi
+ return 0
+}
#
# Function apache2_has_module
@@ -99,6 +189,10 @@ apache2_switch_mpm()
[ -x /usr/sbin/a2dismod ] || return 1
[ -x /usr/sbin/a2enmod ] || return 1
+ if apache2_is_upgrade ; then
+ return 0
+ fi
+
local MPM="$1"
MPM=$(echo "$MPM" | sed -e 's/^mpm_//')
@@ -149,6 +243,10 @@ apache2_invoke()
[ -x "/usr/sbin/a2$CMD" ] || return 1
[ -x "/usr/sbin/a2query" ] || return 1
+ if apache2_is_upgrade && [ $APACHE2_MAINTSCRIPT_NAME = 'postinst' ] ; then
+ return 0
+ fi
+
case "$CMD" in
*conf)
check_switch="-c"
@@ -173,11 +271,12 @@ apache2_invoke()
a2$CMD -q "$CONF" || return 1
;;
disconf|dismod|dissite)
- if ! a2query $check_switch $CONF > /dev/null 2>&1 ; then
+ if a2query $check_switch $CONF > /dev/null 2>&1 ; then
+ invoke_rcd=1
+ a2$CMD -q "$CONF" || return 1
+ else
continue
fi
- invoke_rcd=1
- a2$CMD -q "$CONF" || return 1
;;
*)
return 1
diff --git a/debian/debhelper/dh_apache2.in b/debian/debhelper/dh_apache2.in
index c116273..e5b706c 100755
--- a/debian/debhelper/dh_apache2.in
+++ b/debian/debhelper/dh_apache2.in
@@ -472,23 +472,31 @@ foreach my $package (getpackages())
{
foreach my $ref (@postinst_autoscripts)
{
- my %replacements = (
- HELPER => $ref->[0],
- NAMES => $ref->[1],
- ERROR_HANDLER => $PACKAGE_TYPE{handler},
- CONDITIONAL_VARIABLE => $PACKAGE_TYPE{conditional},
- );
- my $sed_command = "";
- foreach my $key (sort keys %replacements) {
- my $val = $replacements{$key};
- # escape slashes and backslashes from sed
- $val =~ s,([/\\]),\\$1,g;
- $sed_command .= "s/#$key#/$val/g; ";
- }
+ for my $script_type (qw/postinst postrm/)
+ {
+ my %replacements = (
+ HELPER => $ref->[0],
+ NAMES => $ref->[1],
+ ERROR_HANDLER => $PACKAGE_TYPE{handler},
+ CONDITIONAL_VARIABLE => $PACKAGE_TYPE{conditional},
+ );
+
+ if ($script_type eq "postrm")
+ {
+ $replacements{'HELPER'} =~ s/en/dis/;
+ }
- autoscript($package, "postinst", "postinst-apache2", $sed_command);
- $ref->[0] =~ s/en/dis/;
- autoscript($package, "postrm", "postrm-apache2", $sed_command);
+ my $sed_command = "";
+ foreach my $key (sort keys %replacements)
+ {
+ my $val = $replacements{$key};
+ # escape slashes and backslashes from sed
+ $val =~ s,([/\\]),\\$1,g;
+ $sed_command .= "s/#$key#/$val/g; ";
+ }
+
+ autoscript($package, "$script_type", "$script_type-apache2", $sed_command);
+ }
}
}
}
diff --git a/debian/debhelper/postrm-apache2 b/debian/debhelper/postrm-apache2
index 27bbef6..e3bc890 100644
--- a/debian/debhelper/postrm-apache2
+++ b/debian/debhelper/postrm-apache2
@@ -1,6 +1,8 @@
-if [ "$1" = "purge" ] && #CONDITIONAL_VARIABLE#; then
- if [ -e /usr/share/apache2/apache2-maintscript-helper ] ; then
- . /usr/share/apache2/apache2-maintscript-helper
- apache2_invoke #HELPER# #NAMES# || #ERROR_HANDLER#
+if [ "$1" = "purge" ] || [ "$1" = "remove" ] ; then
+ if #CONDITIONAL_VARIABLE#; then
+ if [ -e /usr/share/apache2/apache2-maintscript-helper ] ; then
+ . /usr/share/apache2/apache2-maintscript-helper
+ apache2_invoke #HELPER# #NAMES# || #ERROR_HANDLER#
+ fi
fi
fi
--
Debian packaging for apache2 (Apache HTTPD 2.x)
More information about the Pkg-apache-commits
mailing list