← Back to team overview

mvhub-dev team mailing list archive

[Branch ~mvhub-commit/mvhub/trunk] Rev 427: merged fix_mv_update_user_config_creation

 

Merge authors:
  Lee Goodrich (leegoodrich)
Related merge proposals:
  https://code.launchpad.net/~leegoodrich/mvhub/fix_mv_update_user_config_creation/+merge/28683
  proposed by: Lee Goodrich (leegoodrich)
  review: Approve - Dan MacNeil (omacneil)
------------------------------------------------------------
revno: 427 [merge]
committer: Lee Goodrich <lgoodrich@xxxxxxxxxx>
branch nick: trunk
timestamp: Tue 2010-06-29 15:51:22 -0400
message:
  merged fix_mv_update_user_config_creation
modified:
  app-mvhub/project-tools/bin/mv_update_development
  lib-mvhub/lib/MVHub/Utils/Setup.pm


--
lp:mvhub
https://code.launchpad.net/~mvhub-commit/mvhub/trunk

Your team MVHub Developers is subscribed to branch lp:mvhub.
To unsubscribe from this branch go to https://code.launchpad.net/~mvhub-commit/mvhub/trunk/+edit-subscription
=== modified file 'app-mvhub/project-tools/bin/mv_update_development'
--- app-mvhub/project-tools/bin/mv_update_development	2010-06-25 14:51:40 +0000
+++ app-mvhub/project-tools/bin/mv_update_development	2010-06-28 21:05:35 +0000
@@ -42,33 +42,40 @@
     my $USERNAME = get_username_or_die();
     die_if_bad_env_for($USERNAME);
 
-    my $cfg =
-      MVHub::Utils::ConfigSimple::create_config_from( $ENV{MV_CONFIG_FILE} );
+    my $cfg = MVHub::Utils::ConfigSimple::create_config_from(
+        $ENV{MV_CONFIG_FILE} );
 
     system('clear');
-
     my $prompt = "Create $USERNAME directory structure? (Y/N):";
     if ( !($interactive) || IO::Prompt::prompt( $prompt, -YN ) ) {
         print "Creating $USERNAME directory structure...";
         my $base_dir = $cfg->param('BASE.dir');
-        my @dirs = MVHub::Utils::Setup::get_dirs_with( "$base_dir", $USERNAME );
+        my @dirs
+            = MVHub::Utils::Setup::get_dirs_with( "$base_dir", $USERNAME );
         MVHub::Utils::Setup::make_dirs_from( \@dirs );
     }
     $prompt = "Create config files in /home/$USERNAME? (Y/N):";
     if ( !($interactive) || IO::Prompt::prompt( $prompt, -YN ) ) {
         print "Creating config files in /home/$USERNAME...\n";
-        prompt(
-            "Enter developer email address: ",
-            -default=>"$USERNAME\@thecsl.org" );
-        my $dev_email = $_;
-        prompt( "Enter developer Launchpad username: ",
-            -default=>$USERNAME );
-        my $launchpad_login = $_;
+        my $dev_email       = "default";
+        my $launchpad_login = "default";
+        if (   !-e "/home/$USERNAME/.bazaar/bazaar.conf.default"
+            || !-e "/home/$USERNAME/.bazaar/locations.conf.default" )
+        {
+            prompt(
+                "Enter developer email address: ",
+                -default => "$USERNAME\@thecsl.org"
+            );
+            $dev_email = $_;
+            prompt( "Enter developer Launchpad username: ",
+                -default => $USERNAME );
+            $launchpad_login = $_;
+        }
 
         my @dev_home_dirs = MVHub::Utils::Setup::get_dev_home_dirs($USERNAME);
         MVHub::Utils::Setup::make_dirs_from( \@dev_home_dirs );
-        my @dev_home_files =
-          MVHub::Utils::Setup::get_dev_home_files( $USERNAME, $dev_email,
+        my @dev_home_files
+            = MVHub::Utils::Setup::get_dev_home_files( $USERNAME, $dev_email,
             $launchpad_login );
         MVHub::Utils::Setup::make_dev_home_files(@dev_home_files);
     }
@@ -94,18 +101,17 @@
     }
 
     if ( defined $ENV{SUDO_USER} ) {
-        $prompt =
-            "Add entries for $USERNAME into DNS and Apache? (Y/N):";
+        $prompt = "Add entries for $USERNAME into DNS and Apache? (Y/N):";
         if ( !($interactive) || IO::Prompt::prompt( $prompt, -YN ) ) {
-            MVHub::Utils::Setup::add_dns( $USERNAME );
-            MVHub::Utils::Setup::add_apache_config( $USERNAME );
+            MVHub::Utils::Setup::add_dns($USERNAME);
+            MVHub::Utils::Setup::add_apache_config($USERNAME);
         }
         $prompt = "Update contents of /etc? (Y/N):";
         if ( !($interactive) || IO::Prompt::prompt( $prompt, -YN ) ) {
-    	    MVHub::Utils::Setup::update_etc_files( $cfg );
+            MVHub::Utils::Setup::update_etc_files($cfg);
             MVHub::Utils::Setup::restart_services();
             MVHub::Utils::Setup::remove_cron_jobs();
-	    }
+        }
     }
 }
 
@@ -115,7 +121,7 @@
 
     foreach my $var (qw/PERL5LIB MV_CONFIG_FILE/) {
         $msg .= "$var not set"
-          if !defined $ENV{$var};
+            if !defined $ENV{$var};
     }
 
     my $xtra_msg = <<'HERE';
@@ -133,21 +139,21 @@
     }
 
     $msg .= "\nneed to run under sudo if you aren't $username\n"
-      if ( $username ne $ENV{USER} && $EFFECTIVE_USER_ID != 0 );
+        if ( $username ne $ENV{USER} && $EFFECTIVE_USER_ID != 0 );
 
-    $msg .=
-"\nNot allowed to setup development environment for user root, did you forget a \$user param on command line?\n"
-      if $username eq 'root';
+    $msg
+        .= "\nNot allowed to setup development environment for user root, did you forget a \$user param on command line?\n"
+        if $username eq 'root';
 
     die $msg if $msg;
     return 1;
 }
 
 sub get_username_or_die {
-    my $username =
-         shift @ARGV
-      || $ENV{NEW_DEV_USER}
-      || ( defined $ENV{MV_CONFIG_FILE} ? $ENV{USER} : undef );
+    my $username 
+        = shift @ARGV
+        || $ENV{NEW_DEV_USER}
+        || ( defined $ENV{MV_CONFIG_FILE} ? $ENV{USER} : undef );
 
     if ( !$username ) {
         die "No username defined" . usage();

=== modified file 'lib-mvhub/lib/MVHub/Utils/Setup.pm'
--- lib-mvhub/lib/MVHub/Utils/Setup.pm	2010-06-25 14:51:40 +0000
+++ lib-mvhub/lib/MVHub/Utils/Setup.pm	2010-06-28 21:05:35 +0000
@@ -806,6 +806,11 @@
     croak 'missing param: @files' if !( scalar @files );
     foreach my $file_href (@files) {
         if ( -e $file_href->{dest} ) {
+            if ( -e "$file_href->{dest}.default" ) {
+                print "$file_href->{dest}.default exists: skipping file\n";
+                next;
+            }
+            print "$file_href->{dest} exists: creating a default instead.\n";
             $file_href->{dest} = "$file_href->{dest}.default";
         }
         open my $FILE, ">$file_href->{dest}" or croak "open FILE failed: $!";