Skip to content

Commit

Permalink
Add PHP script for extensions and skins setup (#390)
Browse files Browse the repository at this point in the history
* Move skins setup to skins.yaml and add shell script for execution

* Move skins setup to skins.yaml and add shell script for execution

* Move skins setup to skins.yaml and add shell script for execution

* Move skins setup to skins.yaml and add shell script for execution

* Use php script for extensions and skins setup (earlier - shell)

* Use php script for extensions and skins setup (earlier - shell)

* Use php script for extensions and skins setup (earlier - shell)
  • Loading branch information
naresh-kumar-babu authored Jun 13, 2024
1 parent b3a87ea commit ed9cd06
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 62 deletions.
36 changes: 4 additions & 32 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -103,30 +103,10 @@ RUN set -x; \
# Skins
# The Minerva Neue, MonoBook, Timeless, Vector and Vector 2022 skins are bundled into MediaWiki and do not need to be
# separately installed.
RUN set -x; \
cd $MW_HOME/skins \
# Chameleon (v. 4.2.1)
&& git clone https://github.com/ProfessionalWiki/chameleon $MW_HOME/skins/chameleon \
&& cd $MW_HOME/skins/chameleon \
&& git checkout -q f34a56528ada14ac07e1b03beda41f775ef27606 \
# CologneBlue
&& git clone -b $MW_VERSION --single-branch https://github.com/wikimedia/mediawiki-skins-CologneBlue $MW_HOME/skins/CologneBlue \
&& cd $MW_HOME/skins/CologneBlue \
&& git checkout -q 4d588eb78d7e64e574f631c5897579537305437d \
# Modern
&& git clone -b $MW_VERSION --single-branch https://github.com/wikimedia/mediawiki-skins-Modern $MW_HOME/skins/Modern \
&& cd $MW_HOME/skins/Modern \
&& git checkout -q fb6c2831b5f150e9b82d98d661710695a2d0f8f2 \
# Pivot
&& git clone -b v2.3.0 https://github.com/wikimedia/mediawiki-skins-Pivot $MW_HOME/skins/pivot \
&& cd $MW_HOME/skins/pivot \
&& git checkout -q d79af7514347eb5272936243d4013118354c85c1 \
# Refreshed
&& git clone -b $MW_VERSION --single-branch https://github.com/wikimedia/mediawiki-skins-Refreshed $MW_HOME/skins/Refreshed \
&& cd $MW_HOME/skins/Refreshed \
&& git checkout -q 86f33620f25335eb62289aa18d342ff3b980d8b8

COPY _sources/scripts/extensions-skins.php /tmp/extensions-skins.php
COPY _sources/patches/* /tmp/
COPY _sources/configs/skins.yaml /tmp/skins.yaml
RUN php /tmp/extensions-skins.php "skins" "/tmp/skins.yaml"

# Extensions
# The following extensions are bundled into MediaWiki and do not need to be separately installed:
Expand All @@ -136,16 +116,8 @@ COPY _sources/patches/* /tmp/
# VisualEditor, WikiEditor.
# The following extensions are downloaded via Composer and also do not need to be downloaded here:
# Bootstrap, DataValues (and related extensions like DataValuesCommon), ParserHooks.
COPY _sources/scripts/extension-setup.sh /tmp/extension-setup.sh
COPY _sources/configs/extensions.yaml /tmp/extensions.yaml
RUN wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
RUN chmod a+x /usr/local/bin/yq
RUN set -x; \
apt-get update \
&& apt-get install -y jq \
&& chmod +x /tmp/extension-setup.sh

RUN /tmp/extension-setup.sh
RUN php /tmp/extensions-skins.php "extensions" "/tmp/extensions.yaml"

# Patch composer
RUN set -x; \
Expand Down
17 changes: 17 additions & 0 deletions _sources/configs/skins.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Canasta YAML file for skins for MediaWiki 1.39.
# Where the repository is not specified, the Wikimedia Git repository for the
# skins with that name is used, and the default branch used is REL1_39.
# Where the repository *is* specified, the default branch used is master.
skins:
- Chameleon:
commit: f34a56528ada14ac07e1b03beda41f775ef27606 # v. 4.2.1
repository: https://github.com/ProfessionalWiki/chameleon
- CologneBlue:
commit: 4d588eb78d7e64e574f631c5897579537305437d
- Modern:
commit: fb6c2831b5f150e9b82d98d661710695a2d0f8f2
- Pivot:
branch: v2.3.0
commit: d79af7514347eb5272936243d4013118354c85c1
- Refreshed:
commit: 86f33620f25335eb62289aa18d342ff3b980d8b8
30 changes: 0 additions & 30 deletions _sources/scripts/extension-setup.sh

This file was deleted.

47 changes: 47 additions & 0 deletions _sources/scripts/extensions-skins.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!-- It is much easier to do parsing of YAML in PHP than in .sh; the standard way to do YAML parsing
in a shell script is to call yq, but yq requires different executables for different architectures.
Given that the YAML parsing is already in PHP, it seemed easier to do the whole thing in PHP rather
than split the work between two scripts -->
<?php

$MW_HOME = getenv("MW_HOME");
$MW_VERSION = getenv("MW_VERSION");
$type = $argv[1];
$path = $argv[2];

$yamlData = yaml_parse_file($path);

foreach ($yamlData[$type] as $obj) {
$name = key($obj);
$data = $obj[$name];

$repository = $data['repository'] ?? null;
$commit = $data['commit'] ?? null;
$branch = $data['branch'] ?? null;
$patches = $data['patches'] ?? null;

$gitCloneCmd = "git clone ";

if ($repository === null) {
$repository = "https://github.com/wikimedia/mediawiki-$type-$name";
if ($branch === null) {
$branch = $MW_VERSION;
$gitCloneCmd .= "--single-branch -b $branch ";
}
}

$gitCloneCmd .= "$repository $MW_HOME/$type/$name";
$gitCheckoutCmd = "cd $MW_HOME/$type/$name && git checkout -q $commit";

exec($gitCloneCmd);
exec($gitCheckoutCmd);

if ($patches !== null) {
foreach ($patches as $patch) {
$gitApplyCmd = "cd $MW_HOME/$type/$name && git apply /tmp/$patch";
exec($gitApplyCmd);
}
}
}

?>

0 comments on commit ed9cd06

Please sign in to comment.