-
-
Save christianchristensen/1270929 to your computer and use it in GitHub Desktop.
diff --git a/drush_make.project.inc b/drush_make.project.inc | |
index 76b71b2..3eae893 100644 | |
--- a/drush_make.project.inc | |
+++ b/drush_make.project.inc | |
@@ -59,6 +59,9 @@ class DrushMakeProject { | |
if (drush_make_download_factory($this->name, $this->download, $download_location) === FALSE) { | |
return FALSE; | |
} | |
+ if ($this->drush_make_inject_info($this->name, $this->download, $this->project_directory) === FALSE) { | |
+ return FALSE; | |
+ } | |
if (!$this->addLockfile($download_location)) { | |
return FALSE; | |
} | |
@@ -74,6 +77,60 @@ class DrushMakeProject { | |
return TRUE; | |
} | |
+ function drush_make_inject_info($name, $download, $download_location) { | |
+ if (in_array(strtolower($download['type']), array("git", "svn", "bzr", "cvs")) && $this->version != "best") { | |
+ // Inspired by: http://drupalcode.org/project/project.git/blob/7beb24ff6f46bdfb0e428684172a7811ef809b4e:/release/package-release-nodes.php#l835 | |
+ // Array to hold info files | |
+ $info_files = array(); | |
+ // Handler for the directory and open directory and walk through the filenames | |
+ $handler = opendir($this->download_location); | |
+ while ($file = readdir($handler)) { | |
+ // if file is an info file | |
+ if (preg_match('/^.+\.info$/', $file)) { | |
+ $info_files[] = "$dir/$file"; | |
+ } | |
+ } | |
+ closedir($handler); | |
+ | |
+ $return = TRUE; | |
+ // Consider that the d.o. package manager is aware of submodules in parent modules | |
+ foreach($info_files as $info_file) { | |
+ $return = $return && $this->fix_info_file_version($this->download_location . $info_file, $this->name, $this->version); | |
+ } | |
+ } | |
+ return $return; | |
+ } | |
+ | |
+ /** | |
+ * Fix the given .info file with the specified version string | |
+ * Taken straight from: http://drupalcode.org/project/project.git/blob/7beb24ff6f46bdfb0e428684172a7811ef809b4e:/release/package-release-nodes.php#l767 | |
+ */ | |
+ private function fix_info_file_version($file, $project, $version) { | |
+ $info = "\n\n; Information added by drush_make (data from makefile) automatically on " . date('Y-m-d') . "\n"; | |
+ $info .= "version = \"$version\"\n"; | |
+ // .info files started with 5.x, so we don't have to worry about version | |
+ // strings like "4.7.x-1.0" in this regular expression. If we can't parse | |
+ // the version (also from an old "HEAD" release), or the version isn't at | |
+ // least 6.x, don't add any "core" attribute at all. | |
+ $matches = array(); | |
+ if (preg_match('/^((\d+)\.x)-.*/', $version, $matches) && $matches[2] >= 6) { | |
+ $info .= "core = \"$matches[1]\"\n"; | |
+ } | |
+ $info .= "project = \"$project\"\n"; | |
+ $info .= 'datestamp = "'. time() ."\"\n"; | |
+ $info .= "\n"; | |
+ | |
+ if (!$info_fd = fopen($file, 'a+')) { | |
+ drush_set_error(dt("ERROR: fopen(@file, 'ab') failed", array('@file' => $file))); | |
+ return false; | |
+ } | |
+ if (!fwrite($info_fd, $info)) { | |
+ drush_set_error(dt("ERROR: fwrite(@file) failed", array('@file' => $file)) . '<pre>' . $info); | |
+ return false; | |
+ } | |
+ return true; | |
+ } | |
+ | |
function findDownloadLocation() { | |
$this->path = $this->generatePath(); | |
$this->project_directory = !empty($this->directory_name) ? $this->directory_name : $this->name; |
Did some testing with drush tonight and have some tips:
http://drupal.org/project/drush project has nice pear install info:
(note: may need to sudo)
pear channel-discover pear.drush.org
pear install drush/drush-5.0.0 # note: there may be some instability, but seems ok
(note: drush-5.0.0 has the --gitinfofile which injects version into .info)
Drush bash completion is probably a handy tool for sbox CLI: http://drupalcode.org/project/drush.git/blob/refs/heads/master:/drush.complete.sh
namely: sourcing the bash completion script e.g.: . /usr/share/php/drush/drush.complete.sh
(this provides tab completion for drush commands)
Drush5 provides an injection to the .info file; an example use of this would be:
drush dl --package-handler=git_drupalorg --gitinfofile uuid
(note: the --gitinfofile parameter)
(running .info inject by default)
Using the drushrc.php (a file to specify specific specific drush options in a config file...)
we can ensure that gitinfofile
is enabled by default:
$command_specific['pm-download'] = array('gitinfofile' => TRUE);
(note: unfortunately drush_make doesn't respect the drush dl
paradigm ... drush 5 this will be the preferred method)
(note: to get drush to continue reading my rc file I had to do: drush -c ~/.drush/drushrc.php make example.make www
)
(tip: to see what is happening with the actual drush commands use debug/verbose: drush --debug --verbose -c ~/.drush/drushrc.php make example.make www
)
We can also have specific drushrc.php settings per repo to be fancy: http://drupalcode.org/project/drush.git/blob/refs/heads/master:/examples/example.drushrc.php#l8
and/or
http://drupalcode.org/project/drush.git/blob/refs/heads/master:/examples/example.drushrc.php#l332
(note: I believe this to be a nice way - and the drush recommended way - to organize our alias' and other drush specific settings.)
(note: to accomplish this I believe minimal setup through Puppet could get things in place - this would be for deployed env. - everything else would have a Readme)
<(soon) deprecated>
For drush_make .info inject... (or running drush 4.5)
cd ~/.drush/drush_make/
# http://drupal.org/node/1302820
wget http://drupal.org/files/drush_make_inject_info.patch
patch -p1 < drush_make_inject_info.patch
(note: the necessity to include 'version' in the makefile)
http://drupal.org/node/1302820