Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Strip packaging data from core .info files
* 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 packaging script') !== FALSE) {
fwrite($fh, $line);
echo "Rewrote $dir/$entry/$\n";
echo <<<EndTXT
You should probably run a "git diff" now to be sure everything is as expected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment