Add new --clean option; this makes ikiwiki remove all built files in the destdir...
authorJoey Hess <joey@gnu.kitenet.net>
Sun, 28 Feb 2010 05:12:47 +0000 (00:12 -0500)
committerJoey Hess <joey@gnu.kitenet.net>
Sun, 28 Feb 2010 05:12:47 +0000 (00:12 -0500)
IkiWiki.pm
IkiWiki/Render.pm
Makefile.PL
debian/changelog
doc/usage.mdwn
ikiwiki.in
ikiwiki.spec

index 9df6c90d69671b8a0634d85fea2b3c8ba95fced5..00eadfd9818e6e41adc36457b6bb45361355817b 100644 (file)
@@ -409,6 +409,13 @@ sub getsetup () {
                safe => 0,
                rebuild => 0,
        },
+       clean => {
+               type => "internal",
+               default => 0,
+               description => "running in clean mode",
+               safe => 0,
+               rebuild => 0,
+       },
        refresh => {
                type => "internal",
                default => 0,
index 3ebb1a324d8a3118b54f0d7c6360587892917b65..af24df1550ee7682d649a79e046d0e604c39e0cf 100644 (file)
@@ -683,6 +683,17 @@ sub refresh () {
        }
 }
 
+sub clean_rendered {
+       lockwiki();
+       loadindex();
+       remove_unrendered();
+       foreach my $page (keys %oldrenderedfiles) {
+               foreach my $file (@{$oldrenderedfiles{$page}}) {
+                       prune($config{destdir}."/".$file);
+               }
+       }
+}
+
 sub commandline_render () {
        lockwiki();
        loadindex();
index 462f7364d57ce1c465db2b9ff0c2368a1279b3c2..52421a711d89fee2a2d82529048d26e8e263406e 100755 (executable)
@@ -51,7 +51,7 @@ docwiki: ikiwiki.out
        $(PERL) -Iblib/lib $(extramodules) $(tflag) ikiwiki.out -libdir . -setup docwiki.setup -refresh
 
 extra_clean:
-       rm -rf html doc/.ikiwiki
+       $(PERL) -I. $(extramodules) $(tflag) ikiwiki.in -libdir . -setup docwiki.setup -clean
        rm -f *.man ikiwiki.out ikiwiki.setup plugins/*.pyc
        $(MAKE) -C po clean
 
index 832bbaa85f3662a31acbcc3d3280af8b54a2b75f..3b92c598de4487855fc57dce070fd0fb0addddc9 100644 (file)
@@ -1,4 +1,4 @@
-ikiwiki (3.20100213) UNRELEASED; urgency=low
+ikiwiki (3.20100228) UNRELEASED; urgency=low
 
   * comments: Display number of comments in comment action link.
   * Rebuild wikis on upgrade to this version to get the comment counts
@@ -8,6 +8,8 @@ ikiwiki (3.20100213) UNRELEASED; urgency=low
     files/directories.
   * Fix admin openid detection in setup automator, and avoid prompting
     for a password.
+  * Add new --clean option; this makes ikiwiki remove all built
+    files in the destdir, as well as wrappers and the .ikiwiki directory.
 
  -- Joey Hess <joeyh@debian.org>  Sun, 14 Feb 2010 17:02:10 -0500
 
index e4808d4c256dc6a6d9472dcca21b9c623f01a71f..a105d7e59b96f5bc37324d09eb5a4a84e4054d2f 100644 (file)
@@ -50,6 +50,14 @@ These options control the mode that ikiwiki operates in.
   If used with --setup --refresh, this makes it also update any configured
   wrappers.
 
+* --clean
+
+  This makes ikiwiki clean up by removing any files it denerated in the 
+  `destination` directory, as well as any configured wrappers, and the
+  `.ikiwiki` state directory. This is mostly useful if you're running
+  ikiwiki in a Makefile to build documentation and want a corresponding
+  `clean` target.
+
 * --cgi
 
   Enable [[CGI]] mode. In cgi mode ikiwiki runs as a cgi script, and
index b8581d880eea398ac10a697c311f36428a18a67c..ae1251ff6b3abe3925c59566709748935b83616a 100755 (executable)
@@ -37,6 +37,7 @@ sub getconfig () {
                        "syslog!" => \$config{syslog},
                        "rebuild!" => \$config{rebuild},
                        "refresh!" => \$config{refresh},
+                       "clean!" => \$config{clean},
                        "post-commit" => \$config{post_commit},
                        "render=s" => \$config{render},
                        "wrappers!" => \$config{genwrappers},
@@ -135,6 +136,7 @@ sub main () {
 
                if (@{$config{wrappers}} && 
                    ! $config{render} && ! $config{dumpsetup} &&
+                   ! $config{clean} &&
                    ((! $config{refresh} && ! $config{post_commit})
                     || $config{genwrappers})) {
                        debug(gettext("generating wrappers.."));
@@ -159,7 +161,7 @@ sub main () {
                
                # setup implies a wiki rebuild by default
                if (! $config{refresh} && ! $config{render} &&
-                   ! $config{post_commit}) {
+                   ! $config{post_commit} && ! $config{clean}) {
                        $config{rebuild}=1;
                }
        }
@@ -190,6 +192,14 @@ sub main () {
        elsif ($config{post_commit} && ! commit_hook_enabled()) {
                # do nothing
        }
+       elsif ($config{clean}) {
+               require IkiWiki::Render;
+               foreach my $wrapper (@{$config{wrappers}}) {
+                       prune($wrapper->{wrapper});
+               }
+               clean_rendered();
+               system("rm", "-rf", $config{wikistatedir});
+       }
        else {
                if ($config{rebuild}) {
                        debug(gettext("rebuilding wiki.."));
index 865c9a3255fdacd5e969abab9789c5510d4005e6..1dba9f463a06f1f79508d60f52c64f7b5649fcc5 100644 (file)
@@ -1,5 +1,5 @@
 Name:           ikiwiki
-Version: 3.20100212
+Version: 3.20100228
 Release:        1%{?dist}
 Summary:        A wiki compiler