public
Created

Strip drupal.org packaging data from core .info files

  • Download Gist
strip_info.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
<?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;

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.