Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PHP script for extensions and skins setup #390

Merged
merged 7 commits into from
Jun 13, 2024
36 changes: 4 additions & 32 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
APACHE_LOG_DIR=/var/log/apache2

# System setup
RUN set x; \

Check failure on line 17 in Dockerfile

View workflow job for this annotation

GitHub Actions / test

DL3008 warning: Pin versions in apt get install. Instead of `apt-get install <package>` use `apt-get install <package>=<version>`

Check failure on line 17 in Dockerfile

View workflow job for this annotation

GitHub Actions / test

DL3015 info: Avoid additional packages by specifying `--no-install-recommends`

Check failure on line 17 in Dockerfile

View workflow job for this annotation

GitHub Actions / test

DL3047 info: Avoid use of wget without progress bar. Use `wget --progress=dot:giga <url>`.Or consider using `-q` or `-nv` (shorthands for `--quiet` or `--no-verbose`).
apt-get clean \
&& apt-get update \
&& apt-get install -y aptitude \
Expand Down Expand Up @@ -88,7 +88,7 @@
&& mkdir -p $MW_VOLUME

# Composer
RUN set -x; \

Check failure on line 91 in Dockerfile

View workflow job for this annotation

GitHub Actions / test

DL4001 warning: Either use Wget or Curl but not both
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
&& composer self-update 2.1.3

Expand All @@ -103,30 +103,10 @@
# 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 @@
# 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);
}
}
}

?>
Loading