Merge commit 'schmonz/master'
authorJoey Hess <joey@gnu.kitenet.net>
Thu, 10 Sep 2009 21:04:20 +0000 (17:04 -0400)
committerJoey Hess <joey@gnu.kitenet.net>
Thu, 10 Sep 2009 21:04:20 +0000 (17:04 -0400)
19 files changed:
IkiWiki/Plugin/cvs.pm
IkiWiki/Plugin/git.pm
IkiWiki/Plugin/rsync.pm [deleted file]
IkiWiki/Plugin/unixauth.pm [deleted file]
IkiWiki/Receive.pm
IkiWiki/Render.pm
IkiWiki/Wrapper.pm
debian/changelog
debian/control
doc/ikiwiki-makerepo.mdwn
doc/post-commit/discussion.mdwn
doc/rcs/cvs.mdwn [moved from doc/plugins/contrib/cvs.mdwn with 72% similarity]
doc/rcs/cvs/discussion.mdwn [moved from doc/plugins/contrib/cvs/discussion.mdwn with 99% similarity]
doc/rcs/details.mdwn
doc/sandbox.mdwn
doc/todo/CVS_backend.mdwn
ikiwiki-makerepo
ikiwiki.in
t/cvs.t

index ccd697e1b48649576249b971bb239f743b910556..4543489a621ed3e014ee9ca054d60ac53f951619 100644 (file)
@@ -52,7 +52,7 @@ sub import {
 }
 
 sub genwrapper () {
-       my $check_args=<<"EOF";
+       return <<EOF;
        {
                int j;
                for (j = 1; j < argc; j++)
@@ -60,7 +60,6 @@ sub genwrapper () {
                                exit(0);
        }
 EOF
-       return $check_args;
 }
 
 sub checkconfig () {
@@ -104,7 +103,7 @@ sub getsetup () {
                cvs_wrapper => {
                        type => "string",
                        example => "/cvs/wikirepo/CVSROOT/post-commit",
-                       description => "cvs post-commit hook to generate (triggered by CVSROOT/loginfo entry",
+                       description => "cvs post-commit hook to generate (triggered by CVSROOT/loginfo entry)",
                        safe => 0, # file
                        rebuild => 0,
                },
@@ -264,11 +263,13 @@ sub rcs_add ($) {
                        if (defined($filemime) && $filemime eq 'text/plain') {
                                cvs_runcvs('add', $file) ||
                                        warn("cvs add $file failed\n");
-                       } else {
+                       }
+                       else {
                                cvs_runcvs('add', '-kb', $file) ||
                                        warn("cvs add binary $file failed\n");
                        }
-               } else {
+               }
+               else {
                        # directory
                        cvs_runcvs('add', $file) ||
                                warn("cvs add $file failed\n");
@@ -325,7 +326,8 @@ sub rcs_recentchanges($) {
        system("env TZ=UTC cvsps -q --cvs-direct -z 30 -x >$tmpfile");
        if ($? == -1) {
                error "couldn't run cvsps: $!\n";
-       } elsif (($? >> 8) != 0) {
+       }
+       elsif (($? >> 8) != 0) {
                error "cvsps exited " . ($? >> 8) . ": $!\n";
        }
 
@@ -382,7 +384,8 @@ sub rcs_recentchanges($) {
                    $message[0]->{line}=~/$config{web_commit_regexp}/) {
                        $user=defined $2 ? "$2" : "$3";
                        $message[0]->{line}=$4;
-               } else {
+               }
+               else {
                        $committype="cvs";
                }
 
@@ -392,21 +395,24 @@ sub rcs_recentchanges($) {
                $line = <SPSVC>;
                if ($line =~ /^Author: (.*)$/) {
                        $user = $1 unless defined $user && length $user;
-               } else {
+               }
+               else {
                        error "expected Author, got $line";
                }
 
                $line = <SPSVC>;
                if ($line =~ /^Date: (.*)$/) {
                        $when = str2time($1, 'UTC');
-               } else {
+               }
+               else {
                        error "expected Date, got $line";
                }
 
                $line = <SPSVC>;
                if ($line =~ /^PatchSet (.*)$/) {
                        $rev = $1;
-               } else {
+               }
+               else {
                        error "expected PatchSet, got $line";
                }
 
@@ -444,7 +450,8 @@ sub rcs_diff ($) {
 
        if (wantarray) {
                return @cvsps;
-       } else {
+       }
+       else {
                return join("", @cvsps);
        }
 }
index 68b114a7328332a54d8e66426bd09dc1eec0b030..ad58231e0bbd897e0f65dec50cc1be451fa3c92a 100644 (file)
@@ -14,6 +14,7 @@ my $no_chdir=0;
 sub import {
        hook(type => "checkconfig", id => "git", call => \&checkconfig);
        hook(type => "getsetup", id => "git", call => \&getsetup);
+       hook(type => "genwrapper", id => "git", call => \&genwrapper);
        hook(type => "rcs", id => "rcs_update", call => \&rcs_update);
        hook(type => "rcs", id => "rcs_prepedit", call => \&rcs_prepedit);
        hook(type => "rcs", id => "rcs_commit", call => \&rcs_commit);
@@ -41,6 +42,7 @@ sub checkconfig () {
                        wrappermode => (defined $config{git_wrappermode} ? $config{git_wrappermode} : "06755"),
                };
        }
+
        if (defined $config{git_test_receive_wrapper} &&
            length $config{git_test_receive_wrapper}) {
                push @{$config{wrappers}}, {
@@ -49,6 +51,13 @@ sub checkconfig () {
                        wrappermode => (defined $config{git_wrappermode} ? $config{git_wrappermode} : "06755"),
                };
        }
+       
+       # Run receive test only if being called by the wrapper, and not
+       # when generating same.
+       if ($config{test_receive} && ! exists $config{wrapper}) {
+               require IkiWiki::Receive;
+               IkiWiki::Receive::test();
+       }
 }
 
 sub getsetup () {
@@ -115,6 +124,16 @@ sub getsetup () {
                },
 }
 
+sub genwrapper {
+       if ($config{test_receive}) {
+               require IkiWiki::Receive;
+               return IkiWiki::Receive::genwrapper();
+       }
+       else {
+               return "";
+       }
+}
+
 sub safe_git (&@) {
        # Start a child process safely without resorting /bin/sh.
        # Return command output or success state (in scalar context).
diff --git a/IkiWiki/Plugin/rsync.pm b/IkiWiki/Plugin/rsync.pm
deleted file mode 100644 (file)
index 3f04945..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/usr/bin/perl
-package IkiWiki::Plugin::rsync;
-
-use warnings;
-use strict;
-use IkiWiki 3.00;
-
-sub import {
-       hook(type => "getsetup", id => "rsync", call => \&getsetup);
-       hook(type => "checkconfig", id => "rsync", call => \&checkconfig);
-       hook(type => "postrefresh", id => "rsync", call => \&postrefresh);
-}
-
-sub getsetup () {
-       return
-               plugin => {
-                       safe => 0,
-                       rebuild => 0,
-               },
-               rsync_command => {
-                       type => "string",
-                       example => "rsync -qa --delete /path/to/destdir/ user\@host:/path/to/docroot/",
-                       description => "unattended command to upload regenerated pages",
-                       safe => 0,
-                       rebuild => 0,
-               },
-}
-
-sub checkconfig {
-       if (! exists $config{rsync_command} ||
-           ! defined $config{rsync_command}) {
-               error("Must specify rsync_command");
-       }
-}
-
-sub postrefresh () {
-       system $config{rsync_command};
-       if ($? == -1) {
-               error("failed to execute rsync_command: $!");
-       } elsif ($? != 0) {
-               error(sprintf("rsync_command exited %d", $? >> 8));
-       }
-}
-
-1
diff --git a/IkiWiki/Plugin/unixauth.pm b/IkiWiki/Plugin/unixauth.pm
deleted file mode 100644 (file)
index 4f0cb4d..0000000
+++ /dev/null
@@ -1,195 +0,0 @@
-#!/usr/bin/perl
-# Ikiwiki unixauth authentication.
-package IkiWiki::Plugin::unixauth;
-
-use warnings;
-use strict;
-use IkiWiki 2.00;
-
-sub import {
-       hook(type => "getsetup", id => "unixauth", call => \&getsetup);
-               hook(type => "formbuilder_setup", id => "unixauth",
-                       call => \&formbuilder_setup);
-               hook(type => "formbuilder", id => "unixauth",
-                       call => \&formbuilder);
-       hook(type => "sessioncgi", id => "unixauth", call => \&sessioncgi);
-}
-
-sub getsetup () {
-       return
-       unixauth_type => {
-                       type => "string",
-                       example => "checkpassword",
-                       description => "type of authenticator; can be 'checkpassword' or 'pwauth'",
-                       safe => 0,
-                       rebuild => 1,
-       },
-       unixauth_command => {
-                       type => "string",
-                       example => "/path/to/checkpassword",
-                       description => "full path and any arguments",
-                       safe => 0,
-                       rebuild => 1,
-       },
-       unixauth_requiressl => {
-                       type => "boolean",
-                       example => "1",
-                       description => "require SSL? strongly recommended",
-                       safe => 0,
-                       rebuild => 1,
-       },
-       plugin => {
-                       description => "Unix user authentication",
-                       safe => 0,
-                       rebuild => 1,
-       },
-}
-
-# Checks if a string matches a user's password, and returns true or false.
-sub checkpassword ($$;$) {
-       my $user=shift;
-       my $password=shift;
-       my $field=shift || "password";
-
-       # It's very important that the user not be allowed to log in with
-       # an empty password!
-       if (! length $password) {
-                       return 0;
-       }
-
-       my $ret=0;
-       if (! exists $config{unixauth_type}) {
-                       # admin needs to carefully think over his configuration
-                       return 0;
-       }
-       elsif ($config{unixauth_type} eq "checkpassword") {
-                       open UNIXAUTH, "|$config{unixauth_command} true 3<&0" or die("Could not run $config{unixauth_type}");
-                       print UNIXAUTH "$user\0$password\0Y123456\0";
-                       close UNIXAUTH;
-                       $ret=!($?>>8);
-       }
-       elsif ($config{unixauth_type} eq "pwauth") {
-                       open UNIXAUTH, "|$config{unixauth_command}" or die("Could not run $config{unixauth_type}");
-                       print UNIXAUTH "$user\n$password\n";
-                       close UNIXAUTH;
-                       $ret=!($?>>8);
-       }
-       else {
-                       # no such authentication type
-                       return 0;
-       }
-
-       if ($ret) {
-               my $userinfo=IkiWiki::userinfo_retrieve();
-               if (! length $user || ! defined $userinfo ||
-                       ! exists $userinfo->{$user} || ! ref $userinfo->{$user}) {
-                               IkiWiki::userinfo_setall($user, {
-                                       'email' => '',
-                                       'regdate' => time,
-                               });
-               }
-       }
-
-       return $ret;
-}
-
-sub formbuilder_setup (@) {
-       my %params=@_;
-
-       my $form=$params{form};
-       my $session=$params{session};
-       my $cgi=$params{cgi};
-
-       # if not under SSL, die before even showing a login form,
-       # unless the admin explicitly says it's fine
-       if (! exists $config{unixauth_requiressl}) {
-                       $config{unixauth_requiressl} = 1;
-       }
-       if ($config{unixauth_requiressl}) {
-               if ((! $config{sslcookie}) || (! exists $ENV{'HTTPS'})) {
-                       die("SSL required to login. Contact your administrator.<br>");
-               }
-       }
-
-       if ($form->title eq "signin") {
-                       $form->field(name => "name", required => 0);
-                       $form->field(name => "password", type => "password", required => 0);
-
-                       if ($form->submitted) {
-                                       my $submittype=$form->submitted;
-                                       # Set required fields based on how form was submitted.
-                                       my %required=(
-                                                       "Login" => [qw(name password)],
-                                       );
-                                       foreach my $opt (@{$required{$submittype}}) {
-                                                       $form->field(name => $opt, required => 1);
-                                       }
-
-                                       # Validate password against name for Login.
-                                       if ($submittype eq "Login") {
-                                                       $form->field(
-                                                                       name => "password",
-                                                                       validate => sub {
-                                                                                       checkpassword($form->field("name"), shift);
-                                                                       },
-                                                       );
-                                       }
-
-                                       # XXX is this reachable? looks like no
-                                       elsif ($submittype eq "Login") {
-                                                       $form->field(
-                                                                       name => "name",
-                                                                       validate => sub {
-                                                                                       my $name=shift;
-                                                                                       length $name &&
-                                                                                       IkiWiki::userinfo_get($name, "regdate");
-                                                                       },
-                                                       );
-                                       }
-                       }
-                       else {
-                                       # First time settings.
-                                       $form->field(name => "name");
-                                       if ($session->param("name")) {
-                                                       $form->field(name => "name", value => $session->param("name"));
-                                       }
-                       }
-       }
-       elsif ($form->title eq "preferences") {
-               $form->field(name => "name", disabled => 1,
-                               value => $session->param("name"), force => 1,
-                               fieldset => "login");
-               $form->field(name => "password", disabled => 1, type => "password",
-                               fieldset => "login"),
-       }
-}
-
-sub formbuilder (@) {
-       my %params=@_;
-
-       my $form=$params{form};
-       my $session=$params{session};
-       my $cgi=$params{cgi};
-       my $buttons=$params{buttons};
-
-       if ($form->title eq "signin") {
-               if ($form->submitted && $form->validate) {
-                       if ($form->submitted eq 'Login') {
-                               $session->param("name", $form->field("name"));
-                               IkiWiki::cgi_postsignin($cgi, $session);
-                       }
-               }
-       }
-       elsif ($form->title eq "preferences") {
-               if ($form->submitted eq "Save Preferences" && $form->validate) {
-                       my $user_name=$form->field('name');
-               }
-       }
-}
-
-sub sessioncgi ($$) {
-       my $q=shift;
-       my $session=shift;
-}
-
-1
index 37b6f2a62667600c0ad181eb448d4629504bdd4c..cd94d093853023b0c7e2c6f29649c4b6d920c220 100644 (file)
@@ -1,5 +1,4 @@
 #!/usr/bin/perl
-
 package IkiWiki::Receive;
 
 use warnings;
@@ -20,9 +19,9 @@ sub trusted () {
                ! grep { $_ eq $user } @{$config{untrusted_committers}};
 }
 
-sub gen_wrapper () {
+sub genwrapper () {
        # Test for commits from untrusted committers in the wrapper, to
-       # avoid loading ikiwiki at all for trusted commits.
+       # avoid starting ikiwiki proper at all for trusted commits.
 
        my $ret=<<"EOF";
        {
@@ -37,6 +36,8 @@ EOF
                        "u != $uid";
                } @{$config{untrusted_committers}}).
                ") exit(0);\n";
+
+       
        $ret.=<<"EOF";
                asprintf(&s, "CALLER_UID=%i", u);
                newenviron[i++]=s;
@@ -114,7 +115,7 @@ sub test () {
                        # by not testing the removal in such pairs of changes.
                        # (The add is still tested, just to make sure that
                        # no data is added to the repo that a web edit
-                       # could add.)
+                       # could not add.)
                        next if $newfiles{$file};
 
                        if (IkiWiki::Plugin::remove->can("check_canremove")) {
index 5953b3feef93c9af06b8a491141635f3552fae82..246c2260d7748e9fe2b3522d73035564e0fb6754 100644 (file)
@@ -554,7 +554,6 @@ sub refresh () {
        if (%rendered) {
                run_hooks(change => sub { shift->(keys %rendered) });
        }
-       run_hooks(postrefresh => sub { shift->() });
 }
 
 sub commandline_render () {
index cf85738d68163763e8ac2bb1c7fc2ab04ef69187..ff110b5ffb9763cb5fbb9248c0b5d95bc52fb5e1 100644 (file)
@@ -37,10 +37,6 @@ sub gen_wrapper () {
                addenv("$var", s);
 EOF
        }
-
-       if ($config{test_receive}) {
-               require IkiWiki::Receive;
-       }
        
        my @wrapper_hooks;
        run_hooks(genwrapper => sub { push @wrapper_hooks, shift->() });
index 488aef8661811069ef88072d46ef28233401652a..1aa6c1c11d995fea8824d87aace9982287509725 100644 (file)
@@ -8,6 +8,8 @@ ikiwiki (3.14159265) UNRELEASED; urgency=low
     for template files in.
   * Fix parsing web commits from ipv6 addresses.
   * Add genwrapper hook, that can be used to add code into the C wrapper.
+  * cvs: Yeah, ikiwiki even supports CVS now. Plugin contributed by
+    Amitai Schlair.
 
  -- Joey Hess <joeyh@debian.org>  Wed, 02 Sep 2009 15:01:27 -0400
 
index 96ba221fffc865fc34bd5c54eefebe2d6fab8930..5a0acf4c4a2a7f5102c6d53c5e3bf8f0ddc8c01a 100644 (file)
@@ -6,7 +6,8 @@ Build-Depends-Indep: dpkg-dev (>= 1.9.0), libxml-simple-perl,
   libtext-markdown-perl | markdown, 
   libtimedate-perl, libhtml-template-perl,
   libhtml-scrubber-perl, wdg-html-validator,
-  libhtml-parser-perl, liburi-perl, perlmagick, po4a (>= 0.34)
+  libhtml-parser-perl, liburi-perl, perlmagick, po4a (>= 0.34),
+  libfile-chdir-perl
 Maintainer: Joey Hess <joeyh@debian.org>
 Uploaders: Josh Triplett <josh@freedesktop.org>
 Standards-Version: 3.8.1
index 13f88dc27a7ca3bd1c62d3221e63efbf74676246..9e742c211e36edf498e62923b14a7715d47a917f 100644 (file)
@@ -4,7 +4,7 @@ ikiwiki-makerepo - check an ikiwiki srcdir into revision control
 
 # SYNOPSIS
 
-ikiwiki-makerepo svn|git|monotone|darcs srcdir repository
+ikiwiki-makerepo git|svn|monotone|darcs|cvs srcdir repository
 
 ikiwiki-makerepo bzr|mercurial srcdir
 
index c78709e94e4e24c1019b515ebba391e7274e2582..fc0a27ee4f8e98f9219cb4c47978153360630536 100644 (file)
@@ -91,7 +91,7 @@ Can you offer an educated guess what's going wrong here? --[[Schmonz]]
 >>> Aaaaaand I was wrong about the second half of the conjecture being
 >>> wrong. The wrapper script wasn't correctly identifying directories;
 >>> with that fixed, everything works. I've created a
->>> [[plugins/contrib/cvs]] plugin page. Thanks for listening. :-)
+>>> [[rcs/cvs]] page. Thanks for listening. :-)
 >>> --[[Schmonz]]
 
 >> Here is a comment I committed to my laptop from Madrid Airport before
similarity index 72%
rename from doc/plugins/contrib/cvs.mdwn
rename to doc/rcs/cvs.mdwn
index d4599230004870fff4742326763cfae32746cbda..f0bd0f6f0da902e7888fbf580c8950687b19d5d4 100644 (file)
@@ -1,8 +1,5 @@
-[[!template id=plugin name=cvs core=0 author="[[schmonz]]"]]
-
-[[!template id=gitbranch branch=schmonz author="[[schmonz]]"]]
-
-This plugin allows ikiwiki to use [[!wikipedia desc="CVS" Concurrent Versions System]] as an [[rcs]].
+If you really need to, you can use [[!wikipedia desc="CVS" Concurrent Versions System]]
+with ikiwiki.
 
 ### Usage
 7. Install [[!cpan File::chdir]], [[!cpan File::ReadBackwards]],
@@ -19,12 +16,6 @@ Consider creating `$HOME/.cvsrc` if you don't have one already; the plugin doesn
     rdiff -u
 
 ### Implementation details
-* `cvs.pm` started life as a copy of [[3.14159|news/version_3.14159]]'s `svn.pm`.
-* `IkiWiki.pm:wiki_file_prune_regexps` avoids copying CVS metadata
-into `$DESTDIR`.
-* `IkiWiki/Wrapper.pm` provides a new "wrapperargcheck" hook, which
-the plugin implements to avoid calling ikiwiki from post-commit
-(and locking against itself) if it's a directory being `cvs add`ed.
 * [[ikiwiki-makerepo]]:
  * creates a repository,
  * imports `$SRCDIR` into top-level module `ikiwiki` (vendor tag IKIWIKI, release tag PRE_CVS),
similarity index 99%
rename from doc/plugins/contrib/cvs/discussion.mdwn
rename to doc/rcs/cvs/discussion.mdwn
index ace455d06dc3227a34f7330858f3dc771625752f..645b2388be1b54ee15042b8abede429488bcadee 100644 (file)
@@ -145,3 +145,5 @@ short and clear as possible. --[[schmonz]]
 > I've committed a slightly different hook, which should be general enough
 > that `IkiWiki::Receive` can also use it, so please adapt your code to
 > that. --[[Joey]]
+
+>> Done. --[[schmonz]].
index 6492cf38c6abe764c0b5c4eeb4f9ab1f42c67edd..013ddb7451877d7e2de047e8e9b9c92d30098ce8 100644 (file)
@@ -288,3 +288,5 @@ user for cleanup.  This is less neat than it could be, in that a conflict marked
 revision gets committed to the repository.
 
 ## [[bzr]]
+
+## [[cvs]]
index 8b594043e48d462cea62519557ad5799264641f2..22a5642da0fb61d233846f49469a1c397cbe07c7 100644 (file)
@@ -4,6 +4,8 @@ Here's a paragraph.
 
 Here's another one with *emphasised* text.
 
+test 2
+
 # Header
 
 ## Subheader
index 3c65272904277555b0f7c923d2cafe8f67040e3a..c450542e2c3ead4bdc511c5bc322ef4d0bdbccfd 100644 (file)
@@ -9,6 +9,8 @@ Original discussion:
 >> No, although the existing svn backend could fairly esily be modified into
 >> a CVS backend, by someone who doesn't mind working with CVS. --[[Joey]]
 >>
->>> Wouldn't say I don't mind, but I needed it. See [[plugins/contrib/cvs]]. --[[Schmonz]]
+>>> Wouldn't say I don't mind, but I needed it. See [[rcs/cvs]]. --[[Schmonz]]
+
+[[done]]
 
 [[!tag wishlist]]
index aca8da1531c5a51bc594495a15b1f59ad7bc1e55..6951ca0de98f79d9d782ceaf0a772d0900ac6132 100755 (executable)
@@ -6,7 +6,7 @@ srcdir="$2"
 repository="$3"
 
 usage () {
-       echo "usage: ikiwiki-makerepo cvs|svn|git|monotone|darcs srcdir repository" >&2
+       echo "usage: ikiwiki-makerepo svn|git|svn|monotone|darcs|cvs srcdir repository" >&2
        echo "       ikiwiki-makerepo bzr|mercurial srcdir" >&2
        exit 1
 }
index 4e9b812f852cb4b9805c51d7af6c0d0576d8a976..b8581d880eea398ac10a697c311f36428a18a67c 100755 (executable)
@@ -190,10 +190,6 @@ sub main () {
        elsif ($config{post_commit} && ! commit_hook_enabled()) {
                # do nothing
        }
-       elsif ($config{test_receive}) {
-               require IkiWiki::Receive;
-               IkiWiki::Receive::test();
-       }
        else {
                if ($config{rebuild}) {
                        debug(gettext("rebuilding wiki.."));
diff --git a/t/cvs.t b/t/cvs.t
index 9df62334da86fba1aa479435e07497d8752d7a2a..c9caa94eb308041e0b78ff4d9eddfe86cb331f65 100755 (executable)
--- a/t/cvs.t
+++ b/t/cvs.t
@@ -6,9 +6,11 @@ BEGIN {
        $dir="/tmp/ikiwiki-test-cvs.$$";
        my $cvs=`which cvs`;
        chomp $cvs;
-       if (! -x $cvs || ! mkdir($dir)) {
+       my $cvsps=`which cvsps`;
+       chomp $cvsps;
+       if (! -x $cvs || ! -x $cvsps || ! mkdir($dir)) {
                eval q{
-                       use Test::More skip_all => "cvs not available or could not make test dir"
+                       use Test::More skip_all => "cvs or cvsps not available or could not make test dir"
                }
        }
 }