summaryrefslogtreecommitdiff
path: root/ikiwiki-transition
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2009-05-21 09:15:55 +0200
committerintrigeri <intrigeri@boum.org>2009-05-21 09:15:55 +0200
commitdf6f6a1d53493de0ee4f451220b8c8d34af6642a (patch)
tree51ed87d8494ffda4025989cf4fda8bdcd5daf8ca /ikiwiki-transition
parentef003f48f4a3fe8fb67fda62c70a299b07d75976 (diff)
parentf7ded1174dd8f4aec3371214bbadc1c1f7fc2e22 (diff)
Merge commit 'upstream/master' into pub/po
Diffstat (limited to 'ikiwiki-transition')
-rwxr-xr-xikiwiki-transition71
1 files changed, 29 insertions, 42 deletions
diff --git a/ikiwiki-transition b/ikiwiki-transition
index ce1807309..7e99c878e 100755
--- a/ikiwiki-transition
+++ b/ikiwiki-transition
@@ -42,16 +42,8 @@ sub handle_directive {
}
sub prefix_directives {
- my $setup=shift;
- if (! defined $setup) {
- usage();
- }
-
- require IkiWiki::Setup;
- require IkiWiki::Plugin::aggregate;
+ loadsetup(shift);
- %config = IkiWiki::defaultconfig();
- IkiWiki::Setup::load($setup);
IkiWiki::loadplugins();
IkiWiki::checkconfig();
IkiWiki::loadindex();
@@ -114,31 +106,16 @@ sub hashpassword {
}
sub aggregateinternal {
- my $setup=shift;
- if (! defined $setup) {
- usage();
- }
-
- require IkiWiki::Setup;
+ loadsetup(shift);
require IkiWiki::Plugin::aggregate;
-
- %config = IkiWiki::defaultconfig();
- IkiWiki::Setup::load($setup);
IkiWiki::checkconfig();
-
IkiWiki::Plugin::aggregate::migrate_to_internal();
}
sub setupformat {
my $setup=shift;
- if (! defined $setup) {
- usage();
- }
-
- require IkiWiki::Setup;
- %config = IkiWiki::defaultconfig();
- IkiWiki::Setup::load($setup);
+ loadsetup($setup);
IkiWiki::checkconfig();
# unpack old-format wrappers setting into new fields
@@ -175,14 +152,8 @@ sub setupformat {
sub moveprefs {
my $setup=shift;
- if (! defined $setup) {
- usage();
- }
-
- require IkiWiki::Setup;
- %config = IkiWiki::defaultconfig();
- IkiWiki::Setup::load($setup);
+ loadsetup($setup);
IkiWiki::checkconfig();
eval q{use IkiWiki::UserInfo};
@@ -224,22 +195,38 @@ sub deduplinks {
}
sub setstatedir {
- my $dir=shift;
+ my $dirorsetup=shift;
- if (! defined $dir) {
+ if (! defined $dirorsetup) {
usage();
}
- if (! -d $dir) {
- error("ikiwiki-transition: $dir does not exist");
+ if (-d $dirorsetup) {
+ $config{wikistatedir}=$dirorsetup."/.ikiwiki";
+ }
+ elsif (-f $dirorsetup) {
+ loadsetup($dirorsetup);
+ }
+ else {
+ error("ikiwiki-transition: $dirorsetup does not exist");
}
-
- $config{wikistatedir}=$dir."/.ikiwiki";
if (! -d $config{wikistatedir}) {
error("ikiwiki-transition: $config{wikistatedir} does not exist");
}
}
+
+sub loadsetup {
+ my $setup=shift;
+ if (! defined $setup) {
+ usage();
+ }
+
+ require IkiWiki::Setup;
+
+ %config = IkiWiki::defaultconfig();
+ IkiWiki::Setup::load($setup);
+}
sub usage {
print STDERR "Usage: ikiwiki-transition type ...\n";
@@ -248,9 +235,9 @@ sub usage {
print STDERR "\taggregateinternal setupfile\n";
print STDERR "\tsetupformat setupfile\n";
print STDERR "\tmoveprefs setupfile\n";
- print STDERR "\thashpassword srcdir\n";
- print STDERR "\tindexdb srcdir\n";
- print STDERR "\tdeduplinks srcdir\n";
+ print STDERR "\thashpassword setupfile|srcdir\n";
+ print STDERR "\tindexdb setupfile|srcdir\n";
+ print STDERR "\tdeduplinks setupfile|srcdir\n";
exit 1;
}