Create a gist now

Instantly share code, notes, and snippets.

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