/** * $output_format can be: language, prosilver and subsilver2 */ function build_code_changes($output_format) { global $substitute_new, $substitute_old, $simple_name_old, $simple_name_new, $echo_changes, $package_changed_files, $location, $debug_file, $s_name; // Global array holding the data entries $data = array('header' => array(), 'diff' => array()); // Read diff file and prepare the output filedata... //$patch_filename = '../new_version/patches/phpBB-' . $substitute_old . '_to_' . $substitute_new . '.patch'; $release_filename = 'phpbb-' . $substitute_old . '_to_' . $substitute_new . '_' . $output_format . '.txt'; if (!$package_changed_files) { if (!$echo_changes) { $fp = fopen('save/' . $s_name . '/' . $output_format . '/' . $release_filename, 'wb'); if (!$fp) { die('Unable to create ' . $release_filename); } } } include_once $location . '/build_helper.php'; $package = new build_package(array($substitute_old, $substitute_new), false); $titles = array('language' => 'phpBB ' . $substitute_old . ' to phpBB ' . $substitute_new . ' Language Pack Changes', 'prosilver' => 'phpBB ' . $substitute_old . ' to phpBB ' . $substitute_new . ' prosilver Changes', 'subsilver2' => 'phpBB ' . $substitute_old . ' to phpBB ' . $substitute_new . ' subsilver2 Changes'); $data['header'] = array('title' => $titles[$output_format], 'intro' => ' These are the ' . $titles[$output_format] . ' summed up into a little Mod. These changes are only partial and do not include any code changes, therefore not meant for updating phpBB. ', 'included_files' => array()); // We collect the files we want to diff first (ironically we grab this from a diff file) if (!$echo_changes) { echo "\n\nCollecting Filenames:"; } // We re-create the patch file foreach ($package->old_packages as $_package_name => $dest_package_filename) { chdir($package->locations['old_versions']); if (!$echo_changes) { echo "\n\n" . 'Creating patch/diff files for phpBB-' . $dest_package_filename . $package->get('new_version_number'); } $dest_package_filename = $location . '/save/' . $s_name . '/phpBB-' . $dest_package_filename . $package->get('new_version_number') . '.patch'; $package->run_command('diff ' . $package->diff_options . ' ' . $_package_name . ' ' . $package->get('simple_name') . ' > ' . $dest_package_filename); // Parse this diff to determine file changes from the checked versions and save them $result = $package->collect_diff_files($dest_package_filename, $_package_name); $package->run_command('rm ' . $dest_package_filename); } chdir($location); $filenames = array(); foreach ($result['files'] as $filename) { if ($debug_file !== false && $filename != $debug_file) { continue; } // Decide which files to compare... switch ($output_format) { case 'language': if (strpos($filename, 'language/en/') !== 0) { continue 2; } break; case 'prosilver': if (strpos($filename, 'styles/prosilver/') !== 0) { continue 2; } break; case 'subsilver2': if (strpos($filename, 'styles/subsilver2/') !== 0) { continue 2; } break; } if (!file_exists($location . '/old_versions/' . $simple_name_old . '/' . $filename)) { // New file... include it $data['header']['included_files'][] = array('old' => $location . '/old_versions/' . $simple_name_old . '/' . $filename, 'new' => $location . '/old_versions/' . $simple_name_new . '/' . $filename, 'phpbb_filename' => $filename); continue; } $filenames[] = array('old' => $location . '/old_versions/' . $simple_name_old . '/' . $filename, 'new' => $location . '/old_versions/' . $simple_name_new . '/' . $filename, 'phpbb_filename' => $filename); } // Now let us go through the filenames list and create a more comprehensive diff if (!$echo_changes) { fwrite($fp, build_header($output_format, $filenames, $data['header'])); } else { //echo build_header('text', $filenames, $data['header']); } // Copy files... $files_to_copy = array(); foreach ($data['header']['included_files'] as $filename) { $files_to_copy[] = $filename['phpbb_filename']; } // First step is to copy the new version over (clean structure) if (!$echo_changes && sizeof($files_to_copy)) { foreach ($files_to_copy as $file) { // Create directory? $dirname = dirname($file); if ($dirname) { $dirname = explode('/', $dirname); $__dir = array(); foreach ($dirname as $i => $dir) { $__dir[] = $dir; run_command("mkdir -p {$location}/save/" . $s_name . '/' . $output_format . '/' . implode('/', $__dir)); } } $source_file = $location . '/new_version/phpBB3/' . $file; $dest_file = $location . '/save/' . $s_name . '/' . $output_format . '/'; $dest_file .= $file; $command = "cp -p {$source_file} {$dest_file}"; $result = trim(`{$command}`); echo "- Copied File: " . $source_file . " -> " . $dest_file . "\n"; } } include_once 'diff_class.php'; if (!$echo_changes) { echo "\n\nDiffing Codebases:"; } foreach ($filenames as $file_ary) { if (!file_exists($file_ary['old'])) { $lines1 = array(); } else { $lines1 = file($file_ary['old']); } $lines2 = file($file_ary['new']); if (!sizeof($lines1)) { // New File } else { $diff = new Diff($lines1, $lines2); $fmt = new BBCodeDiffFormatter(false, 5, $debug_file); if (!$echo_changes) { fwrite($fp, $fmt->format_open($file_ary['phpbb_filename'])); fwrite($fp, $fmt->format($diff, $lines1)); fwrite($fp, $fmt->format_close($file_ary['phpbb_filename'])); } else { echo $fmt->format_open($file_ary['phpbb_filename']); echo $fmt->format($diff, $lines1); echo $fmt->format_close($file_ary['phpbb_filename']); } if ($debug_file !== false) { echo $fmt->format_open($file_ary['phpbb_filename']); echo $fmt->format($diff, $lines1); echo $fmt->format_close($file_ary['phpbb_filename']); exit; } } } if (!$echo_changes) { fwrite($fp, build_footer($output_format)); // Close file fclose($fp); chmod('save/' . $s_name . '/' . $output_format . '/' . $release_filename, 0666); } else { echo build_footer($output_format); } }
foreach ($package->remove_from_diff_structure as $remove_dir) { $package->run_command('rm -Rv ' . $location . '/' . $remove_dir); } } // Go trough all versions making a diff if we even have old versions // For phpBB 3.0.x we might choose a different update method, rendering the things below useless... if (sizeof($package->old_packages)) { chdir($package->locations['old_versions']); // This array is for holding the filenames change $diff_file_changes = array(); foreach ($package->old_packages as $_package_name => $dest_package_filename) { $package->begin_status('Creating patch/diff files for phpBB-' . $dest_package_filename . $package->get('new_version_number')); $dest_package_filename = $package->get('patch_directory') . '/phpBB-' . $dest_package_filename . $package->get('new_version_number') . '.patch'; $package->run_command('diff ' . $package->diff_options . ' ' . $_package_name . ' ' . $package->get('simple_name') . ' > ' . $dest_package_filename); // Parse this diff to determine file changes from the checked versions and save them $diff_file_changes[$_package_name] = $package->collect_diff_files($dest_package_filename, $_package_name); } // Now put those files determined within the correct directories foreach ($diff_file_changes as $_package_name => $file_contents) { $package->begin_status('Creating files-only informations for ' . $package->old_packages[$_package_name] . $package->get('new_version_number')); $dest_filename_dir = $package->get('files_directory') . '/' . $package->old_packages[$_package_name] . $package->get('new_version_number'); if (!file_exists($dest_filename_dir)) { $package->run_command('mkdir ' . $dest_filename_dir); } // Now copy the file contents foreach ($file_contents['all'] as $file) { $source_filename = $package->get('dest_dir') . '/' . $file; $dest_filename = $dest_filename_dir . '/' . $file; // Create Directories along the way? $file = explode('/', $file); // Remove filename portion
$versions = array_map('trim', $versions); $verbose = true; require 'build_helper.php'; $package = new build_package($versions, $verbose); echo "Building Release Packages\n"; echo "Now all three package types (patch, files, release) are built as well as the update package (update).\n"; // Go trough all versions making a diff if we even have old versions // For phpBB 3.0.x we might choose a different update method, rendering the things below useless... if (sizeof($package->old_packages)) { chdir($package->locations['old_versions']); // This array is for holding the filenames change $diff_file_changes = array(); foreach ($package->old_packages as $_package_name => $dest_package_filename) { $package->begin_status('Parsing patch/diff files for phpBB-' . $dest_package_filename . $package->get('new_version_number')); // Parse this diff to determine file changes from the checked versions and save them $diff_file_changes[$_package_name] = $package->collect_diff_files($package->get('patch_directory') . '/phpBB-' . $dest_package_filename . $package->get('new_version_number') . '.patch', $_package_name); } // Now put those files determined within the correct directories foreach ($diff_file_changes as $_package_name => $file_contents) { $package->begin_status('Creating files-only informations for ' . $package->old_packages[$_package_name] . $package->get('new_version_number')); $dest_filename_dir = $package->get('files_directory') . '/' . $package->old_packages[$_package_name] . $package->get('new_version_number'); if (!file_exists($dest_filename_dir)) { $package->run_command('mkdir ' . $dest_filename_dir); } // Now copy the file contents foreach ($file_contents['all'] as $file) { $source_filename = $package->get('dest_dir') . '/' . $file; $dest_filename = $dest_filename_dir . '/' . $file; // Create Directories along the way? $file = explode('/', $file); // Remove filename portion