Ori.livneh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/90085


Change subject: multiversion/checkoutMediaWiki: create/update 'current' / 
'stable' symlinks
......................................................................

multiversion/checkoutMediaWiki: create/update 'current' / 'stable' symlinks

Bits static asset URLs currently reference a specific production branch. This
is fine in most cases, but in certain cases (such as large files in extensions
that change infrequently) we want a stable URL to the latest version of some
asset, so that the referenced asset is not thrown out of the browser cache on
each release. The current case is the UniversalLanguageSelector extension,
which serves large font files out of its repository.

This patch updates the multiversion/checkoutMediaWiki script so that in
addition to checking out a new production branch, it also updates a pair of
directories in the Bits docroot, static-current & static-stable, that contain
symlinks to the asset paths of the most recent & secondmost recent production
branches, respectively. If only one production branch exists, both current &
stable pointers are pointed to it.

Bug: 55506
Change-Id: If597d70625cf8f06c0e59dd7749442ba05769174
---
M multiversion/checkoutMediaWiki
1 file changed, 55 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/mediawiki-config 
refs/changes/85/90085/1

diff --git a/multiversion/checkoutMediaWiki b/multiversion/checkoutMediaWiki
index 1a73a4b..d4ad849 100755
--- a/multiversion/checkoutMediaWiki
+++ b/multiversion/checkoutMediaWiki
@@ -167,4 +167,59 @@
        }
 }
 
+function updateBitsBranchPointers() {
+       $branchDirs = glob( MW_COMMON . '/php-*', GLOB_ONLYDIR );
+
+       if ( !is_array( $branchDirs ) || count( $branchDirs ) < 1 ) {
+               fwrite( STDERR, __FUNCTION__ . ': no deployment branch 
directories found in ' . MW_COMMON . "\n" );
+               exit( 1 );
+       }
+
+       $branches = array();
+       $branches['current'] = array_pop( $branchDirs );
+       // If there's only one deployment branch, make both 'current' & 
'stable' symlinks refer to it.
+       $branches['stable'] = array_pop( $branchDirs ) ?: $branches['current'];
+
+       foreach( $branches as $branch => $target ) {
+               $parent = MW_COMMON_SOURCE . "/docroot/bits/static-$branch";
+
+               echo "Updating $branch branch pointer...\n";
+
+               if ( !file_exists( $parent ) && !mkdir( $parent, 0775 ) ) {
+                       fwrite( STDERR, __FUNCTION__ . ": $parent does not 
exist and could not be created.\n" );
+                       exit( 1 );
+               }
+
+               foreach( array( 'skins', 'extensions', 'resources' ) as $child 
) {
+                       $link = $parent . '/' . $child;
+                       $dest = $target . '/' . $child;
+
+                       if ( file_exists( $link ) ) {
+                               if ( realpath( $link ) === $dest ) {
+                                       echo "$link is already up-to-date.\n";
+                                       continue;
+                               }
+
+                               if ( !is_link( $link ) ) {
+                                       fwrite( STDERR, __FUNCTION__ . ": $link 
exists and is not a symbolic link.\n" );
+                                       exit( 1 );
+                               }
+
+                               if ( !unlink( $link ) ) {
+                                       fwrite( STDERR, __FUNCTION__ . ": 
failed to unlink $link\n" );
+                                       exit( 1 );
+                               }
+                       }
+
+                       if ( !symlink( $dest, $link ) ) {
+                               fwrite( STDERR, __FUNCTION__ . ": failed to 
create $link\n" );
+                               exit( 1 );
+                       }
+                       echo "$link => $dest\n";
+               }
+               echo "\n";
+       }
+}
+
 checkoutMediaWiki();
+updateBitsBranchPointers();

-- 
To view, visit https://gerrit.wikimedia.org/r/90085
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If597d70625cf8f06c0e59dd7749442ba05769174
Gerrit-PatchSet: 1
Gerrit-Project: operations/mediawiki-config
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to