[Pkg-apache-commits] [SCM] Debian packaging for apache2 (Apache HTTPD 2.x) branch, next, updated. d92b87422ca92f44a8bc6ec9c4dbeaef66bb26d8
Stefan Fritsch
sf at sfritsch.de
Sun Apr 1 07:50:10 UTC 2012
The following commit has been merged in the next branch:
commit d92b87422ca92f44a8bc6ec9c4dbeaef66bb26d8
Author: Stefan Fritsch <sf at sfritsch.de>
Date: Sun Apr 1 09:38:27 2012 +0200
Improve dependency handling in a2enmod
- implement warning if (module) dependencies are not enabled for .conf
files
- implement loading of the Depends/Conflicts line as separate function.
Be more strict about the syntax:
* line must start with "# Depends:"
* line must come before any non-empty non-comment lines
diff --git a/debian/a2enmod b/debian/a2enmod
index eebc10c..fee796d 100755
--- a/debian/a2enmod
+++ b/debian/a2enmod
@@ -156,33 +156,39 @@ sub doit {
# handle module dependencies
if ( $obj eq 'module' ) {
if ( $act eq 'enable' ) {
- my $depends = qx{grep "# Depends:" "$availdir/$acton.load"|cut -f2 -d:};
- $depends =~ s,^[\s\n]+,,;
- $depends =~ s,[\s\n]+$,,;
- do_deps( $acton, split( /[\n\s]+/, $depends ) ) or return 0;
-
- my $conflicts = qx{grep "# Conflicts:" "$availdir/$acton.load"|cut -f2 -d:};
- $conflicts =~ s,^[\s\n]+,,;
- $conflicts =~ s,[\s\n]+$,,;
- check_conflicts( $acton, split( /[\n\s]+/, $conflicts ) ) or return 0;
+ my @depends = get_deps("$availdir/$acton.load");
+ do_deps( $acton, @depends ) or return 0;
+
+ my @conflicts = get_deps("$availdir/$acton.load", "Conflicts");
+ check_conflicts( $acton, @conflicts ) or return 0;
}
else {
- my @depends = qx{egrep "# Depends:.*${acton}( |\$)" $enabldir/*.load};
- @depends = grep {s{^.*?/([^/]*?)\.load:.*}{$1}s} @depends;
- if ( scalar @depends ) {
+ my @depending;
+ foreach my $d (glob("$enabldir/*.load")) {
+ my @deps = get_deps($d);
+ if (is_in($acton, @deps)) {
+ $d =~ m,/([^/]+).load$,;
+ push @depending, $1;
+ }
+ }
+ if ( scalar @depending ) {
if ($force) {
- do_deps( $acton, @depends ) or return 0;
+ do_deps( $acton, @depending ) or return 0;
}
else {
error(
"The following modules depend on $acton ",
- "and need to be disabled first: @depends\n"
+ "and need to be disabled first: @depending\n"
);
return 0;
}
}
}
}
+ elsif ( $act eq 'enable' ) {
+ my @depends = get_deps("$availdir/$acton$sffx");
+ warn_deps( $acton, @depends ) or return 0;
+ }
if ( $act eq 'enable' ) {
my $check = check_link( $tgt, $link );
@@ -256,6 +262,28 @@ sub doit {
return 1;
}
+sub get_deps {
+ my $file = shift;
+ my $type = shift || "Depends";
+
+ my $fd;
+ if (!open($fd, '<', $file)) {
+ error("Can't open $file: $!");
+ return;
+ }
+ my $line;
+ while (defined ($line = <$fd>)) {
+ chomp $line;
+ if ($line =~ /^# $type:\s+(.*?)\s*$/) {
+ my $deps = $1;
+ return split( /[\n\s]+/, $deps )
+ }
+ # only check until the first non-empty non-comment line
+ last if ($line !~ /^\s*(?:#.*)?$/);
+ }
+ return;
+}
+
sub do_deps {
my $acton = shift;
foreach my $d (@_) {
@@ -268,6 +296,19 @@ sub do_deps {
return 1;
}
+sub warn_deps {
+ my $acton = shift;
+ my $modsenabldir = $ENV{APACHE_MODS_ENABLED} || "$confdir/mods-enabled";
+ foreach my $d (@_) {
+ info("Checking dependency $d for $acton:\n");
+ if ( ! -e "$modsenabldir/$d.load" ) {
+ warning("Module $d is not enabled, but $acton depends on it, aborting\n");
+ return 0;
+ }
+ }
+ return 1;
+}
+
sub check_conflicts {
my $acton = shift;
my $haderror = 0;
@@ -375,6 +416,18 @@ sub error {
print STDERR 'ERROR: ', @_;
}
+sub warning {
+ print STDERR 'WARNING: ', @_;
+}
+
+sub is_in {
+ my $needle = shift;
+ foreach my $e (@_) {
+ return 1 if $needle eq $e;
+ }
+ return 0;
+}
+
sub read_env_file {
my $file = shift;
--
Debian packaging for apache2 (Apache HTTPD 2.x)
More information about the Pkg-apache-commits
mailing list