Index: drush_pm/drush_pm.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/drush/drush_pm/drush_pm.module,v retrieving revision 1.13 diff -u -p -r1.13 drush_pm.module --- drush_pm/drush_pm.module 30 Oct 2007 16:53:49 -0000 1.13 +++ drush_pm/drush_pm.module 16 Nov 2007 01:58:54 -0000 @@ -10,11 +10,29 @@ * Implementation of hook_help(). */ function drush_pm_help($section) { + $handlers = str_replace('drush_pm_', '', module_invoke_all('drush_pm_module_handler')); + $handlers[0] = $handlers[0] .' (default)'; + + $handler = 'You can use the --handler option to specify which module handler +you would like to use for module installation. +Available options: '. implode(', ', $handlers); + switch ($section) { case 'drush:pm install': - return t("Usage: drush [options] pm install ...\n\n is the short name of a project hosted on drupal.org.\nSo far, only modules are supported.\nThe modules will be installed into the sites/all/modules directory.\n\nTo use the modules, they still have to be activated on the normal module administration page."); + return t("Usage: drush [options] pm install ... + is the short name of a project hosted on drupal.org. +So far, only modules are supported.\n +The modules will be installed into the sites/all/modules directory. +To use the modules, they still have to be activated on the normal module +administration page\n\n". $handler); + case 'drush:pm update': - return t("Usage: drush [options] pm udpate\n\nDisplays update status information and allows to update all installed packages\n(so far, only modules are supported). If you only want to update certain projects, pass those as additional arguments (e.g. cck devel views ...)\n\nNote: The user is asked to confirm before the actual update is started.\n Use the -y option to answer all questions with yes automatically."); + return t("Usage: drush [options] pm update\n +Displays update status information and allows to update all installed packages +(so far, only modules are supported). If you only want to update certain +projects, pass those as additional arguments (e.g. cck devel views ...) +Note: The user is asked to confirm before the actual update is started. +Use the -y option to answer all questions with yes automatically.\n\n". $handler); } } @@ -65,13 +83,18 @@ function drush_pm_install() { $startdir = getcwd(); + $module_handler = drush_pm_get_module_handler() .'_install_project'; + if (!function_exists($module_handler)) { + drush_die(t("Module handler installation function not found.")); + } + // Download and install each module foreach($projects as $project) { if (isset($info[$project]) && $release = drush_pm_get_release($info[$project])) { if (is_dir($modulepath . $project)) { drush_error(t('Project !project is already installed. Skipping.', array('!project' => $project))); } - elseif (drush_pm_install_project($project, $release, $modulepath)) { + elseif ($module_handler($project, $release, $modulepath)) { drush_print(t("Project !project successfully installed (version !version).", array('!project' => $project, '!version' => $release['version']))); } @@ -85,62 +108,6 @@ function drush_pm_install() { } /** - * Install a project (so far, only modules are supported). - * - * @param $project The short name of the drupal.org project - * @param $info The details (fetched from drupal.org via xml-rpc) - * @param $path The path to install the module to. - */ -function drush_pm_install_project($project, $info, $path = '.') { - - drush_op('chdir', $path); - - drush_verbose("Downloading project $project ..."); - - // Get the filename... - $filename = explode('/', $info['download_link']); - $filename = array_pop($filename); - - // Download it. - if (!drush_shell_exec("wget " .$info['download_link'])) { - drush_shell_exec("curl -O " .$info['download_link']); - } - - if (file_exists($path. $filename) || DRUSH_SIMULATE) { - drush_verbose("Downloading " . $filename . " was successful."); - } - else { - return drush_error("Unable to download $filename to $path from ". $info['download_link']); - } - - // Check Md5 hash - if (md5_file($filename) != $info['mdhash'] && !DRUSH_SIMULATE) { - drush_op('unlink', $filename); - return drush_error("Error: File $filename is corrupt (wrong md5 checksum)."); - } - else { - drush_verbose("Md5 checksum of $filename verified."); - } - - // Decompress - drush_shell_exec("gzip -d " . $filename); - $filename = substr($filename, 0, strlen($filename)-3); - // Untar - drush_shell_exec("tar -xf " . $filename); - // We're not using tar -xzf because that's not working on windows... - - // Remove the tarball - drush_op('unlink', $filename); - - if (!is_dir($path . $project) && !DRUSH_SIMULATE) { - return drush_error("Error. Downloaded file $filename couldn't be untarred correctly"); - } - else { - return TRUE; - } -} - -/** * Command callback. Displays update status info and allows to update installed modules. * Pass specific projects as arguments, otherwise we update all that have candidate releases. * @@ -268,6 +235,23 @@ function drush_pm_update() { } } +/** + * Find a module handler + */ +function drush_pm_get_module_handler() { + $module_handlers = module_invoke_all('drush_pm_module_handler'); + $handler = drush_get_option('handler'); + // See if we have the full handler provided + if (array_search($handler, $module_handlers)) { + return $handler; + } + // Allow a shortcut for any functions named drush_pm_* + if (array_search('drush_pm_'. $handler, $module_handlers)) { + return 'drush_pm_'. $handler; + } + // Fallback on the first provided handler (from the lightest module) + return $module_handlers[0]; +} /** * Get update information for all installed projects. Index: drush_pm_wget/drush_pm_wget.info =================================================================== RCS file: drush_pm_wget/drush_pm_wget.info diff -N drush_pm_wget/drush_pm_wget.info --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ drush_pm_wget/drush_pm_wget.info 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,6 @@ +; $Id$ +name = drush Package Manager wget Support +description = Allows drush to install and update modules using wget or curl. +package = drush +dependencies = update_status drush drush_pm + Index: drush_pm_wget/drush_pm_wget.module =================================================================== RCS file: drush_pm_wget/drush_pm_wget.module diff -N drush_pm_wget/drush_pm_wget.module --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ drush_pm_wget/drush_pm_wget.module 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,65 @@ +