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

Arno Töll debian at toell.net
Thu Feb 16 17:51:23 UTC 2012


The following commit has been merged in the next branch:
commit 9a3d3f33489577ca698dab2c13c9a5030436d587
Author: Arno Töll <debian at toell.net>
Date:   Thu Feb 16 02:27:13 2012 +0100

    * move files from conf.d to conf-available
    * support conf-available in a2enmod
    * write manpages for a2enconf and a2disconf
    * Rewrite maintainer scripts to do a proper transition of configuration files
      moved from one location to another. This holds true for:
      + debian/config-dir/conf.d/charset
      + debian/config-dir/conf.d/localized-error-pages
      + debian/config-dir/conf.d/other-vhosts-access-log
      + debian/config-dir/conf.d/security
    * enable these configuration files in postinst
    * update debian/changelog

diff --git a/debian/a2enmod b/debian/a2enmod
index 2073d51..027fe0a 100755
--- a/debian/a2enmod
+++ b/debian/a2enmod
@@ -18,7 +18,7 @@ GetOptions(
 ) or exit 2;
 
 my $basename = basename($0);
-$basename =~ /^a2(en|dis)(mod|site)((?:-.+)?)$/
+$basename =~ /^a2(en|dis)(mod|site|conf)((?:-.+)?)$/
     or die "$basename call name unknown\n";
 my $act        = $1;
 my $obj        = $2;
@@ -41,6 +41,12 @@ if ( $obj eq 'mod' ) {
     $sffx   = '.load';
     $reload = 'restart';
 }
+elsif ( $obj eq 'conf' ) {
+    $obj    = 'conf';
+    $dir    = 'conf';
+    $sffx   = '.conf';
+    $reload = 'reload';
+}
 else {
     $dir    = 'sites';
     $sffx   = '';
diff --git a/debian/apache2-data.manpages b/debian/apache2-data.manpages
index a2ff114..d5f0c8d 100644
--- a/debian/apache2-data.manpages
+++ b/debian/apache2-data.manpages
@@ -4,3 +4,5 @@ debian/manpages/a2enmod.8
 debian/manpages/a2dissite.8
 debian/manpages/a2dismod.8
 debian/manpages/a2ensite.8
+debian/manpages/a2enconf.8
+debian/manpages/a2disconf.8
diff --git a/debian/apache2.dirs b/debian/apache2.dirs
index c3f300a..01b06e5 100644
--- a/debian/apache2.dirs
+++ b/debian/apache2.dirs
@@ -1,6 +1,6 @@
 etc/apache2/mods-enabled
+etc/apache2/conf-enabled
 etc/apache2/sites-enabled
-etc/apache2/conf.d
 etc/logrotate.d
 usr/lib/cgi-bin
 usr/share/apache2
diff --git a/debian/apache2.links b/debian/apache2.links
index 26ca9cd..ec9d92e 100644
--- a/debian/apache2.links
+++ b/debian/apache2.links
@@ -2,4 +2,6 @@ usr/share/bug/apache2-common/script	usr/share/bug/apache2/script
 usr/sbin/a2enmod 			usr/sbin/a2dismod
 usr/sbin/a2enmod 			usr/sbin/a2ensite
 usr/sbin/a2enmod 			usr/sbin/a2dissite
+usr/sbin/a2enmod 			usr/sbin/a2enconf
+usr/sbin/a2enmod 			usr/sbin/a2disconf
 usr/sbin/apache2ctl 			usr/sbin/apachectl
diff --git a/debian/apache2.postinst b/debian/apache2.postinst
index bc4384e..23c7d58 100755
--- a/debian/apache2.postinst
+++ b/debian/apache2.postinst
@@ -30,6 +30,12 @@ OBSOLETE_CONFFILES="/etc/apache2/mods-available/authz_default.load
 /etc/apache2/mods-available/ident.load
 /etc/apache2/mods-available/imagemap.load"
 
+MOVED_CONFFILES_IN="charset
+localized-error-pages
+other-vhosts-access-log
+security"
+
+
 
 # the functions below need to be idempotent, however we guess the upgrade based
 # on obsolete conffiles which might be removed anytime. Thus, remember we were
@@ -55,8 +61,15 @@ we_are_upgrading_from_squeeze()
 	fi
 
 	for CONFFILE in $OBSOLETE_CONFFILES ; do
-		SQUEEZE_UPGRADE=1
 		if [ -e "$CONFFILE.dpkg-backup" ] || [ -e "$CONFFILE.dpkg-remove" ] ; then
+			SQUEEZE_UPGRADE=1
+			return 0
+		fi
+	done
+
+	for CONFFILE in $MOVED_CONFFILES_IN ; do
+		if [ -e "/etc/apache2/conf.d/$CONFFILE.dpkg-remove" ] ; then
+			SQUEEZE_UPGRADE=1
 			return 0
 		fi
 	done
@@ -65,7 +78,7 @@ we_are_upgrading_from_squeeze()
 }
 
 
