=== modified file 'includes/bootstrap.inc'
--- includes/bootstrap.inc	2008-10-31 02:18:22 +0000
+++ includes/bootstrap.inc	2008-11-01 04:57:57 +0000
@@ -393,7 +393,7 @@ function conf_init() {
   global $base_url, $base_path, $base_root;
 
   // Export the following settings.php variables to the global namespace
-  global $databases, $db_prefix, $cookie_domain, $conf, $installed_profile, $update_free_access;
+  global $databases, $db_prefix, $cookie_domain, $conf, $installed_profile, $update_free_access, $db_url;
   $conf = array();
 
   if (file_exists(DRUPAL_ROOT . '/' . conf_path() . '/settings.php')) {

=== modified file 'includes/install.inc'
--- includes/install.inc	2008-10-24 18:21:54 +0000
+++ includes/install.inc	2008-11-01 04:59:44 +0000
@@ -88,7 +88,7 @@ function drupal_load_updates() {
  * @param $module
  *   A module name.
  * @return
- *   If the module has updates, an array of available updates sorted by version. 
+ *   If the module has updates, an array of available updates sorted by version.
  *   Otherwise, FALSE.
  */
 function drupal_get_schema_versions($module) {
@@ -105,10 +105,10 @@ function drupal_get_schema_versions($mod
   if (count($updates) == 0) {
     return FALSE;
   }
-  
+
   // Make sure updates are run in numeric order, not in definition order.
   sort($updates, SORT_NUMERIC);
-  
+
   return $updates;
 }
 
@@ -213,8 +213,8 @@ function drupal_detect_database_types() 
   // file for the driver explicitly.
 
   foreach (file_scan_directory(DRUPAL_ROOT . '/includes/database', '/^[a-z]*$/i', array('.', '..', 'CVS'), 0, FALSE) as $file) {
-    include_once "{$file->filename}/install.inc";      
-    include_once "{$file->filename}/database.inc"; 
+    include_once "{$file->filename}/install.inc";
+    include_once "{$file->filename}/database.inc";
     $drivers[$file->basename] = $file->filename;
   }
 
@@ -232,7 +232,7 @@ function drupal_detect_database_types() 
     unset($databases['mysql']);
     $databases = array('mysql' => $mysql_database) + $databases;
   }
-  
+
   return $databases;
 }
 
@@ -466,7 +466,7 @@ function drupal_verify_profile($profile,
   $missing_modules = array_diff($module_list, $present_modules);
 
   $requirements = array();
-  
+
   if (count($missing_modules)) {
     $modules = array();
     foreach ($missing_modules as $module) {
@@ -544,7 +544,7 @@ function _drupal_install_module($module)
  */
 function drupal_install_init_database() {
   static $included = FALSE;
-  
+
   if (!$included) {
     $connection_info = Database::getConnectionInfo();
     $driver = $connection_info['default']['driver'];
@@ -568,7 +568,7 @@ function drupal_install_system() {
   require_once DRUPAL_ROOT . '/' . $system_path . '/system.install';
   drupal_install_init_database();
   module_invoke('system', 'install');
-  
+
   $system_versions = drupal_get_schema_versions('system');
   $system_version = $system_versions ? max($system_versions) : SCHEMA_INSTALLED;
   db_query("INSERT INTO {system} (filename, name, type, owner, status, bootstrap, schema_version) VALUES('%s', '%s', '%s', '%s', %d, %d, %d)", $system_path . '/system.module', 'system', 'module', '', 1, 0, $system_version);
@@ -828,7 +828,7 @@ function drupal_install_fix_file($file, 
 
 
 /**
- * Send the user to a different installer page. 
+ * Send the user to a different installer page.
  *
  * This issues an on-site HTTP redirect. Messages (and errors) are erased.
  *
@@ -927,7 +927,7 @@ function drupal_check_profile($profile) 
  * Extract highest severity from requirements array.
  *
  * @param $requirements
- *   An array of requirements, in the same format as is returned by 
+ *   An array of requirements, in the same format as is returned by
  *   hook_requirements().
  * @return
  *   The highest severity in the array.
@@ -974,3 +974,61 @@ function drupal_check_module($module) {
   }
   return TRUE;
 }
+
+/**
+ * Check installation requirements and report any errors.
+ */
+function install_check_requirements($profile, $verify) {
+  // Check the profile requirements.
+  $requirements = $profile ? drupal_check_profile($profile) : array();
+
+  // If Drupal is not set up already, we need to create a settings file.
+  if (!$verify) {
+    $writable = FALSE;
+    $conf_path = './' . conf_path(FALSE, TRUE);
+    $settings_file = $conf_path . '/settings.php';
+    $file = $conf_path;
+    $exists = FALSE;
+    // Verify that the directory exists.
+    if (drupal_verify_install_file($conf_path, FILE_EXIST, 'dir')) {
+      // Check to make sure a settings.php already exists.
+      $file = $settings_file;
+      if (drupal_verify_install_file($settings_file, FILE_EXIST)) {
+        $exists = TRUE;
+        // If it does, make sure it is writable.
+        $writable = drupal_verify_install_file($settings_file, FILE_READABLE|FILE_WRITABLE);
+        $exists = TRUE;
+      }
+    }
+
+    if (!$exists) {
+      $requirements['settings file exists'] = array(
+        'title'       => st('Settings file'),
+        'value'       => st('The settings file does not exist.'),
+        'severity'    => REQUIREMENT_ERROR,
+        'description' => st('The @drupal installer requires that you create a settings file as part of the installation process. Copy the %default_file file to %file. More details about installing Drupal are available in INSTALL.txt.', array('@drupal' => drupal_install_profile_name(), '%file' => $file, '%default_file' => $conf_path .'/default.settings.php')),
+      );
+    }
+    elseif ($exists) {
+      $requirements['settings file exists'] = array(
+        'title'       => st('Settings file'),
+        'value'       => st('The %file file exists.', array('%file' => $file)),
+      );
+    }
+    if (!$writable) {
+      $requirements['settings file writable'] = array(
+        'title'       => st('Settings file'),
+        'value'       => st('The settings file is not writable.'),
+        'severity'    => REQUIREMENT_ERROR,
+        'description' => st('The @drupal installer requires write permissions to %file during the installation process. If you are unsure how to grant file permissions, please consult the <a href="@handbook_url">online handbook</a>.', array('@drupal' => drupal_install_profile_name(), '%file' => $file, '@handbook_url' => 'http://drupal.org/server-permissions')),
+      );
+    }
+    elseif ($writable) {
+      $requirements['settings file'] = array(
+        'title'       => st('Settings file'),
+        'value'       => st('Settings file is writable.'),
+      );
+    }
+  }
+  return $requirements;
+}

=== modified file 'install.php'
--- install.php	2008-10-29 10:08:51 +0000
+++ install.php	2008-11-01 04:59:09 +0000
@@ -891,64 +891,6 @@ function install_reserved_tasks() {
 }
 
 /**
- * Check installation requirements and report any errors.
- */
-function install_check_requirements($profile, $verify) {
-  // Check the profile requirements.
-  $requirements = drupal_check_profile($profile);
-
-  // If Drupal is not set up already, we need to create a settings file.
-  if (!$verify) {
-    $writable = FALSE;
-    $conf_path = './' . conf_path(FALSE, TRUE);
-    $settings_file = $conf_path . '/settings.php';
-    $file = $conf_path;
-    $exists = FALSE;
-    // Verify that the directory exists.
-    if (drupal_verify_install_file($conf_path, FILE_EXIST, 'dir')) {
-      // Check to make sure a settings.php already exists.
-      $file = $settings_file;
-      if (drupal_verify_install_file($settings_file, FILE_EXIST)) {
-        $exists = TRUE;
-        // If it does, make sure it is writable.
-        $writable = drupal_verify_install_file($settings_file, FILE_READABLE|FILE_WRITABLE);
-        $exists = TRUE;
-      }
-    }
-
-    if (!$exists) {
-      $requirements['settings file exists'] = array(
-        'title'       => st('Settings file'),
-        'value'       => st('The settings file does not exist.'),
-        'severity'    => REQUIREMENT_ERROR,
-        'description' => st('The @drupal installer requires that you create a settings file as part of the installation process. Copy the %default_file file to %file. More details about installing Drupal are available in INSTALL.txt.', array('@drupal' => drupal_install_profile_name(), '%file' => $file, '%default_file' => $conf_path .'/default.settings.php')),
-      );
-    }
-    elseif ($exists) {
-      $requirements['settings file exists'] = array(
-        'title'       => st('Settings file'),
-        'value'       => st('The %file file exists.', array('%file' => $file)),
-      );
-    }
-    if (!$writable) {
-      $requirements['settings file writable'] = array(
-        'title'       => st('Settings file'),
-        'value'       => st('The settings file is not writable.'),
-        'severity'    => REQUIREMENT_ERROR,
-        'description' => st('The @drupal installer requires write permissions to %file during the installation process. If you are unsure how to grant file permissions, please consult the <a href="@handbook_url">online handbook</a>.', array('@drupal' => drupal_install_profile_name(), '%file' => $file, '@handbook_url' => 'http://drupal.org/server-permissions')),
-      );
-    }
-    elseif ($writable) {
-      $requirements['settings file'] = array(
-        'title'       => st('Settings file'),
-        'value'       => st('Settings file is writable.'),
-      );
-    }
-  }
-  return $requirements;
-}
-
-/**
  * Add the installation task list to the current page.
  */
 function install_task_list($active = NULL) {

=== modified file 'update.php'
--- update.php	2008-10-24 18:47:02 +0000
+++ update.php	2008-11-01 04:58:39 +0000
@@ -592,8 +592,18 @@ function update_task_list($active = NULL
  * Check update requirements and report any errors.
  */
 function update_check_requirements() {
+  global $db_url, $databases;
+  $requirements = array();
+
+  // If we will rewrite the settings.php then we need to make sure it is
+  // writeable.
+  if (empty($databases) && !empty($db_url) && is_string($db_url)) {
+    $requirements = install_check_requirements('', FALSE);
+  }
+  $warnings = FALSE;
+
   // Check the system module requirements only.
-  $requirements = module_invoke('system', 'requirements', 'update');
+  $requirements += module_invoke('system', 'requirements', 'update');
   $severity = drupal_requirements_severity($requirements);
 
   // If there are issues, report them.
@@ -604,15 +614,32 @@ function update_check_requirements() {
         if (isset($requirement['value']) && $requirement['value']) {
           $message .= ' (Currently using ' . $requirement['title'] . ' ' . $requirement['value'] . ')';
         }
+        $warnings = TRUE;
         drupal_set_message($message, 'warning');
       }
     }
   }
+  return $warnings;
+}
+
+function update_check_drupal_7_settings() {
+  global $db_url, $databases;
+
+  if (empty($databases) && !empty($db_url) && is_string($db_url)) {
+    $url = parse_url($db_url);
+    $databases['default']['default']['driver'] = substr($db_url, 0, strpos($db_url, '://'));
+    $databases['default']['default']['database'] = substr($url['path'], 1);
+    foreach (array('user' => 'username', 'pass' => 'password', 'host' => 'host', 'port' => 'port') as $old_key => $new_key) {
+      $databases['default']['default'][$new_key] =  isset($url[$old_key]) ? urldecode($url[$old_key]) : '';
+    }
+    $conf_path = conf_path();
+    file_put_contents($conf_path .'/settings.php', var_export($databases, TRUE) . ';', FILE_APPEND);
+  }
 }
 
 // Some unavoidable errors happen because the database is not yet up-to-date.
 // Our custom error handler is not yet installed, so we just suppress them.
-ini_set('display_errors', FALSE);
+#ini_set('display_errors', FALSE);
 
 require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
 
@@ -642,16 +669,18 @@ if (empty($op)) {
   drupal_maintenance_theme();
 
   // Check the update requirements for Drupal.
-  update_check_requirements();
+  $warnings = update_check_requirements();
 
   // Display the warning messages (if any) in a dedicated maintenance page,
   // or redirect to the update information page if no message.
-  $messages = drupal_set_message();
-  if (!empty($messages['warning'])) {
+  if ($warnings) {
     drupal_maintenance_theme();
     print theme('update_page', '<form method="post" action="update.php?op=info"><input type="submit" value="Continue" /></form>', FALSE);
     exit;
   }
+  // Write D7 settings file.
+  update_check_drupal_7_settings();
+
   install_goto('update.php?op=info');
 }
 

