$value){ $file[$index] = explode(' ', $file[$index]); if($file[$index][0] == 'content'){ $file[$index][2] = 'jar:chrome/' . SHORT_APP_NAME . '.jar!/' . $file[$index][2]; } elseif($file[$index][0] == "locale" || $file[$index][0] == "skin"){ $file[$index][3] = 'jar:chrome/' . SHORT_APP_NAME . '.jar!/' . $file[$index][3]; } $file[$index] = implode(' ', $file[$index]); } $file = implode("\n", $file); file_put_contents('Releases\\' . SHORT_APP_NAME . '\\chrome.manifest', $file); shell_exec('xcopy /E /I Releases\\' . SHORT_APP_NAME . ' Releases\\' . SHORT_APP_NAME . '-mozillaAddons'); $file = file_get_contents('Releases\\' . SHORT_APP_NAME . '-mozillaAddons\\install.rdf'); $file = explode("\n", $file); $applications = array(); $currentApp = null; foreach($file as $index => $value){ if(strpos($value, 'http://' . SHORT_APP_NAME . '.fvds.frih.net/update.rdf') !== false){ $file[$index] = ""; } if(preg_match('/([0-9\.A-Za-z]+)<\/em:version>/', $value, $matches) == 1){ $version = $matches[1]; } if(strpos($value, '') !== false){ $currentApp = array(); } if(strpos($value, '') !== false){ $applications[] = $currentApp; $currentApp = null; } if(preg_match('/(\{[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\}|[^<@]+@[^<]+)<\/em:id>/', $value, $matches) == 1 && $currentApp !== null){ $currentApp['id'] = $matches[1]; } if(preg_match('/([0-9\.*+A-Za-z]+)<\/em:minVersion>/', $value, $matches) == 1 && $currentApp !== null){ $currentApp['minVersion'] = $matches[1]; } if(preg_match('/([0-9\.*+A-Za-z]+)<\/em:maxVersion>/', $value, $matches) == 1 && $currentApp !== null){ $currentApp['maxVersion'] = $matches[1]; } } $file = implode("\n", $file); file_put_contents('Releases\\' . SHORT_APP_NAME . '-mozillaAddons\\install.rdf', $file); if(preg_match('/[A-Za-z]/', $version) === 1){ $officialVersion = false; } else { $officialVersion = true; } // Do some checks $stop = false; if(file_exists('Releases\\' . SHORT_APP_NAME . '-' . $version . '.xpi')){ echo 'This file version already exists. Are you sure you want to overwrite it? Y/N: '; $response = substr(trim(fgets(STDIN)), 0, 1); if($response != 'Y' && $response != 'y'){ $stop = true; } else { echo "File will be overwritten.\n"; } } $file = file_get_contents('Releases\\' . SHORT_APP_NAME . '\\chrome.manifest'); $locales = opendir('Releases\\' . SHORT_APP_NAME . '\\locale\\'); while(!$stop && false !== ($currentlocale = readdir($locales))){ if($currentlocale != '..' && $currentlocale != '.' && strpos($file, $currentlocale) === false){ echo "Locale $currentlocale not found in chrome.manifest.\n"; $stop = true; } } closedir($locales); if($stop){ shell_exec('cd Releases & rmdir /S /Q ' . SHORT_APP_NAME . ' & rmdir /S /Q ' . SHORT_APP_NAME . '-mozillaAddons'); echo "Build process stopped.\n"; exit; } shell_exec(' cd Releases\\' . SHORT_APP_NAME . ' & 7za a -tzip ' . SHORT_APP_NAME . '.jar ' . CONTENT . ' ' . LOCALE . ' ' . SKIN . ' & rmdir /S /Q ' . CONTENT . ' ' . LOCALE . ' ' . SKIN . ' & mkdir chrome & move ' . SHORT_APP_NAME . '.jar chrome\\'); shell_exec(' cd Releases\\' . SHORT_APP_NAME . ' & 7za a -tzip ..\\' . SHORT_APP_NAME . '-' . $version . '.xpi * & cd .. & rmdir /S /Q ' . SHORT_APP_NAME . ''); if($officialVersion){ shell_exec('cd Releases\\' . SHORT_APP_NAME . '-mozillaAddons & 7za a -tzip ..\\' . SHORT_APP_NAME . '-' . $version . '-mozillaAddons.xpi * & cd .. & rmdir /S /Q ' . SHORT_APP_NAME . '-mozillaAddons'); } else { shell_exec('cd Releases & rmdir /S /Q ' . SHORT_APP_NAME . '-mozillaAddons'); } shell_exec('copy /Y Releases\\' . SHORT_APP_NAME . '-' . $version . '.xpi Web\\releases\\ '); if($officialVersion){ $file = ' ' . $version . ''; foreach($applications as $index => $value){ $file .= ' ' . $value['id'] . ' ' . $value['minVersion'] . ' ' . $value['maxVersion'] . ' http://' . SHORT_APP_NAME . '.fvds.frih.net/releases/' . SHORT_APP_NAME . '-' . $version . '.xpi '; } $file .= ' ' . $version . ' http://' . SHORT_APP_NAME . '.fvds.frih.net/releases/' . SHORT_APP_NAME . '-' . $version . '.xpi '; file_put_contents('Web\update.rdf', $file); $file = file_get_contents('Web\index.php'); $file = explode("\n", $file); foreach($file as $index => $value){ if(strpos($value, '') === 0){ $file[$index] = '

Click here to download ' . LONG_APP_NAME . ' v' . $version . '

'; } } $file = implode("\n", $file); file_put_contents('Web\index.php', $file); echo "Remember to manually:\n\t- Upload index.php, update.rdf and the new release to the web\n\t- Submit the new release to addons.mozilla.org\n\t- Change the version number\n\n"; } else { echo "Remember to manually:\n\t- Upload the new release to the web\n\t- Change the version number\n\n"; } ?>