-# The function below is licensed GPL-2+ and was written by dpkg maintainers
+# The two functions below is licensed GPL-2+ and was written by dpkg maintainers
 # See the dpkg-maintscript-helper script for details
 
 remove_conffiles()
@@ -87,6 +100,35 @@ remove_conffiles()
         fi
 }
 
+mv_conffiles()
+{
+	# same rationale as above
+	if we_are_upgrading_from_squeeze $@ ; then
+		for CONFFILE in $MOVED_CONFFILES_IN ; do
+			OLDCONFFILE="/etc/apache2/conf.d/$CONFFILE"
+			NEWCONFFILE="/etc/apache2/conf-available/$CONFFILE.conf"
+
+			rm -f $OLDCONFFILE.dpkg-remove
+			[ -e "$OLDCONFFILE" ] || return 0
+
+			echo "Preserving user changes to $NEWCONFFILE (renamed from $OLDCONFFILE)..."
+			mv -f "$NEWCONFFILE" "$NEWCONFFILE.dpkg-new"
+			mv -f "$OLDCONFFILE" "$NEWCONFFILE"
+		done
+
+		if [ -d /etc/apache2/conf.d ] && [ ! "$(ls -A /etc/apache2/conf.d)" ] ; then
+			echo "Removing obsolete directory /etc/apache2/conf.d"
+			rmdir /etc/apache2/conf.d
+		fi
+
+		if [ -d /etc/apache2/conf.d ] && [ "$(ls -A /etc/apache2/conf.d)" ]	; then
+			echo "Directory /etc/apache2/conf.d is not empty - leaving as is"
+			echo "Please note, that directory is considered obsolete and not read anymore by a standard apache2.conf file anymore"
+		fi
+
+	fi
+}
+
 
 enable_default_mpm()
 {
@@ -127,6 +169,13 @@ enable_default_modules()
         done
 }
 
+enable_default_conf()
+{
+	for conf in charset localized-error-pages other-vhosts-access-log security ; do
+		a2enconf -q $conf
+	done
+}
+
 install_default_site()
 {
 
@@ -187,10 +236,12 @@ case "$1" in
         configure)
 
                 remove_conffiles $@
+		mv_conffiles $@
                 refresh_modules $@
                 enable_default_mpm $@
                 install_default_files $@
                 enable_default_modules $@
+		enable_default_conf $@
 
                 if [ -z "$2" ]; then
                         install_default_site
diff --git a/debian/apache2.postrm b/debian/apache2.postrm
index b5f3f04..d176c5e 100644
--- a/debian/apache2.postrm
+++ b/debian/apache2.postrm
@@ -30,6 +30,11 @@ OBSOLETE_CONFFILES="/etc/apache2/mods-available/authz_default.load
 /etc/apache2/mods-available/ident.load
 /etc/apache2/mods-available/imagemap.load"
 
+MOVED_CONFFILES_IN="charset
+localized-error-pages
+other-vhosts-access-log
+security"
+
 
 case "$1" in
     purge)
@@ -54,6 +59,20 @@ case "$1" in
                 fi
         done
 
+	for CONFFILE in $MOVED_CONFFILES_IN ; do
+
+		CONFFILE="/etc/apache2/conf.d/$CONFFILE"
+
+		if [ -e "$CONFFILE.dpkg-remove" ]; then
+			echo "Reinstalling $CONFFILE that was moved away"
+			mv "$CONFFILE.dpkg-remove" "$CONFFILE"
+		fi
+		if [ -e "$CONFFILE.dpkg-backup" ]; then
+			echo "Reinstalling $CONFFILE that was backupped"
+			mv "$CONFFILE.dpkg-backup" "$CONFFILE"
+		fi
+	done
+
         # post installation cleanup
         if [ -e /etc/apache2/.apache2_mpm_selected ] ; then
                 rm -f /etc/apache2/.apache2_mpm_selected
diff --git a/debian/apache2.preinst b/debian/apache2.preinst
index ad759b8..503fb9a 100644
--- a/debian/apache2.preinst
+++ b/debian/apache2.preinst
@@ -25,6 +25,14 @@ OBSOLETE_CONFFILES="/etc/apache2/mods-available/authz_default.load
 /etc/apache2/mods-available/ident.load
 /etc/apache2/mods-available/imagemap.load"
 
