[Pkg-apache-commits] [SCM] Debian packaging for apache2 (Apache HTTPD 2.x) branch, next, updated. fdb6503c66bbafea8e92a86c26fa2653ee503253
Arno Töll
debian at toell.net
Sat Feb 25 02:16:57 UTC 2012
The following commit has been merged in the next branch:
commit 5ddd369768cc8e2d441a1e64992dcd8ae582ca63
Author: Arno Töll <debian at toell.net>
Date: Sat Feb 25 00:25:49 2012 +0100
Provide dh_apache2
* Provide dh_apache2 which can be used by reverse dependencies to build their
packages. dh_apache2 can install files to /etc/apache2/{conf, sites,
mods}_available and /usr/lib/apache2/modules. It also manages maintainer
scripts.
* Provide a dh(1) sequence addon calling dh_apache2 upon request
* Warning: dh_apache2 should not reside in apache2-dev in the end. The
backend information interface is a stub only. dh_apache2 needs a dependency
against debhelper >= 7.0.50, but I omitted that for now, as apache2-dev is not
where this tool should be provided
diff --git a/debian/apache2-dev.install b/debian/apache2-dev.install
index f5d2707..785dd5b 100644
--- a/debian/apache2-dev.install
+++ b/debian/apache2-dev.install
@@ -1,3 +1,7 @@
/usr/include/apache2
/usr/share/apache2/build
/usr/bin/apxs
+debian/debhelper/dh_apache2 /usr/bin
+debian/debhelper/apache2.pm /usr/share/perl5/Debian/Debhelper/Sequence/
+debian/debhelper/postinst-apache2 /usr/share/debhelper/autoscripts/
+debian/debhelper/postrm-apache2 /usr/share/debhelper/autoscripts/
diff --git a/debian/changelog b/debian/changelog
index 4874b85..c2ecf15 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -92,6 +92,11 @@ apache2 (2.4.1-1) experimental; urgency=low
proxy_express, proxy_fcgi, proxy_fdpass, proxy_html, ratelimit, reflector
remoteip, request, session, session_cookie, session_crypto, session_dbd
(Closes: #400881)
+ * Provide a dh_apache2 debhelper which can be used by reverse dependencies to
+ install modules, module configuration files, site configuration files and global
+ configuration files which need to be registered to the Apache web server.
+ Thus, dh_apache2 can be used for Apache web server modules and web
+ applications providing configuration files for Apache.
[ Stefan Fritsch ]
@@ -102,7 +107,7 @@ apache2 (2.4.1-1) experimental; urgency=low
(Closes: #402567)
* Update the README.Debian file
- -- Arno Töll <debian at toell.net> Thu, 16 Feb 2012 21:34:15 +0100
+ -- Arno Töll <debian at toell.net> Sat, 25 Feb 2012 00:21:03 +0100
apache2 (2.2.22-1) unstable; urgency=low
diff --git a/debian/debhelper/apache2.pm b/debian/debhelper/apache2.pm
new file mode 100644
index 0000000..204e61c
--- /dev/null
+++ b/debian/debhelper/apache2.pm
@@ -0,0 +1,8 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use Debian::Debhelper::Dh_Lib;
+
+insert_after("dh_install", "dh_apache2");
+
+1;
diff --git a/debian/debhelper/dh_apache2 b/debian/debhelper/dh_apache2
new file mode 100755
index 0000000..6ea6ab1
--- /dev/null
+++ b/debian/debhelper/dh_apache2
@@ -0,0 +1,224 @@
+#! /usr/bin/perl
+
+use strict;
+use File::Find;
+use Debian::Debhelper::Dh_Lib;
+
+sub apache_api_version
+{
+ # TODO: replace me
+ return "apache2-api-20111203";
+}
+
+
+sub apache_version
+{
+ # TODO: replace me
+ return ">= 2.2~";
+}
+
+sub apache_api_installdir
+{
+ # TODO: replace me
+ return "/usr/lib/apache2/modules/";
+}
+
+sub apache_conf_installdir
+{
+ my $type = shift;
+ # TODO: replace me
+ return "etc/apache2/${type}-available/"
+}
+
+
+init(options => {
+ "conditional=s" => \$dh{CONDITIONAL},
+});
+
+if (!$dh{CONDITIONAL})
+{
+ $dh{CONDITIONAL} = "true";
+}
+
+foreach my $package (getpackages())
+{
+ my %PACKAGE_TYPE = (
+ has_a_module => [],
+ has_a_conf_file => [],
+ has_a_site_conf => [],
+ dependency_line => "",
+ handler => $dh{ERROR_HANDLER},
+ conditional => $dh{CONDITIONAL}
+ );
+
+ my $file = pkgfile($package, "apache2");
+ my $tmp = tmpdir($package);
+
+ my @files_to_register = filedoublearray($file, ".") if $file;
+ foreach my $line (@files_to_register)
+ {
+ my $type = lc(shift @{$line}) if $line->[0];
+ my $source = shift @{$line} if $line->[0];
+ my @arguments = map {"$_ "} @{$line};
+
+ $type .= "s" unless $type eq "conf";
+ my $installdir = $tmp . "/" . apache_conf_installdir($type);
+
+ #verbose_print("$type -- $source -- @arguments\n\n");
+
+ if ($type eq "mods" or $type eq "sites" or $type eq "conf")
+ {
+ my $basesource = basename($source);
+
+ if ($type eq "mods")
+ {
+ if ($basesource =~ m/\.load$/)
+ {
+ my $enablename = $basesource;
+ $enablename =~ s/\.load$//;
+ push @{$PACKAGE_TYPE{'has_a_module'}}, $enablename;
+ verbose_print("Installing module configuration $enablename into $installdir\n");
+ }
+ elsif ($basesource =~ m/\.so$/)
+ {
+ my $modinstalldir = $tmp . "/" . apache_api_installdir();
+ verbose_print("Installing module binary $source into $modinstalldir\n");
+ if (! -d $modinstalldir)
+ {
+ complex_doit("mkdir","-p", $modinstalldir);
+ }
+ complex_doit("cp", $source, $modinstalldir);
+ complex_doit("chmod","644","$modinstalldir");
+ next;
+ }
+
+ error("module: \"$basesource\" needs .conf, .so or .load suffix") if $basesource !~ m/\.(conf|load|so)/;
+ }
+ elsif ($type eq "sites")
+ {
+ push @{$PACKAGE_TYPE{'has_a_site_conf'}}, $basesource;
+ verbose_print("Installing site configuration $basesource into $installdir\n");
+ }
+ elsif($type eq "conf")
+ {
+
+ if ($#arguments > 0)
+ {
+ $PACKAGE_TYPE{'dependency_line'} .= " | " . join("", @arguments);
+ }
+
+ if ($basesource =~ m/\.conf/)
+ {
+ my $enablename = $basesource;
+ $enablename =~ s/\.conf$//;
+ push
+ @{$PACKAGE_TYPE{'has_a_conf_file'}}, $enablename;
+ verbose_print("Installing global configuration $enablename into $installdir\n");
+ }
+ error("configuration file: \"$basesource\" needs .conf suffix") if $basesource !~ m/\.conf/;
+ }
+
+ if (! -d $installdir)
+ {
+ complex_doit("mkdir","-p",$installdir);
+ }
+ complex_doit("cp",$source,$installdir);
+ complex_doit("chmod","644","$installdir/$basesource");
+
+ }
+ else
+ {
+ error("Unknown parameter: $type\n");
+ }
+
+ }
+
+
+ if (! $file)
+ {
+ # do black magic only if there is no .apache2 configuration file
+ find({ no_chdir => 1,
+ wanted => sub
+ {
+ my ($dir, $file) = (dirname($File::Find::name), basename($File::Find::name));
+
+ if ($dir =~ m#etc/apache2/mods-available# and $file =~ m#.(load|conf)$#)
+ {
+ verbose_print("package $package appears to be a web server module\n");
+ push @{$PACKAGE_TYPE{'has_a_module'}}, $file if $file =~ m/\.load/;
+ }
+ if ($dir =~ m#etc/apache2/sites-available# and $file =~ m#.conf$#)
+ {
+ verbose_print("package $package appears to contain a virtual host confoguration\n");
+ push @{$PACKAGE_TYPE{'has_a_site_conf'}}, $file;
+ }
+ if ($dir =~ m#etc/apache2/conf-available# and $file =~ m#.conf$#)
+ {
+ verbose_print("package $package appears to contaqin a global configuration file \n");
+ push @{$PACKAGE_TYPE{'has_a_conf_file'}}, $file;
+ }
+
+
+
+ }}, tmpdir($package));
+ }
+
+
+ my @postinst_autoscripts;
+
+ if ($#{$PACKAGE_TYPE{'has_a_module'}} >= 0)
+ {
+ if ($package !~ m/libapache2-mod-\w+?/)
+ {
+ warning("Package $package appears to be an Apache module. It should comply to the package naming scheme libapache2-mod-<modulename>\n");
+ }
+ addsubstvar($package, "misc:Depends", apache_api_version());
+
+ my $modules = "";
+ foreach my $module (@{$PACKAGE_TYPE{'has_a_module'}})
+ {
+ $modules .= "$module ";
+ }
+
+ push @postinst_autoscripts, ["a2enmod", $modules];
+ }
+
+ if ($#{$PACKAGE_TYPE{'has_a_conf_file'}} >= 0 or $#{$PACKAGE_TYPE{'has_a_site_conf'}} >= 0)
+ {
+ $PACKAGE_TYPE{'dependency_line'} .= "| httpd";
+ addsubstvar($package, "misc:Recommends", "apache2 (" . apache_version() . ") " . $PACKAGE_TYPE{'dependency_line'} );
+
+ my $confs = "";
+ my $sites = "";
+
+ foreach my $conf (@{$PACKAGE_TYPE{'has_a_conf_file'}})
+ {
+ $confs .= "$conf ";
+ }
+
+ foreach my $site (@{$PACKAGE_TYPE{'has_a_site_conf'}})
+ {
+ $sites .= "$site ";
+ }
+
+ if ($confs)
+ {
+ push @postinst_autoscripts, ["a2enconf", $confs];
+ }
+ if ($sites)
+ {
+ push @postinst_autoscripts, ["a2ensite", $sites];
+ }
+
+ }
+
+ if (! $dh{NOSCRIPTS})
+ {
+ foreach my $ref (@postinst_autoscripts)
+ {
+ autoscript($package, "postinst", "postinst-apache2", "s/#HELPER#/$ref->[0]/; s/#NAMES#/$ref->[1]/; s/#ERROR_HANDLER#/$PACKAGE_TYPE{'handler'}/; s/#CONDITIONAL_VARIABLE#/$PACKAGE_TYPE{'conditional'}/;");
+ $ref->[0] =~ s/a2en/a2dis/;
+ autoscript($package, "postrm", "postrm-apache2", "s/#HELPER#/$ref->[0]/; s/#NAMES#/$ref->[1]/; s/#ERROR_HANDLER#/$PACKAGE_TYPE{'handler'}/; s/#CONDITIONAL_VARIABLE#/$PACKAGE_TYPE{'conditional'}/;");
+ }
+ }
+}
diff --git a/debian/debhelper/postinst-apache2 b/debian/debhelper/postinst-apache2
new file mode 100755
index 0000000..41cf1b5
--- /dev/null
+++ b/debian/debhelper/postinst-apache2
@@ -0,0 +1,12 @@
+if [ "$1" = "configure" ] && #CONDITIONAL_VARIABLE#; then
+ if [ -x "/usr/sbin/#HELPER#" ] ; then
+ for S in #NAMES# ; do
+ /usr/sbin/#HELPER# -q $S || #ERROR_HANDLER#
+ done
+
+ if [ -x "/etc/init.d/apache2" ]; then
+ invoke-rc.d apache2 restart || #ERROR_HANDLER#
+ fi
+
+ fi
+fi
diff --git a/debian/debhelper/postrm-apache2 b/debian/debhelper/postrm-apache2
new file mode 100755
index 0000000..7e9fbaa
--- /dev/null
+++ b/debian/debhelper/postrm-apache2
@@ -0,0 +1,12 @@
+if [ "$1" = "purge" ] && #CONDITIONAL_VARIABLE# ; then
+ if [ -x "/usr/sbin/#HELPER#" ] ; then
+ for S in #NAMES# ; do
+ /usr/sbin/#HELPER# -q $S || #ERROR_HANDLER#
+ done
+
+ if [ -x "/etc/init.d/apache2" ]; then
+ invoke-rc.d apache2 restart || #ERROR_HANDLER#
+ fi
+
+ fi
+fi
--
Debian packaging for apache2 (Apache HTTPD 2.x)
More information about the Pkg-apache-commits
mailing list