--- drush_make.drush.inc.orig 2009-11-14 16:20:30.000000000 -0600 +++ drush_make.drush.inc 2009-11-14 19:48:23.000000000 -0600 @@ -19,6 +19,12 @@ function drush_make_drush_command() { 'bootstrap' => DRUSH_BOOTSTRAP_DRUSH, ); + $items['generate_makefile'] = array( + 'description' => 'Attempts to generate a makefile from the current drupal install.', + 'callback' => 'drush_generate_makefile', + 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL, + ); + return $items; } @@ -29,7 +35,66 @@ function drush_make_drush_help($section) switch ($section) { case 'drush:make': return dt("@TODO: Print information on the format of the makefile here."); + case 'drush:generate_makefile': + return dt("This command attempts to generate a makefile from the current drupal install. It is imperfect in that it cannot always find the sources of various components."); + } +} + +/** + * Drush callback; generate makefile from the current build. + */ +function drush_generate_makefile() { + // core section + print 'core = ' . DRUPAL_CORE_COMPATIBILITY . "\n"; + // surely this is a given + print 'projects[] = drupal' . "\n"; + print "\n"; + + // non-default profiles + $install_profile = variable_get('install_profile', ''); + if ($install_profile != 'default' || $install_profile != '') { + print 'projects[' . $install_profile . '][type] = "profile"' . "\n"; + print '; projects[' . $install_profile . '][download][type] = "DOWNLOADTYPE"' . "\n"; + print '; projects[' . $install_profile . '][download][url] = "DOWNLOADURL"' . "\n"; + print '; projects[' . $install_profile . '][download][branch] = "BRANCHNAME"' . "\n"; + print "\n"; + } + + // enabled modules + $module_info = drush_get_modules(); + //print_r($module_info); + foreach ($module_info as $module) { + // project name is required to be the same as module name to avoid listing out submodules + if ($module->info['project'] != 'drupal' + && $module->info['project'] == $module->name + && $module->status) { + print 'projects[] = ' . $module->name . "\n"; + } + } + print "\n"; + + // get installed libraries if the libraries module is available + if (function_exists(libraries_get_libraries)) { + $libraries = libraries_get_libraries(); + foreach ($libraries as $library_name => $library_path) { + $path = explode('/', $library_path); + print 'libraries[' . $library_name . '][download][type] = "get"' . "\n"; + print 'libraries[' . $library_name . '][directory_name] = "' . $path[(count($path) - 1)] . '"' . "\n"; + print 'libraries[' . $library_name . '][download][url] = "DOWNLOADURL"' . "\n"; + } + } + print "\n"; + + // get custom themes + if (function_exists(_system_theme_data)) { + $theme_info = _system_theme_data(); + foreach ($theme_info as $theme) { + if ($theme->info['project'] != 'drupal') { + print 'projects[] = ' . $theme->name . "\n"; + } + } } + } /**