+# these are all moved from /etc/apache2/conf.d/ to /etc/apache2/conf-available.
+# The scripts deal with that. Don't put any file in here which is located
+# somewhere else.
+MOVED_CONFFILES_IN="charset
+localized-error-pages
+other-vhosts-access-log
+security"
+
 
 obsolete_conffile_exists()
 {
@@ -34,10 +42,16 @@ obsolete_conffile_exists()
 		fi
 	done
 
+	for CONFFILE in $MOVED_CONFFILES_IN ; do
+		if [ -e "/etc/apache2/conf.d/$CONFFILE" ] ; then
+			return 0
+		fi
+	done
+
 	return 1
 }
 
-# The function below is licensed GPL-2+ and was written by dpkg maintainers
+# The two functions below is licensed GPL-2+ and was written by dpkg maintainers
 # See the dpkg-maintscript-helper script for details
 prepare_rm_conffile()
 {
@@ -45,7 +59,7 @@ prepare_rm_conffile()
                 [ -e "$CONFFILE" ] || continue
 
                 local md5sum="$(md5sum $CONFFILE | sed -e 's/ .*//')"
-                local old_md5sum="$(dpkg-query -W -f='${Conffiles}' $PACKAGE | \
+                local old_md5sum="$(dpkg-query -W -f='${Conffiles}' apache2.2-common apache2 | \
                         sed -n -e "\' $CONFFILE ' { s/ obsolete$//; s/.* //; p }")"
                 if [ "$md5sum" != "$old_md5sum" ]; then
                         echo "Obsolete conffile $CONFFILE has been modified by you."
@@ -58,7 +72,21 @@ prepare_rm_conffile()
         done
 }
 
+prepare_mv_conffile()
+{
+	for CONFFILE in $OBSOLETE_CONFFILES ; do
+		CONFFILE="/etc/apache2/conf.d/$CONFFILE"
+		[ -e "$CONFFILE" ] || return 0
+
+		local md5sum="$(md5sum $CONFFILE | sed -e 's/ .*//')"
+		local old_md5sum="$(dpkg-query -W -f='${Conffiles}' apache2.2-common apache2 | \
+			sed -n -e "\' $CONFFILE ' { s/ obsolete$//; s/.* //; p }")"
 
+		if [ "$md5sum" = "$old_md5sum" ]; then
+			mv -f "$CONFFILE" "$CONFFILE.dpkg-remove"
+		fi
+	done
+}
 
 case "$1" in
     install|upgrade)
@@ -82,6 +110,7 @@ case "$1" in
 	# installed
 	if [ -n "$2" ] || obsolete_conffile_exists ; then
 		prepare_rm_conffile
+		prepare_mv_conffile
        fi
 
     ;;
