Skip to content

Commit

Permalink
Item12952: Fix shell extension installer
Browse files Browse the repository at this point in the history
 - Inconsistent usage of Package->new()
 - Better warning if default "install" is not provided.
 - Fix incorrect escaping of { in regex
 - Fix documentation of Package->new() calling parameters
  • Loading branch information
gac410 committed Oct 6, 2014
1 parent d119d8c commit 12ffa0e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 28 deletions.
10 changes: 3 additions & 7 deletions core/lib/Foswiki/Configure/Package.pm
Expand Up @@ -51,15 +51,11 @@ use Foswiki::Configure::Util ();
---++ ClassMethod new($root, $pkgname, $type, \%options)
* =$root= - The root of the Foswiki installation - used for file operations
* =$pkgname= - The name of the the package.
* $type - The type of package represented by this objct. Supported types include:
* Plugin - A Foswiki Extension of type Plugin - Defined in Extension/_extension_.pm
* Skin - A Foswiki Skin
* Contrib - A Foswiki Contribution or AddOn. Defined in Contrib/_extension_.pm
* Core - (future) a packaged core installation.
* =$repository= - The source repository information.
* =\%options= - A hash of options for the installation
{
module => 'Module' Name of the package being installed
EXPANDED => 0/1 Specify that archive file has already been expanded
USELOCAL => 0/1 If local versions of _installer or archives are found, use them instead of download.
NODEPS => 0/1 Set if dependencies should not be installed. Default is to always install Foswiki dependencies.
Expand All @@ -71,7 +67,7 @@ use Foswiki::Configure::Util ();
=cut

sub new {
my ( $class, $root, $repository, $module, %args ) = @_;
my ( $class, $root, $repository, %args ) = @_;
my @deps;

my $this = bless(
Expand Down
3 changes: 1 addition & 2 deletions core/lib/Foswiki/Configure/Wizards/InstallExtensions.pm
Expand Up @@ -81,8 +81,7 @@ sub _getPackage {
}
}
my $pkg =
new Foswiki::Configure::Package( $installRoot,
$repository, $args->{module}, %$args );
new Foswiki::Configure::Package( $installRoot, $repository, %$args );

return $pkg;
}
Expand Down
40 changes: 21 additions & 19 deletions core/tools/extender.pl
Expand Up @@ -91,13 +91,17 @@ sub _stop {
# processParameters
my %opts;
getopts( 'acdnoru', \%opts );

$noconfirm = $opts{a};
$nocpan = $opts{c};
$downloadOK = $opts{d};
$reuseOK = $opts{r};
$simulate = $opts{n};
$alreadyUnpacked = $opts{u};
if ( @ARGV == 0 ) {
$reporter->ERROR(
'DEFAULT \'install\' action is no longer active. Specify \'install\' if you want to install this extension.'
);
usage();
exit(0);
}
Expand Down Expand Up @@ -312,7 +316,8 @@ sub _loadInstaller {

$thispkg = Foswiki::Configure::Package->new(
"$installationRoot/",
$repository, $MODULE,
$repository,
module => $MODULE,
USELOCAL => $reuseOK,
SIMULATE => $simulate,
DIR => $installationRoot
Expand Down Expand Up @@ -374,9 +379,6 @@ sub usage {
tools/extension_installer ${MODULE} manifest
tools/extension_installer ${MODULE} dependencies
If command (install, uninstall ..) is not provided, default is to
install the extension.
Operates on the directory tree below where it is run from,
so should be run from the top level of your Foswiki installation.
Expand Down Expand Up @@ -416,6 +418,8 @@ sub usage {
# 4 If any CPAN dependences are reported - offer to satisfy them
sub _install {
my ($rootModule) = @_;
my $sim = '';
$sim = ' simulated' if ($simulate);

my $path = $MODULE;

Expand Down Expand Up @@ -450,33 +454,35 @@ sub _install {
if ($moduleVersion) {
return 0
unless ask(
"$MODULE version $moduleVersion is already installed. Are you sure you want to re-install this module?"
"$MODULE version $moduleVersion is already installed. Are you sure you want to re-install this module? $sim."
);
}
}

my ( $installed, $missing, @wiki, @cpan, @manual ) =
$thispkg->checkDependencies();
$reporter->NOTE("\nDEPENDENCIES:") if ( @$installed || @$missing );
$reporter->NOTE( "INSTALLED: ", @$installed ) if @$installed;
$reporter->NOTE( "MISSING: ", @$missing ) if @$missing;

my $instmsg = "$MODULE ready to be installed";
$instmsg .= ": ($sim )" if ($simulate);
$instmsg .=
" along with Foswiki dependencies identified above\n"
" along with missing Foswiki dependencies identified above\n"
. "(you will be asked later about any CPAN dependencies)"
if ($missing);
if (@$missing);
$instmsg .= ".\n";

$instmsg .= "Do you want to proceed with installation of $MODULE";
$instmsg .= "Do you want to proceed with$sim installation of $MODULE";
$instmsg .= " and Dependencies" if ($missing);
$instmsg .= '?';

return 0
unless ask("$instmsg");

my ( $plugins, $depCPAN ) = $thispkg->install($reporter);
my ( $ok, $plugins, $depCPAN ) = $thispkg->install($reporter);

if ( $plugins && keys %$plugins && !$simulate ) {
if ( $ok && !$simulate ) {
$reporter->NOTE(
"> Before you can use newly installed plugins, you must enable them in the Enabled Plugins section in configure."
);
Expand All @@ -492,12 +498,8 @@ sub _install {
}
}

my $err = $thispkg->errors();
if ($err) {
$reporter->ERROR($err);
}
else {
$reporter->NOTE("No errors encountered during installation\n");
if ($ok) {
$reporter->NOTE("No errors encountered during$sim installation\n");
}

$thispkg->finish();
Expand Down Expand Up @@ -550,12 +552,12 @@ sub getScriptDir {
\"
}x;

my $reBinDir = qr{
^\s*\$Foswiki::cfg\{ScriptDir\} # Variable
my $reBinDir = qr/
^\s*\$Foswiki::cfg{ScriptDir} # Variable
\s*=\s* # Equal sign - optional spaces
(?: (?:$reSqString) | (?:$reDqString) ) # delimited value
\s*;\s*$ # ending bracket
}msx;
/msx;

my $cfgfh = open my $cfg, '<', "$lscFile";
if ( !$cfgfh ) {
Expand Down

0 comments on commit 12ffa0e

Please sign in to comment.