diff options
author | Joey Hess <joey@kodama.kitenet.net> | 2008-08-05 20:40:49 -0400 |
---|---|---|
committer | Joey Hess <joey@kodama.kitenet.net> | 2008-08-05 20:40:49 -0400 |
commit | ea6dc3832585d8aca784c21d6f91436848a45039 (patch) | |
tree | ee36bf353350d814803934f47ae2a645801749df /ikiwiki-transition | |
parent | 1d5ba6cf51275ddcb26312b440b8680f8a52c2b2 (diff) | |
download | ikiwiki-ea6dc3832585d8aca784c21d6f91436848a45039.tar ikiwiki-ea6dc3832585d8aca784c21d6f91436848a45039.tar.gz |
add ikiwiki-transition setupformat subcommand.
Also fixed a bug in how aggregateinternal used IkiWiki::Setup::load,
and added checks for arguments to other subcommands.
Diffstat (limited to 'ikiwiki-transition')
-rwxr-xr-x | ikiwiki-transition | 68 |
1 files changed, 56 insertions, 12 deletions
diff --git a/ikiwiki-transition b/ikiwiki-transition index 3e2c89bf9..a257347a1 100755 --- a/ikiwiki-transition +++ b/ikiwiki-transition @@ -51,11 +51,11 @@ sub prefix_directives { } sub indexdb { - $config{wikistatedir}=shift()."/.ikiwiki"; - - if (! defined $config{wikistatedir}) { + my $dir=shift; + if (! defined $dir) { usage(); } + $config{wikistatedir}=$dir."/.ikiwiki"; # Note: No lockwiki here because ikiwiki already locks it # before calling this. @@ -74,12 +74,12 @@ sub indexdb { } sub hashpassword { - $config{wikistatedir}=shift()."/.ikiwiki"; - - if (! defined $config{wikistatedir}) { + my $dir=shift; + if (! defined $dir) { usage(); } - + $config{wikistatedir}=$dir."/.ikiwiki"; + eval q{use IkiWiki::UserInfo}; eval q{use Authen::Passphrase::BlowfishCrypt}; if ($@) { @@ -100,10 +100,16 @@ sub hashpassword { } sub aggregateinternal { + my $setup=shift; + if (! defined $setup) { + usage(); + } + require IkiWiki::Setup; require IkiWiki::Plugin::aggregate; - %config = (IkiWiki::defaultconfig(), IkiWiki::Setup::load(shift)); + %config = IkiWiki::defaultconfig(); + IkiWiki::Setup::load(); IkiWiki::checkconfig(); IkiWiki::Plugin::aggregate::migrate_to_internal(); @@ -111,13 +117,48 @@ sub aggregateinternal { print "... now add aggregateinternal => 1 to your .setup file\n"; } +sub setupformat { + my $setup=shift; + if (! defined $setup) { + usage(); + } + + require IkiWiki::Setup; + + %config = IkiWiki::defaultconfig(); + IkiWiki::Setup::load($setup); + IkiWiki::checkconfig(); + + # unpack old-format wrappers setting into new fields + foreach my $wrapper (@{$config{wrappers}}) { + if ($wrapper->{cgi}) { + print "setting cgi_wrapper to ".$wrapper->{wrapper}."\n"; + $config{cgi_wrapper}=$wrapper->{wrapper}; + $config{cgi_wrappermode}=$wrapper->{wrappermode} + if exists $wrapper->{wrappermode}; + } + elsif ($config{rcs}) { + print "setting $config{rcs}_wrapper to ".$wrapper->{wrapper}."\n"; + $config{$config{rcs}."_wrapper"}=$wrapper->{wrapper}; + $config{$config{rcs}."_wrappermode"}=$wrapper->{wrappermode} + if exists $wrapper->{wrappermode}; + } + else { + die "don't know what to do with wrapper ".$wrapper->{wrapper}."\n"; + } + } + + IkiWiki::Setup::dump($setup); +} + sub usage { print STDERR "Usage: ikiwiki-transition type ...\n"; print STDERR "Currently supported transition subcommands:\n"; - print STDERR " prefix_directives file\n"; - print STDERR " indexdb srcdir\n"; - print STDERR " hashpassword srcdir\n"; - print STDERR " aggregateinternal setupfile\n"; + print STDERR "\tprefix_directives file\n"; + print STDERR "\tindexdb srcdir\n"; + print STDERR "\thashpassword srcdir\n"; + print STDERR "\taggregateinternal setupfile\n"; + print STDERR "\tsetupformat setupfile\n"; exit 1; } @@ -136,6 +177,9 @@ elsif ($mode eq 'indexdb') { elsif ($mode eq 'aggregateinternal') { aggregateinternal(@ARGV); } +elsif ($mode eq 'setupformat') { + setupformat(@ARGV); +} else { usage(); } |