diff --git a/debian/config-dir/conf.d/charset.conf b/debian/config-dir/conf-available/charset.conf
similarity index 100%
rename from debian/config-dir/conf.d/charset.conf
rename to debian/config-dir/conf-available/charset.conf
diff --git a/debian/config-dir/conf.d/localized-error-pages.conf b/debian/config-dir/conf-available/localized-error-pages.conf
similarity index 100%
rename from debian/config-dir/conf.d/localized-error-pages.conf
rename to debian/config-dir/conf-available/localized-error-pages.conf
diff --git a/debian/config-dir/conf.d/other-vhosts-access-log.conf b/debian/config-dir/conf-available/other-vhosts-access-log.conf
similarity index 100%
rename from debian/config-dir/conf.d/other-vhosts-access-log.conf
rename to debian/config-dir/conf-available/other-vhosts-access-log.conf
diff --git a/debian/config-dir/conf.d/security.conf b/debian/config-dir/conf-available/security.conf
similarity index 100%
rename from debian/config-dir/conf.d/security.conf
rename to debian/config-dir/conf-available/security.conf
diff --git a/debian/manpages/a2disconf.8 b/debian/manpages/a2disconf.8
new file mode 100644
index 0000000..a349380
--- /dev/null
+++ b/debian/manpages/a2disconf.8
@@ -0,0 +1,74 @@
+.\"                                      Hey, EMACS: -*- nroff -*-
+.\" First parameter, NAME, should be all caps
+.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
+.\" other parameters are allowed: see man(7), man(1)
+.TH A2ENCONF 8 "14 February 2012"
+.\" Please adjust this date whenever revising the manpage.
+.\"
+.\" Some roff macros, for reference:
+.\" .nh        disable hyphenation
+.\" .hy        enable hyphenation
+.\" .ad l      left justify
+.\" .ad b      justify to both left and right margins
+.\" .nf        disable filling
+.\" .fi        enable filling
+.\" .br        insert line break
+.\" .sp <n>    insert n+1 empty lines
+.\" for manpage-specific macros, see man(7)
+.SH NAME
+a2enconf, a2disconf \- enable or disable an apache2 module
+.SH SYNOPSIS
+.B a2enmod
+.RI [ configuration ]
+.PP
+.B a2dismod
+.RI [ configuration ]
+.SH DESCRIPTION
+This manual page documents briefly the
+.B a2enconf
+and
+.B a2disconf
+commands.
+.PP
+.B a2enmod
+is a script that enables the specified configuration file within the
+.B apache2
+configuration.  It does this by creating symlinks within
+.BR /etc/apache2/conf-enabled .
+Likewise,
+.B a2disconf
+disables a specific configuration part by removing those symlinks.  It is not an
+error to enable a module which is already enabled, or to disable one which is
+already disabled.
+.PP
+Note that many configuration file may have a dependency to specific modules.
+Unlike module dependencies, these are not resolved automatically. Configuration
+fragments stored in the conf-available directory are considered non-essential or
+being installed and manged by reverse dependencies (e.g. web scripts).
+.B apache2
+.SH EXAMPLES
+.RS
+.B "a2enmod security"
+.br
+.B "a2dismod charset"
+.RE
+.PP
+Enables Apache security directives stored in the
+.B security
+configuration files, and disables the
+.B charset
+configuration.
+.SH FILES
+.TP
+.B /etc/apache2/conf-available
+Directory with files giving information on available configuration files.
+.TP
+.B /etc/apache2/conf-enabled
+Directory with links to the files in
+.B conf-available
+for enabled modules.
+.SH "SEE ALSO"
+.BR apache2ctl (8).
+.SH AUTHOR
+This manual page was written by Arno Toell <debian at toell.net> for the Debian
+GNU/Linux distribution, as it is a Debian-specific script with the package.
diff --git a/debian/manpages/a2enconf.8 b/debian/manpages/a2enconf.8
new file mode 100644
index 0000000..a349380
--- /dev/null
+++ b/debian/manpages/a2enconf.8
@@ -0,0 +1,74 @@
+.\"                                      Hey, EMACS: -*- nroff -*-
+.\" First parameter, NAME, should be all caps
+.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
+.\" other parameters are allowed: see man(7), man(1)
+.TH A2ENCONF 8 "14 February 2012"
+.\" Please adjust this date whenever revising the manpage.
+.\"
+.\" Some roff macros, for reference:
+.\" .nh        disable hyphenation
+.\" .hy        enable hyphenation
+.\" .ad l      left justify
+.\" .ad b      justify to both left and right margins
+.\" .nf        disable filling
+.\" .fi        enable filling
+.\" .br        insert line break
+.\" .sp <n>    insert n+1 empty lines
+.\" for manpage-specific macros, see man(7)
+.SH NAME
+a2enconf, a2disconf \- enable or disable an apache2 module
+.SH SYNOPSIS
+.B a2enmod
+.RI [ configuration ]
+.PP
+.B a2dismod
+.RI [ configuration ]
+.SH DESCRIPTION
+This manual page documents briefly the
+.B a2enconf
+and
+.B a2disconf
+commands.
+.PP
+.B a2enmod
+is a script that enables the specified configuration file within the
+.B apache2
+configuration.  It does this by creating symlinks within
+.BR /etc/apache2/conf-enabled .
+Likewise,
+.B a2disconf
+disables a specific configuration part by removing those symlinks.  It is not an
+error to enable a module which is already enabled, or to disable one which is
+already disabled.
+.PP
+Note that many configuration file may have a dependency to specific modules.
+Unlike module dependencies, these are not resolved automatically. Configuration
+fragments stored in the conf-available directory are considered non-essential or
+being installed and manged by reverse dependencies (e.g. web scripts).
+.B apache2
+.SH EXAMPLES
+.RS
+.B "a2enmod security"
+.br
+.B "a2dismod charset"
+.RE
+.PP
+Enables Apache security directives stored in the
+.B security
+configuration files, and disables the
+.B charset
+configuration.
+.SH FILES
+.TP
+.B /etc/apache2/conf-available
+Directory with files giving information on available configuration files.
+.TP
+.B /etc/apache2/conf-enabled
+Directory with links to the files in
+.B conf-available
+for enabled modules.
+.SH "SEE ALSO"
+.BR apache2ctl (8).
+.SH AUTHOR
+This manual page was written by Arno Toell <debian at toell.net> for the Debian
+GNU/Linux distribution, as it is a Debian-specific script with the package.

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



More information about the Pkg-apache-commits mailing list