Merge branch 'master' into cvs

master
Joey Hess 2009-09-10 16:18:23 -04:00
commit 93cd30bc0a
10 changed files with 48 additions and 18 deletions

View File

@ -14,6 +14,7 @@ my $no_chdir=0;
sub import { sub import {
hook(type => "checkconfig", id => "git", call => \&checkconfig); hook(type => "checkconfig", id => "git", call => \&checkconfig);
hook(type => "getsetup", id => "git", call => \&getsetup); 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_update", call => \&rcs_update);
hook(type => "rcs", id => "rcs_prepedit", call => \&rcs_prepedit); hook(type => "rcs", id => "rcs_prepedit", call => \&rcs_prepedit);
hook(type => "rcs", id => "rcs_commit", call => \&rcs_commit); hook(type => "rcs", id => "rcs_commit", call => \&rcs_commit);
@ -41,6 +42,7 @@ sub checkconfig () {
wrappermode => (defined $config{git_wrappermode} ? $config{git_wrappermode} : "06755"), wrappermode => (defined $config{git_wrappermode} ? $config{git_wrappermode} : "06755"),
}; };
} }
if (defined $config{git_test_receive_wrapper} && if (defined $config{git_test_receive_wrapper} &&
length $config{git_test_receive_wrapper}) { length $config{git_test_receive_wrapper}) {
push @{$config{wrappers}}, { push @{$config{wrappers}}, {
@ -49,6 +51,13 @@ sub checkconfig () {
wrappermode => (defined $config{git_wrappermode} ? $config{git_wrappermode} : "06755"), 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 () { 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 (&@) { sub safe_git (&@) {
# Start a child process safely without resorting /bin/sh. # Start a child process safely without resorting /bin/sh.
# Return command output or success state (in scalar context). # Return command output or success state (in scalar context).

View File

@ -39,6 +39,7 @@ sub import {
hook(type => "renamepage", id => "skeleton", call => \&renamepage); hook(type => "renamepage", id => "skeleton", call => \&renamepage);
hook(type => "rename", id => "skeleton", call => \&rename); hook(type => "rename", id => "skeleton", call => \&rename);
hook(type => "savestate", id => "skeleton", call => \&savestate); hook(type => "savestate", id => "skeleton", call => \&savestate);
hook(type => "genwrapper", id => "skeleton", call => \&genwrapper);
} }
sub getopt () { sub getopt () {
@ -239,4 +240,8 @@ sub savestate () {
debug("skeleton plugin running in savestate"); debug("skeleton plugin running in savestate");
} }
sub genwrapper () {
debug("skeleton plugin running in genwrapper");
}
1 1

View File

@ -1,5 +1,4 @@
#!/usr/bin/perl #!/usr/bin/perl
package IkiWiki::Receive; package IkiWiki::Receive;
use warnings; use warnings;
@ -20,9 +19,9 @@ sub trusted () {
! grep { $_ eq $user } @{$config{untrusted_committers}}; ! grep { $_ eq $user } @{$config{untrusted_committers}};
} }
sub gen_wrapper () { sub genwrapper () {
# Test for commits from untrusted committers in the wrapper, to # 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"; my $ret=<<"EOF";
{ {
@ -37,6 +36,8 @@ EOF
"u != $uid"; "u != $uid";
} @{$config{untrusted_committers}}). } @{$config{untrusted_committers}}).
") exit(0);\n"; ") exit(0);\n";
$ret.=<<"EOF"; $ret.=<<"EOF";
asprintf(&s, "CALLER_UID=%i", u); asprintf(&s, "CALLER_UID=%i", u);
newenviron[i++]=s; newenviron[i++]=s;

View File

@ -38,11 +38,8 @@ sub gen_wrapper () {
EOF EOF
} }
my $test_receive=""; my @wrapper_hooks;
if ($config{test_receive}) { run_hooks(genwrapper => sub { push @wrapper_hooks, shift->() });
require IkiWiki::Receive;
$test_receive=IkiWiki::Receive::gen_wrapper();
}
my $check_args=" return 0;"; my $check_args=" return 0;";
run_hooks(wrapperargcheck => sub { $check_args = shift->(); }); run_hooks(wrapperargcheck => sub { $check_args = shift->(); });
@ -130,7 +127,7 @@ int main (int argc, char **argv) {
exit(0); exit(0);
$check_commit_hook $check_commit_hook
$test_receive @wrapper_hooks
$envsave $envsave
newenviron[i++]="HOME=$ENV{HOME}"; newenviron[i++]="HOME=$ENV{HOME}";
newenviron[i++]="WRAPPED_OPTIONS=$configstring"; newenviron[i++]="WRAPPED_OPTIONS=$configstring";
@ -154,7 +151,6 @@ $pre_exec
exit(1); exit(1);
} }
EOF EOF
close OUT;
my $cc=exists $ENV{CC} ? possibly_foolish_untaint($ENV{CC}) : 'cc'; my $cc=exists $ENV{CC} ? possibly_foolish_untaint($ENV{CC}) : 'cc';
if (system($cc, "$wrapper.c", "-o", "$wrapper.new") != 0) { if (system($cc, "$wrapper.c", "-o", "$wrapper.new") != 0) {

1
debian/changelog vendored
View File

@ -7,6 +7,7 @@ ikiwiki (3.14159265) UNRELEASED; urgency=low
* underlay: Also allow configuring additional directories to search * underlay: Also allow configuring additional directories to search
for template files in. for template files in.
* Fix parsing web commits from ipv6 addresses. * Fix parsing web commits from ipv6 addresses.
* Add genwrapper hook, that can be used to add code into the C wrapper.
-- Joey Hess <joeyh@debian.org> Wed, 02 Sep 2009 15:01:27 -0400 -- Joey Hess <joeyh@debian.org> Wed, 02 Sep 2009 15:01:27 -0400

View File

@ -22,9 +22,6 @@ Consider creating `$HOME/.cvsrc` if you don't have one already; the plugin doesn
* `cvs.pm` started life as a copy of [[3.14159|news/version_3.14159]]'s `svn.pm`. * `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 * `IkiWiki.pm:wiki_file_prune_regexps` avoids copying CVS metadata
into `$DESTDIR`. 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]]: * [[ikiwiki-makerepo]]:
* creates a repository, * creates a repository,
* imports `$SRCDIR` into top-level module `ikiwiki` (vendor tag IKIWIKI, release tag PRE_CVS), * imports `$SRCDIR` into top-level module `ikiwiki` (vendor tag IKIWIKI, release tag PRE_CVS),

View File

@ -141,3 +141,9 @@ general-purpose way to do so. If and when some other problem thinks
it wants to be solved by a new wrapper hook, it's easy enough to add it wants to be solved by a new wrapper hook, it's easy enough to add
one. Until then, I'd say it's more important to keep the wrapper as one. Until then, I'd say it's more important to keep the wrapper as
short and clear as possible. --[[schmonz]] 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]].

View File

@ -496,6 +496,13 @@ describes the plugin as a whole. For example:
and undef if a rebuild could be needed in some circumstances, but is not and undef if a rebuild could be needed in some circumstances, but is not
strictly required. strictly required.
### genwrapper
hook(type => "genwrapper", id => "foo", call => \&genwrapper);
This hook is used to inject C code (which it returns) into the `main`
function of the ikiwiki wrapper when it is being generated.
## Plugin interface ## Plugin interface
To import the ikiwiki plugin interface: To import the ikiwiki plugin interface:

View File

@ -4,6 +4,8 @@ Here's a paragraph.
Here's another one with *emphasised* text. Here's another one with *emphasised* text.
test 2
# Header # Header
## Subheader ## Subheader

View File

@ -190,10 +190,6 @@ sub main () {
elsif ($config{post_commit} && ! commit_hook_enabled()) { elsif ($config{post_commit} && ! commit_hook_enabled()) {
# do nothing # do nothing
} }
elsif ($config{test_receive}) {
require IkiWiki::Receive;
IkiWiki::Receive::test();
}
else { else {
if ($config{rebuild}) { if ($config{rebuild}) {
debug(gettext("rebuilding wiki..")); debug(gettext("rebuilding wiki.."));