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

Arno Töll debian at toell.net
Tue Apr 3 21:06:49 UTC 2012


The following commit has been merged in the next branch:
commit 3045436a1e737367f61c6b912d38e97b1e41a2e8
Author: Arno Töll <debian at toell.net>
Date:   Tue Apr 3 23:06:42 2012 +0200

    Add a helper script to rename sites following our .conf suffix requirement

diff --git a/debian/apache2.NEWS b/debian/apache2.NEWS
index 6858646..3f5f39b 100644
--- a/debian/apache2.NEWS
+++ b/debian/apache2.NEWS
@@ -26,16 +26,21 @@ apache2 (2.4.1-1) experimental; urgency=low
   supported anymore and works just like {sites,mods}-{available,enabled} by
   using the "a2enconf" tool. The upgrade tries to migrate known configuration
   files from /etc/apache2/conf.d/ to /etc/apache2/conf-available/ - please
-  review this changes. In addition, the default site was renamed to
-  000-default to avoid naming confusions. The rename of the config files to
-  *.conf makes the special handling inside apache2 to ignore *.dpkg-* backup
-  files obsolete. This special handling has been removed.
+  review this changes.
+  Note this means all existing sites are ignored until they get a ".conf" suffix
+  and are being re-enabled by the use of a2ensite. The script in [3] can
+  automate that for simple cases. This change also includes Debian default
+  sites, hence the default site was renamed to 000-default to avoid naming
+  confusions. The rename of the config files to *.conf makes the special
+  handling inside apache2 to ignore *.dpkg-* backup files obsolete. This special
+  handling has been removed.
 
   Packagers are advised to review their packages whether they comply with this
   new version. Please see [2] for detailed documentation and instructions
 
   [1] http://httpd.apache.org/docs/2.4/howto/auth.html
   [2] </usr/share/doc/apache2/PACKAGING>
+  [3] </usr/share/doc/apache2/migrate-sites.pl>
 
  -- Arno Töll <debian at toell.net>  Fri, 02 Mar 2012 17:38:23 +0100
 
diff --git a/debian/apache2.docs b/debian/apache2.docs
index 6de9747..5000c3b 100644
--- a/debian/apache2.docs
+++ b/debian/apache2.docs
@@ -1,3 +1,4 @@
 debian/README.backtrace
 debian/README.multiple-instances
 debian/PACKAGING
+debian/migrate-sites.pl
diff --git a/debian/changelog b/debian/changelog
index 2735294..f429756 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -7,8 +7,10 @@ apache2 (2.4.1-4) experimental; urgency=low
   * Fix "dh_apache2 does not set "x" bits on /usr/lib/apache2/modules/"
     Set directory permissions to 755 by default (Closes: #666875). Thanks Axel
     Beckert for the hint.
+  * Add /usr/share/doc/apache2/migrate-sites.pl, a script to assist users to
+    give sites a .conf suffix, add a hint to the NEWS file.
 
- -- Arno Töll <arno at debian.org>  Mon, 02 Apr 2012 10:49:09 +0200
+ -- Arno Töll <arno at debian.org>  Tue, 03 Apr 2012 22:47:47 +0200
 
 apache2 (2.4.1-3) experimental; urgency=low
 
diff --git a/debian/migrate-sites.pl b/debian/migrate-sites.pl
new file mode 100644
index 0000000..8296844
--- /dev/null
+++ b/debian/migrate-sites.pl
@@ -0,0 +1,62 @@
+#! /usr/bin/perl
+
+#
+# Rename existing sites in $SITES_AVAILABLE to make sure they have a
+# .conf suffix. update symlinks in $SITES_ENABLED if necessary
+#
+# Warning: This script does not work if you didn't use a2ensite/a2dissite to
+# manage your sites
+#
+
+use strict;
+use File::Copy;
+use File::Spec;
+use File::Basename;
+
+my $SITES_AVAILABLE = "/etc/apache2/sites-available";
+my $SITES_ENABLED = "/etc/apache2/sites-enabled";
+
+my %SITES = (
+	"$SITES_AVAILABLE" => [],
+	"$SITES_ENABLED" => []
+);
+
+sub error
+{
+	my $reason = shift;
+	print STDERR "$reason\n";
+	exit 1;
+}
+
+foreach my $key (keys %SITES)
+{
+	error("No such directory: $key") unless -d $key;
+
+	opendir(DIR, $key) || error("$key: $!");
+	push $SITES{$key}, grep { m#^[^\.]# && $_ !~ m/default|default-ssl/ && $_ !~ m#\.conf$# } readdir(DIR);
+	closedir(DIR);
+}
+
+foreach my $site (@{ $SITES{$SITES_AVAILABLE} })
+{
+		print("rename $site -> $site.conf\n");
+		my $curname = $SITES_AVAILABLE . "/" . $site;
+		my $newname = $curname . ".conf";
+		my $curlink = $SITES_ENABLED . "/" . $site;
+		my $newlink = $curlink . ".conf";
+
+		if (-e $curname)
+		{
+			move($curname, $newname) || error("Could not rename file $curname: $!");
+			if ( grep { $_ eq $site && -l $SITES_ENABLED . "/" . $_ } @{ $SITES{$SITES_ENABLED} } )
+			{
+				print("re-enable site: $site as $site.conf\n");
+				symlink( File::Spec->abs2rel( $newname,	dirname($newlink)), $newlink ) || error("Could not create link $newlink: $1");
+				if ( -l $curlink )
+				{
+					unlink($curlink)
+				}
+			}
+		}
+}
+

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



More information about the Pkg-apache-commits mailing list