@@ -28,7 +28,7 @@ function usage($command)
2828{
2929 echo PHP_EOL ;
3030 echo 'Usage: php ' . $ command . ' [options] ' . PHP_EOL ;
31- echo PHP_TAB . '[options]: ' . PHP_EOL ;
31+ echo PHP_TAB . '[options]: ' . PHP_EOL ;
3232 echo PHP_TAB . PHP_TAB . '--remote <remote>: ' . PHP_TAB . 'The git remote reference to build from (ex: `tags/3.8.6`, `4.0-dev`), defaults to the most recent tag for the repository ' . PHP_EOL ;
3333 echo PHP_TAB . PHP_TAB . '--exclude-zip: ' . PHP_TAB . PHP_TAB . 'Exclude the generation of .zip packages ' . PHP_EOL ;
3434 echo PHP_TAB . PHP_TAB . '--exclude-gzip: ' . PHP_TAB . PHP_TAB . 'Exclude the generation of .tar.gz packages ' . PHP_EOL ;
@@ -71,6 +71,9 @@ function usage($command)
7171$ excludeBzip2 = isset ($ options ['exclude-bzip2 ' ]);
7272$ showHelp = isset ($ options ['help ' ]);
7373
74+ // Disable the generation of extra text files
75+ $ includeExtraTextfiles = false ;
76+
7477if ($ showHelp )
7578{
7679 usage ($ argv [0 ]);
@@ -84,6 +87,9 @@ function usage($command)
8487 $ tagVersion = system ($ systemGit . ' describe --tags ` ' . $ systemGit . ' rev-list --tags --max-count=1` ' , $ tagVersion );
8588 $ remote = 'tags/ ' . $ tagVersion ;
8689 chdir ($ here );
90+
91+ // We are in release mode so we need the extra text files
92+ $ includeExtraTextfiles = true ;
8793}
8894
8995echo "Start build for remote $ remote. \n" ;
@@ -228,18 +234,21 @@ function usage($command)
228234 // Loop through and add all files except: tests, installation, build, .git, .travis, travis, phpunit, .md, or images
229235 foreach ($ files as $ file )
230236 {
231- if (substr ($ file , 0 , 1 ) === 'R ' ) {
232- $ fileName = substr ($ file , strrpos ($ file , "\t" ) + 1 );
233- } else {
234- $ fileName = substr ($ file , 2 );
237+ if (substr ($ file , 0 , 1 ) === 'R ' )
238+ {
239+ $ fileName = substr ($ file , strrpos ($ file , "\t" ) + 1 );
240+ }
241+ else
242+ {
243+ $ fileName = substr ($ file , 2 );
235244 }
236- $ folderPath = explode ('/ ' , $ fileName );
237- $ baseFolderName = $ folderPath [0 ];
238245
239- $ doNotPackageFile = in_array (trim ($ fileName ), $ doNotPackage );
240- $ doNotPatchFile = in_array (trim ($ fileName ), $ doNotPatch );
246+ $ folderPath = explode ('/ ' , $ fileName );
247+ $ baseFolderName = $ folderPath [0 ];
248+ $ doNotPackageFile = in_array (trim ($ fileName ), $ doNotPackage );
249+ $ doNotPatchFile = in_array (trim ($ fileName ), $ doNotPatch );
241250 $ doNotPackageBaseFolder = in_array ($ baseFolderName , $ doNotPackage );
242- $ doNotPatchBaseFolder = in_array ($ baseFolderName , $ doNotPatch );
251+ $ doNotPatchBaseFolder = in_array ($ baseFolderName , $ doNotPatch );
243252
244253 if ($ doNotPackageFile || $ doNotPatchFile || $ doNotPackageBaseFolder || $ doNotPatchBaseFolder )
245254 {
@@ -389,84 +398,98 @@ function usage($command)
389398
390399chdir ('.. ' );
391400
392- foreach (array_keys ($ checksums ) as $ packageName )
401+ // Thats only needed when we release a version
402+ if ($ includeExtraTextfiles )
393403{
394- echo "Generating checksums for $ packageName \n" ;
395404
396- foreach (array ( ' md5 ' , ' sha1 ' , ' sha256 ' , ' sha384 ' , ' sha512 ' ) as $ hash )
405+ foreach (array_keys ( $ checksums ) as $ packageName )
397406 {
398- if (file_exists ('packages/ ' . $ packageName ))
399- {
400- $ checksums [$ packageName ][$ hash ] = hash_file ($ hash , 'packages/ ' . $ packageName );
401- }
402- else
407+ echo "Generating checksums for $ packageName \n" ;
408+
409+ foreach (array ('sha256 ' , 'sha384 ' , 'sha512 ' ) as $ hash )
403410 {
404- echo "Package $ packageName not found in build directories \n" ;
411+ if (file_exists ('packages/ ' . $ packageName ))
412+ {
413+ $ checksums [$ packageName ][$ hash ] = hash_file ($ hash , 'packages/ ' . $ packageName );
414+ }
415+ else
416+ {
417+ echo "Package $ packageName not found in build directories \n" ;
418+ }
405419 }
406420 }
407- }
408-
409- echo "Generating checksums.txt file \n" ;
410421
411- $ checksumsContent = '' ;
422+ echo " Generating checksums.txt file \n" ;
412423
413- foreach ($ checksums as $ packageName => $ packageHashes )
414- {
415- $ checksumsContent .= "Filename: $ packageName \n" ;
424+ $ checksumsContent = '' ;
416425
417- foreach ($ packageHashes as $ hashType => $ hash )
426+ foreach ($ checksums as $ packageName => $ packageHashes )
418427 {
419- $ checksumsContent .= "$ hashType: $ hash \n" ;
420- }
428+ $ checksumsContent .= "Filename: $ packageName \n" ;
421429
422- $ checksumsContent .= "\n" ;
423- }
430+ foreach ($ packageHashes as $ hashType => $ hash )
431+ {
432+ $ checksumsContent .= "$ hashType: $ hash \n" ;
433+ }
424434
425- file_put_contents ('checksums.txt ' , $ checksumsContent );
435+ $ checksumsContent .= "\n" ;
436+ }
426437
427- echo " Generating github_release .txt file \n" ;
438+ file_put_contents ( ' checksums .txt' , $ checksumsContent ) ;
428439
429- $ githubContent = array ();
430- $ githubText = '' ;
431- $ releaseText = array (
432- 'FULL ' => 'New Joomla! Installations ' ,
433- 'POINT ' => 'Update from Joomla! ' . $ version . '. ' . $ previousRelease . ' ' ,
434- 'MINOR ' => 'Update from Joomla! ' . $ version . '.x ' ,
435- 'UPGRADE ' => 'Update from Joomla! 2.5 or previous 3.x releases ' ,
436- );
437- $ githubLink = 'https://github.com/joomla/joomla-cms/releases/download/ ' . $ tagVersion . '/ ' ;
440+ echo "Generating github_release.txt file \n" ;
438441
439- foreach ($ checksums as $ packageName => $ packageHashes )
440- {
441- $ type = '' ;
442- if (strpos ($ packageName , 'Full_Package ' ) !== false )
442+ $ githubContent = array ();
443+ $ githubText = '' ;
444+ $ releaseText = array (
445+ 'FULL ' => 'New Joomla! Installations ' ,
446+ 'POINT ' => 'Update from Joomla! ' . $ version . '. ' . $ previousRelease . ' ' ,
447+ 'MINOR ' => 'Update from Joomla! ' . $ version . '.x ' ,
448+ 'UPGRADE ' => 'Update from Joomla! 2.5 or previous 3.x releases ' ,
449+ );
450+ $ githubLink = 'https://github.com/joomla/joomla-cms/releases/download/ ' . $ tagVersion . '/ ' ;
451+
452+ foreach ($ checksums as $ packageName => $ packageHashes )
443453 {
444- $ type = 'FULL ' ;
445- } elseif (strpos ($ packageName , 'Patch_Package ' ) !== false ) {
446- if (strpos ($ packageName , '.x_to ' ) !== false ) {
447- $ type = 'MINOR ' ;
448- } else {
449- $ type = 'POINT ' ;
454+ $ type = '' ;
455+
456+ if (strpos ($ packageName , 'Full_Package ' ) !== false )
457+ {
458+ $ type = 'FULL ' ;
459+ }
460+ elseif (strpos ($ packageName , 'Patch_Package ' ) !== false )
461+ {
462+ if (strpos ($ packageName , '.x_to ' ) !== false )
463+ {
464+ $ type = 'MINOR ' ;
465+ }
466+ else
467+ {
468+ $ type = 'POINT ' ;
469+ }
470+ }
471+ elseif (strpos ($ packageName , 'Update_Package ' ) !== false )
472+ {
473+ $ type = 'UPGRADE ' ;
450474 }
451- } elseif ( strpos ( $ packageName , ' Update_Package ' ) !== false ) {
452- $ type = 'UPGRADE ' ;
475+
476+ $ githubContent [ $ type][] = '[ ' . substr ( $ packageName , strpos ( $ packageName , ' Package ' ) + 7 ) . ' ]( ' . $ githubLink . $ packageName . ' ) ' ;
453477 }
454478
455- $ githubContent [$ type ][] = '[ ' . substr ($ packageName , strpos ($ packageName , 'Package ' ) + 7 ) . ']( ' . $ githubLink . $ packageName . ') ' ;
456- }
479+ foreach ($ releaseText as $ type => $ text )
480+ {
481+ if (empty ($ githubContent [$ type ]))
482+ {
483+ continue ;
484+ }
457485
458- foreach ($ releaseText as $ type => $ text )
459- {
460- if (empty ($ githubContent [$ type ])) {
461- continue ;
462- }
486+ $ githubText .= $ text ;
487+ $ githubText .= implode (" | " , $ githubContent [$ type ]);
463488
464- $ githubText .= $ text ;
465- $ githubText .= implode ( " | " , $ githubContent [ $ type ]);
489+ $ githubText .= "\n" ;
490+ }
466491
467- $ githubText .= "\n" ;
492+ file_put_contents ( ' github_release.txt ' , $ githubText ) ;
468493}
469494
470- file_put_contents ('github_release.txt ' , $ githubText );
471-
472495echo "Build of version $ fullVersion complete! \n" ;
0 commit comments