diff options
author | Andreas Fischer <bantu@phpbb.com> | 2013-10-01 16:13:10 +0200 |
---|---|---|
committer | Andreas Fischer <bantu@phpbb.com> | 2013-10-01 16:16:19 +0200 |
commit | dbd0380c3fb9edeaa6ec32b4f2348eca26955831 (patch) | |
tree | 7b3a98fe25ce0e08bcc336ff64a6e5ae86f09981 /build | |
parent | 0cf9d657b7c56e602248d5998a49b7d392b16d39 (diff) | |
download | forums-dbd0380c3fb9edeaa6ec32b4f2348eca26955831.tar forums-dbd0380c3fb9edeaa6ec32b4f2348eca26955831.tar.gz forums-dbd0380c3fb9edeaa6ec32b4f2348eca26955831.tar.bz2 forums-dbd0380c3fb9edeaa6ec32b4f2348eca26955831.tar.xz forums-dbd0380c3fb9edeaa6ec32b4f2348eca26955831.zip |
[ticket/11877] Create package links and checksums for announcement via script.
PHPBB3-11877
Diffstat (limited to 'build')
-rw-r--r-- | build/build.xml | 12 | ||||
-rwxr-xr-x | build/build_announcement.php | 98 |
2 files changed, 110 insertions, 0 deletions
diff --git a/build/build.xml b/build/build.xml index f0962e67eb..018f7b91a2 100644 --- a/build/build.xml +++ b/build/build.xml @@ -169,6 +169,18 @@ <exec dir="${dir}" command="sha256sum ${filename} > ${filename}.sha256" /> </target> + <target name="announcement" depends="prepare"> + <echo msg="Writing download links and checksums for email announcement to save/announcement_email_${newversion}.txt" /> + <exec dir="build" escape="false" + command="php -f build_announcement.php email '${newversion}' 'new_version/release_files' sha256 > + save/announcement_email_${newversion}.txt" /> + + <echo msg="Writing download links and checksums for bbcode announcement to save/announcement_bbcode_${newversion}.txt" /> + <exec dir="build" escape="false" + command="php -f build_announcement.php bbcode '${newversion}' 'new_version/release_files' sha256 > + save/announcement_bbcode_${newversion}.txt" /> + </target> + <target name="changelog" depends="prepare"> <exec dir="build" escape="false" command="php -f build_changelog.php '${newversion}' > diff --git a/build/build_announcement.php b/build/build_announcement.php new file mode 100755 index 0000000000..3ee96fc67d --- /dev/null +++ b/build/build_announcement.php @@ -0,0 +1,98 @@ +#!/usr/bin/env php +<?php +/** +* +* @package build +* @copyright (c) 2013 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +if (php_sapi_name() !== 'cli' || $_SERVER['argc'] != 5) +{ + echo "Usage (CLI only): build_announcement.php email|bbcode new_version release_files_dir checksum_algorithm\n"; + exit(1); +} + +$mode = $_SERVER['argv'][1]; +$version = $_SERVER['argv'][2]; +$root = $_SERVER['argv'][3]; +$checksum_algorithm = $_SERVER['argv'][4]; + +$series_version = substr($version, 0, 3); +$base_url = "https://download.phpbb.com/pub/release/$series_version"; + +if (strpos($version, 'RC') === false) +{ + // Final release + $install_url = "$base_url/$version"; + $update_url = "$base_url/update/to_$version"; +} +else +{ + $install_url = "$base_url/release_candidates/$version"; + $update_url = "$base_url/release_candidates/update/other_to_$version"; +} + +if ($mode === 'bbcode') +{ + $template = "[url=%1\$s/%2\$s]%2\$s[/url]\n{$checksum_algorithm}sum: %3\$s\n"; +} +else +{ + $template = "%s/%s\n{$checksum_algorithm}sum: %s\n"; +} + +function phpbb_rnatsort($array) +{ + $strrnatcmp = function($a, $b) + { + return strnatcmp($b, $a); + }; + usort($array, $strrnatcmp); + return $array; +} + +function phpbb_string_ends_with($haystack, $needle) +{ + return substr($haystack, -strlen($needle)) === $needle; +} + +function phpbb_is_update_file($filename) +{ + return strpos($filename, '_to_') !== false; +} + +function phpbb_get_checksum($checksum_file) +{ + return array_shift(explode(' ', file_get_contents($checksum_file))); +} + +$install_files = $update_files = array(); +foreach (phpbb_rnatsort(array_diff(scandir($root), array('.', '..'))) as $filename) +{ + if (phpbb_string_ends_with($filename, $checksum_algorithm)) + { + continue; + } + else if (phpbb_is_update_file($filename)) + { + $update_files[] = $filename; + } + else + { + $install_files[] = $filename; + } +} + +foreach ($install_files as $filename) +{ + printf($template, $install_url, $filename, phpbb_get_checksum("$root/$filename.$checksum_algorithm")); +} + +echo "\n"; + +foreach ($update_files as $filename) +{ + printf($template, $update_url, $filename, phpbb_get_checksum("$root/$filename.$checksum_algorithm")); +} |