Name

Feature — specify Interchange "feature" for activation in the catalog

SYNOPSIS

feature_name

DESCRIPTION

Specify Interchange "feature" for inclusion in the current catalog.

For an introduction to Interchange "features", please see the feature glossary entry.

DIRECTIVE TYPE AND DEFAULT VALUE

Catalog directive

EXAMPLES

Example: Activating a feature

Feature quickpoll

NOTES

AVAILABILITY

Feature is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: lib/Vend/Config.pm
Line 596

['Feature',          'feature',          ''],

Source: lib/Vend/Config.pm
Line 2269 (context shows lines 2269-2387)

sub parse_feature {
my ($var, $value) = @_;
my $c = $C->{$var} || {};
return $c unless $value;

$value =~ s/^\s+//;
$value =~ s/\s+$//;
my $fdir = Vend::File::catfile($Global::FeatureDir, $value);

unless(-d $fdir) {
  config_warn("Feature '%s' not found, skipping.", $value);
  return $c;
}

# Get the global install files and remove them from the config list
my @gfiles = glob("$fdir/*.global");
my %seen;
@seen{@gfiles} = @gfiles;

# Get the init files and remove them from the config list
my @ifiles = glob("$fdir/*.init");
@seen{@ifiles} = @ifiles;

# Get the uninstall files and remove them from the config list
my @ufiles = glob("$fdir/*.uninstall");
@seen{@ufiles} = @ifiles;

# Any other files are config files
my @cfiles = grep ! $seen{$_}++, glob("$fdir/*");

# directories are for copying
my @cdirs = grep -d $_, @cfiles;

# strip the directories from the config list, leaving catalog.cfg stuff
@cfiles   = grep -f $_, @cfiles;

# Don't install global more than once
@gfiles = grep ! $Global::FeatureSeen{$_}++, @gfiles;

# Place the catalog configuration in the config list
unshift @include, @cfiles;

my @copy;
my $wanted = sub {
  return unless -f $_;
  my $n = $File::Find::name;
  $n =~ s{^$fdir/}{};
  my $d = $File::Find::dir;
  $d =~ s{^$fdir/}{};
  push @copy, [$n, $d];
};

if(@cdirs) {
  File::Find::find({ wanted => $wanted, follow => 1 }, @cdirs);
}
#::logDebug("gfiles=" . ::uneval(\@gfiles));
#::logDebug("cfiles=" . ::uneval(\@cfiles));
#::logDebug("ifiles=" . ::uneval(\@ifiles));
#::logDebug("ufiles=" . ::uneval(\@ufiles));
#::logDebug("cdirs=" . ::uneval(\@cdirs));
#::logDebug("copy=" . ::uneval(\@copy));

for(@copy) {
  my ($n, $d) = @$_;

  my $tf = Vend::File::catfile($C->{VendRoot}, $n);
  next if -f $tf;

  my $td = Vend::File::catfile($C->{VendRoot}, $d);
  unless(-d $td) {
    File::Path::mkpath($td)
      or do {
        config_warn("Feature %s not able to make directory %s", $value, $td);
        next;
      };
  }
  File::Copy::copy("$fdir/$n", $tf)
    or do {
      config_warn("Feature %s not able to copy %s to %s", $value, "$fdir/$n", $tf);
      next;
    };
}

for(@gfiles) {
  global_chunk($_);
}

if(@ifiles) {
  my $initdir = Vend::File::catfile($C->{ConfDir}, 'init', $value);
  File::Path::mkpath($initdir) unless -d $initdir;
  my $unfile = Vend::File::catfile($initdir, 'uninstall');

  ## Feature was previously uninstalled, we *do* need to run init
  my $ignore = -f $unfile;

  if($ignore) {
    unlink $unfile
        or die errmsg("Couldn't unlink $unfile: $!");
  }

  for(@ifiles) {
    my $fn = $_;
    $fn =~ s{^$fdir/}{};
    if($ignore) {
      unlink "$initdir/$fn"
        or die errmsg("Couldn't unlink $fn: $!");
    }

    next if -f "$initdir/$fn";
    $C->{Init} ||= [];
    push @{$C->{Init}}, [$_, "$initdir/$fn"];
  }
}

#::logDebug("Init=" . ::uneval($C->{Init}));

$c->{$value} = 1;
return $c;
}

AUTHORS

Mike Heins

SEE ALSO

FeatureDir(7ic)

DocBook! Interchange!