diff options
author | Joe Rayhawk <jrayhawk@omgwallhack.org> | 2011-06-01 03:20:33 -0700 |
---|---|---|
committer | Joe Rayhawk <jrayhawk@omgwallhack.org> | 2011-06-01 03:20:33 -0700 |
commit | 28c9853a2cb8b789eaecf76ed18b4230eee45ca4 (patch) | |
tree | 99d410a873a681dcce61ce597f6ceddc6539d9ba | |
parent | 18c3275a222e57e6b98932e8e394646382b25388 (diff) | |
download | piny-code-28c9853a2cb8b789eaecf76ed18b4230eee45ca4.tar.gz piny-code-28c9853a2cb8b789eaecf76ed18b4230eee45ca4.zip |
newrepo: migrating rebuild logic out of Repo.pm and making --enable/disable-ikiwiki work
-rw-r--r-- | libpiny/lib/Piny/Repo.pm | 8 | ||||
-rw-r--r-- | pinyadmin/debian/control | 2 | ||||
-rwxr-xr-x | pinyadmin/sbin/newrepo | 50 |
3 files changed, 39 insertions, 21 deletions
diff --git a/libpiny/lib/Piny/Repo.pm b/libpiny/lib/Piny/Repo.pm index b5e6800..675c16c 100644 --- a/libpiny/lib/Piny/Repo.pm +++ b/libpiny/lib/Piny/Repo.pm @@ -455,7 +455,7 @@ sub all_repos { return @ret; }; -# Only sets up needed data; ->rebuild takes care of the rest. +# Only sets up needed data; ->rebuild can take care of the rest. sub create { my ( $class, $name, $description, $remote ) = @_; @@ -498,14 +498,8 @@ sub create { $repo->description( $description ); - $repo->rebuild_git; - $repo = $class->new( $name ); - if ( $repo->config->piny_ikiwiki =~ /^(1|true)$/ ) { - $repo->rebuild_ikiwiki; - }; - return $repo; }; diff --git a/pinyadmin/debian/control b/pinyadmin/debian/control index 126b57c..b41d5b5 100644 --- a/pinyadmin/debian/control +++ b/pinyadmin/debian/control @@ -8,7 +8,7 @@ Standards-version: 3.9.1 Package: pinyadmin Architecture: all -Depends: ${perl:Depends}, ${misc:Depends}, libpiny-perl (>= 0.14), moreutils +Depends: ${perl:Depends}, ${misc:Depends}, libpiny-perl (>= 0.14), libgetopt-tabular-perl, moreutils Description: Administrative programs for piny The command-line programs for day-to-day administrative tasks in the Piny infrastructure. diff --git a/pinyadmin/sbin/newrepo b/pinyadmin/sbin/newrepo index a13a0dc..8f13873 100755 --- a/pinyadmin/sbin/newrepo +++ b/pinyadmin/sbin/newrepo @@ -3,26 +3,35 @@ use strict; use warnings; +use Getopt::Tabular qw( ); + use Moose::Util::TypeConstraints qw( find_type_constraint ); use Piny; -my ( $batch, $name, $remote ); -if ( $ARGV[0] eq "--batch" ) { - ( $batch, $name, $remote ) = @ARGV; -} else { - ( $name, $remote ) = @ARGV; -}; +my ( $batch ) = ( 0 ); +my ( $name, $remote, $ikiwiki ); + +Getopt::Tabular::SetOptionPatterns( "(--)[\\w-]+", "(-)\\w" ); +Getopt::Tabular::SetHelpOption( "--help" ); +Getopt::Tabular::GetOptions( + [ + [ "--batch", "const", 1, \$batch, "enable batch mode, for use as a backend by other scripts" ], + [ "--enable-ikiwiki|--disable-ikiwiki", "boolean", 0, \$ikiwiki, "enable or disable creation of an ikiwiki site for this repo" ] + ], \@ARGV +) or exit( 0 ); + +( $name, $remote ) = @ARGV; if ( not defined $name ) { - print "Usage: newrepo REPONAME\n"; - exit 1; + print( "Usage: newrepo REPONAME\n" ); + exit( 1 ); }; if ( not find_type_constraint( "Reponame" )->check( $name ) ) { print "That is not a valid repo name; must be at least 1 character long, begin with a lowercase alphanumeric character, and contain only alphanumeric characters and dashes.\n"; - exit 1; + exit( 2 ); }; my $description; @@ -33,8 +42,8 @@ while( 1 ) { if ( not find_type_constraint( "SimpleText" )->check( $description ) ) { print "Must be 1-80 characters long; control characters (including tab) not allowed.\n"; - if ( defined $batch ) { - exit; + if ( $batch ) { + exit( 3 ); }; next; }; @@ -74,5 +83,20 @@ if( defined( $remote ) ) { $repo = Piny::Repo->create( $name, $description ); }; -print "Repo URL: " . $repo->ikiwiki_url . "\n"; -print "Repo URL: " . $repo->cgit_url . "\n"; +$repo->rebuild_git; + +if ( defined( $ikiwiki ) ) { + $repo->config->piny_ikiwiki( $ikiwiki ); + if ( $repo->config->piny_ikiwiki ne $ikiwiki ) { + print( "Override in place for piny.ikiwiki.\n" ); + }; +}; + +if ( $repo->config->piny_ikiwiki ) { + $repo->rebuild_ikiwiki; + print( "Repo URL: " . $repo->ikiwiki_url . "\n" ); +} else { + print( "Ikiwiki disabled.\n" ); +}; + +print( "Repo URL: " . $repo->cgit_url . "\n" ); |