Skip to content

Instantly share code, notes, and snippets.

@joshkoenig
Created May 3, 2012 19:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save joshkoenig/2588420 to your computer and use it in GitHub Desktop.
Save joshkoenig/2588420 to your computer and use it in GitHub Desktop.
Strip drupal.org packaging data from core .info files
<?php
/**
* Quick script for stripping drupal packaging info.
*
* Run in the drupal root, or specify the root as an argument. E.g.:
*
* php strip_info.php path/to/drupal
*
*/
$dir = isset($argv[1]) ? $argv[1] : '.';
echo "Looking for core modules/themes in '$dir'\n";
strip_packaging_info($dir .'/modules');
strip_packaging_info($dir .'/themes');
function strip_packaging_info($dir) {
if (is_dir($dir) && $handle = opendir($dir)) {
echo "Directory $dir:\n";
while (false !== ($entry = readdir($handle))) {
if (is_dir($dir.'/'.$entry) && file_exists($dir.'/'.$entry.'/'.$entry.'.info')) {
$lines = file($dir.'/'.$entry.'/'.$entry.'.info');
$fh = fopen($dir.'/'.$entry.'/'.$entry.'.info', 'w');
foreach($lines as $line) {
if (strpos($line, '; Information added by drupal.org packaging script') !== FALSE) {
break;
}
fwrite($fh, $line);
}
fclose($fh);
echo "Rewrote $dir/$entry/$entry.info\n";
}
}
closedir($handle);
}
}
echo <<<EndTXT
DONE!
You should probably run a "git diff" now to be sure everything is as expected.
EndTXT;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment