diff --git a/cmds.mk b/cmds.mk
index 4022063..d1f14bf 100644
--- a/cmds.mk
+++ b/cmds.mk
@@ -1,96 +1,100 @@
# Running commands
# Copyright (C) 2019, 2020 NicheWork, LLC
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
doCmd:
echo in $@
test -n "${cmd}" || ( \
echo No cmd to run. Please set cmd! && \
exit 10 )
test -z "${REMOTE_HOST}" || ( \
make doRemote cmd="${cmd}" )
test -n "${REMOTE_HOST}" || ( \
${cmd} )
#
doRemote:
test -n "${cmd}" || ( \
echo You need to set cmd! && \
exit 1 )
test -n "${REMOTE_HOST}" || ( \
echo You need to set REMOTE_HOST! && \
exit 1 )
test -n "${stdIn}" || ( \
echo Running "${cmd}" on ${REMOTE_HOST} && \
echo ============================================================== && \
ssh ${REMOTE_HOST} ${cmd} )
test -z "${stdIn}" || ( \
echo Running "${cmd}" on ${REMOTE_HOST} with stdin from ${stdIn} && \
echo ============================================================== && \
pv ${stdIn} | ssh ${REMOTE_HOST} ${cmd} )
ensureDirAndFile:
test -n "${dir}" || ( \
echo dir should be defined. && \
exit 1 )
test -n "${file}" || ( \
echo file should be defined. && \
exit 1 )
symlinkConf: ensureDirAndFile
echo ${indent} $@ for ${file}
test -L ${dir}/${file} || ( \
rm -f ${dir}/${file} && \
ln -s ../conf/${file} ${dir}/${file} )
verifyTimingFile:
test -n "${timingFile}" || ( \
echo && \
echo "***** No file to log timings to. Please set timingFile" && \
exit 1 )
logStart: verifyTimingFile
test -n "${section}" || ( \
echo && \
echo "***** No section to start log" && \
exit 1 )
echo '**** Starting ${section}: ' `date --rfc-3339=seconds` | \
tee -a ${timingFile}
logStop: verifyTimingFile
test -n "${section}" || ( \
echo && \
echo "***** No section to stop log" && \
exit 1 )
echo '**** Finished ${section}: ' `date --rfc-3339=seconds` | \
tee -a ${timingFile}
.PHONY: checkForCommand
checkForCommand:
type ${cmd} > /dev/null 2>&1 || ( echo ${cmd} is not installed; exit 10 )
+.PHONY: git
+git: cmd=git
+direnv: checkForCommand
+
.PHONY: direnv
direnv: cmd=direnv
direnv: checkForCommand
.PHONY: sponge
sponge: cmd=sponge
sponge: checkForCommand
.PHONY: jq
jq: cmd=jq
jq: checkForCommand
diff --git a/composer.mk b/composer.mk
index 6ca647d..e107f7a 100644
--- a/composer.mk
+++ b/composer.mk
@@ -1,71 +1,71 @@
# Rules to get composer installed correctly
# Copyright (C) 2019 NicheWork, LLC
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
mkfilePath := $(abspath $(lastword $(MAKEFILE_LIST)))
composerInstallerSigUrl=https://composer.github.io/installer.sig
composerInstallerUrl=https://getcomposer.org/installer
#
make ?= make -f ${mkfilePath}
#
curl ?= curl -f -L ${verboseCurl}
#
PHP ?= You-Need-To-Set-PHP-EnvVar
php ?= ${PHP}
# Download composer and verify binary
composer: composerCert
${make} composer.phar
mv composer.phar composer
#
.PHONY: fetchFromUrl
fetchFromUrl: /usr/bin/curl
test -f ${file} || \
${curl} ${curlCAPath} -o ${file} ${url}
touch ${file}
expected:
${make} fetchFromUrl url=${composerInstallerSigUrl} file=$@
installer:
${make} fetchFromUrl url=${composerInstallerUrl} file=$@
composer-setup.php: installer expected
echo ${indent}Getting $@ && \
echo `cat expected` ' installer' | sha384sum -c - && \
rm expected && \
mv installer $@
composer.phar: composer-setup.php
- ${php} composer-setup.php ${csNoSSL} ${composerQuiet}
+ ${php} composer-setup.php --1 ${csNoSSL} ${composerQuiet}
rm composer-setup.php
${phpCaCert}: composer.phar
${phpCaCert}: composerCert
.PHONY: composerCert
composerCert: ${phpCaCert} ${proxySSL} composer.phar
test -z "${proxySSL}" || ( \
rm -f ${phpCaCert} && \
mkdir -p `dirname ${phpCaCert}` && \
${php} -d phar.readonly=0 -r "(new Phar('composer.phar')) \
->extractTo( '${phpCaCertDir}', '${phpCaCertFile}');" && \
cat "${proxySSL}" >> "${phpCaCert}" )
diff --git a/lamp.mk b/lamp.mk
index d374799..6876506 100644
--- a/lamp.mk
+++ b/lamp.mk
@@ -1,71 +1,71 @@
# Set up a LAMP server on the remote host
# Copyright (C) 2020 NicheWork, LLC
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
currentDir := $(notdir $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST))))))
include $(if $(findstring ${currentDir}/cmds.mk,$(MAKEFILE_LIST)),, \
${currentDir}/cmds.mk)
# Install the basic LAMP stack
initLamp: updatePkg lampPkgSet
${make} doRemote cmd="sh -c 'sudo systemctl enable apache2'"
${make} doRemote cmd="sh -c 'sudo systemctl enable mariadb'"
${make} doRemote cmd="sh -c 'sudo systemctl start apache2'"
${make} doRemote cmd="sh -c 'sudo systemctl start mariadb'"
curl -s -I ${REMOTE_HOST} | grep -q ^.*200.OK || ( \
echo Did not get "'200 OK'" from ${REMOTE_HOST} && \
exit 1 )
touch $@
#
verifyRemotePath:
test -n "${REMOTE_PATH}" || ( \
echo Please set REMOTE_PATH! && \
exit 1 )
test -n "${REMOTE_USER}" || ( \
echo Please set REMOTE_USER! && \
exit 1 )
${make} doRemote cmd="bash -c 'test -d ${REMOTE_PATH}/html || \
- sudo mkdir -p ${REMOTE_PATH}/{html,logs}'"
+ mkdir -p ${REMOTE_PATH}/{html,logs}'"
${make} doRemote cmd="bash -c 'test -w ${REMOTE_PATH}/html || \
- sudo chown -R ${REMOTE_USER} ${REMOTE_PATH}/html'"
+ chown -R ${REMOTE_USER} ${REMOTE_PATH}/html'"
touch $@
setupSite: initLamp verifyRemotePath coreutils
( \
echo "" && \
echo " ServerName ${REMOTE_HOST}" && \
echo " DocumentRoot ${REMOTE_PATH}/html" && \
echo " ErrorLog ${REMOTE_PATH}/logs/error.log" && \
echo " CustomLog ${REMOTE_PATH}/logs/access.log combined" && \
echo " " && \
echo " Options FollowSymlinks Indexes" && \
echo " Require all granted" && \
echo " AllowOverride All" && \
echo " " && \
echo "" \
) | ${make} doRemote \
cmd="sh -c 'test -f /etc/apache2/sites-available/${REMOTE_HOST}.conf || \
- sudo tee /etc/apache2/sites-available/${REMOTE_HOST}.conf'"
+ tee /etc/apache2/sites-available/${REMOTE_HOST}.conf'"
${make} doRemote \
cmd="sh -c 'test -L /etc/apache2/sites-enabled/${REMOTE_HOST}.conf || \
- sudo a2ensite ${REMOTE_HOST}'"
+ a2ensite ${REMOTE_HOST}'"
${make} doRemote \
cmd="sh -c 'test ! -L /etc/apache2/sites-enabled/${REMOTE_HOST}.conf || \
sudo systemctl reload apache2 || \
( sudo systemctl status apache2 && false )'"
touch $@
diff --git a/mediawiki.mk b/mediawiki.mk
index ce477ae..e7e5094 100644
--- a/mediawiki.mk
+++ b/mediawiki.mk
@@ -1,494 +1,501 @@
# Set up MediaWiki on the remote host
# Copyright (C) 2020 NicheWork, LLC
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
currentDir := $(notdir $(patsubst %/,%,$(dir $(abspath \
$(lastword $(MAKEFILE_LIST))))))
+include $(if $(findstring ${currentDir}/composer.mk,$(MAKEFILE_LIST)),, \
+ ${currentDir}/composer.mk)
include $(if $(findstring ${currentDir}/cmds.mk,$(MAKEFILE_LIST)),, \
${currentDir}/cmds.mk)
include $(if $(findstring ${currentDir}/pkg.mk,$(MAKEFILE_LIST)),, \
${currentDir}/pkg.mk)
include $(if $(findstring ${currentDir}/lamp.mk,$(MAKEFILE_LIST)),, \
${currentDir}/lamp.mk)
phpMWContainer ?= mediawiki
containerRepo ?= localhost
perconaContainer ?= docker.io/library/percona
perconaTag ?= latest
dbPort ?= 3306
mwBranch ?= master
# Root of WMF repos
gerritHead ?= https://gerrit.wikimedia.org/r
# git repo to use for MW
mwCoreRepo ?= ${gerritHead}/mediawiki/core
#
localPath:
test -d ${MW_INSTALL_PATH} || mkdir -p ${MW_INSTALL_PATH}
# Checkout MediaWiki
checkoutMediaWiki: git verifyRemotePath localPath
test -e ${MW_INSTALL_PATH}/.git || \
git clone -b ${mwBranch} ${mwCoreRepo} ${MW_INSTALL_PATH}
+ test -d html || mkdir html
test -L html/w || ln -s ../mediawiki html/w
touch $@
# Where things are installed
REMOTE_HOST ?=
# Run composer update in MW_INSTALL_PATH
-mwComposerUpdate:
+mwComposerUpdate: composer
cd ${MW_INSTALL_PATH} && \
${php} ${topDir}/composer update --no-interaction --no-dev
conf/LocalSettings.php: conf
test -f $@ || cp LocalSettings.php $@
${make} symlinkConf dir=mediawiki file=LocalSettings.php
dumpDB: pv
test -n "${sqlDump}" || ( \
echo You need to set sqlDump. && \
exit 1 )
export running=`${dockerCmd} ps -f ancestor=${perconaContainer} \
--format='{{.ID}}' -f status=running` && \
test -n "$$running" || ( \
echo ${perconaContainer} is not running. && \
exit 1 )
echo Dumping ${MW_DB_NAME} to ${sqlDump}
echo ==============================================================
mysqldump -h${MW_DB_SERVER} -u${MW_DB_USER} -p${MW_DB_PASSWORD} \
${MW_DB_NAME} | pv > ${sqlDump}
# Populate local DB (usually test) with remote DB data remote
syncDB:
export sqlDump=wiki-dump-$(shell date +%Y-%m-%d-%M:%H).sql && \
${make} dumpDB sqlDump=$$sqlDump && \
${make} doRemote stdIn=$$sqlDump \
cmd='sudo mysql ${MW_DB_NAME}'
#
getBasePhpMWContainer: /usr/bin/buildah
export id=$(shell buildah containers --filter 'name=${phpMWContainer}' \
--format "{{.ContainerID}}") && \
test -n "$$id" || \
buildah from --name "mediawiki" \
docker.io/php:${PHP_DOT_VER}-apache && \
echo $@ complete.
buildPhpMWContainer: getBasePhpMWContainer
export id=$(shell buildah images --json | \
jq -r 'map( select( any( \
.names[]; contains( "${containerRepo}/${phpMWContainer}" ) \
) ) | .id )[]') && \
test -n "$$id" || ( \
export container=$(shell buildah containers \
--filter 'name=${phpMWContainer}' \
--format '{{.ContainerID}}') && \
buildah run $$container apt update && \
buildah run $$container apt install -y libzip-dev && \
buildah run $$container pecl install zip-1.19.0 || true && \
buildah run $$container docker-php-ext-enable zip || true && \
buildah commit $$container ${containerRepo}/${phpMWContainer} )
echo $@ complete.
# Start local PHP container for MediaWiki
startContainer: buildPhpMWContainer
${dockerCmd} run -d -p "80:80" -v "${topDir}:/var/www" \
${phpMWContainer}
#
stopAContainer:
test -n "${container}" || ( \
echo "Please set container!" && \
exit 10 )
export running=$(shell ${dockerCmd} ps --format='{{.ID}}' \
-f status=running -f ancestor=${container}) && \
test -n "$$running" || \
echo ${indent}${container} is not running. && \
test -z "$$running" || ( \
echo ${indent}Stopping ${container}... && \
${dockerCmd} rm -f $$running )
# Stop local MW container
stopContainer:
${make} stopAContainer container=${phpMWContainer}
# Stop local Percona container
stopPerconaContainer:
${make} stopAContainer container=${perconaContainer}
# Start local Percona container
startPerconaContainer:
export running=`${dockerCmd} ps -f ancestor=${perconaContainer} \
--format='{{.ID}}' -f status=running` && \
test -z "$$running" || \
echo "${indent}${perconaContainer} is running ($$running)." && \
test -n "$$running" || ( \
echo ${indent}Starting ${perconaContainer}... && \
${dockerCmd} run -d -p "${dbPort}:${dbPort}" \
-e MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} \
${perconaContainer}:${perconaTag} )
#
-installMediaWiki: conf/LocalSettings.php startPerconaContainer \
- mediawiki/vendor/autoload.php
+installMediaWiki: conf/LocalSettings.php mediawiki/vendor/autoload.php
rm -f conf/LocalSettings.php
${php} ${MW_INSTALL_PATH}/maintenance/install.php --pass=${WIKIUSER_PASS} \
--dbname=${MW_DB_NAME} --dbuser=${MW_DB_USER} \
--dbpass=${MW_DB_PASSWORD} --installdbpass=${MYSQL_ROOT_PASSWORD} \
--dbserver=${MW_DB_SERVER} --installdbuser=root \
${MW_SITENAME} ${WIKIUSER_NAME}
${make} symlinkConf dir=mediawiki file=LocalSettings.php
# Install Mediawiki on remote host
deployMediaWiki: checkoutMediaWiki mwComposerUpdate installMediaWiki
.PHONY: install-skin-%
install-skin-%: verifyLSDir
export name=$(subst install-skin-,,$@) && \
test -d mediawiki/skins/$$name -a \
-f ${lsDir}/skins-$$name.php || ( \
echo installing skin $$name && \
${make} skin-$$name ) && ( \
echo $$name is installed )
.PHONY: skin-%
skin-%:
${make} install-skin branch=${mwBranch} name=$(subst skin-,,$@) \
repo=$(or ${repo},${gerritHead}/mediawiki/skins/$(subst skin-,,$@))
.PHONY: remove-extension-%
remove-extension-%:
echo ${indent}Removing old installation of $(subst remove-extension-,,$@)
rm -rf .git/modules/conf/extensions/$(subst remove-extension-,,$@) \
conf/extensions/$(subst remove-extension-,,$@) \
mediawiki/extensions/$(subst remove-extension-,,$@) \
${lsDir}/$(subst remove-,,$@).php
.PHONY: redeploy-extension-%
redeploy-extension-%:
${make} $(subst redeploy-,remove-,$@)
${make} $(subst redeploy-,,$@)
.PHONY: extension-%
extension-%:
${make} install-extension branch=${mwBranch} name=$(subst extension-,,$@) \
repo=$(or ${repo},${gerritHead}/mediawiki/extensions/$(subst extension-,,$@))
.PHONY: install-ext-%
install-ext-%: verifyLSDir
export name=$(subst install-ext-,,$@) && \
test -d mediawiki/extensions/$$name -a \
-f ${lsDir}/extension-$$name.php || ( \
echo ${indent}installing extension $$name && \
${make} extension-$$name ) && ( \
echo ${indent}$$name is installed )
spongeMergeInstallExtension: sponge install-extension ${compLocalJson}
export json="`jq -r -M . < ${compLocalJson}`" && \
export extCompPath="extensions/${name}/composer.json" && \
export exists="`echo $$json | jq \
\"contains({extra:{\\\"merge-plugin\\\":{include: \
[\\\"$$extCompPath\\\"]}}})\"`" && \
export requires="`echo $$json | jq \
\"contains({require:{\\\"${compID}\\\":\\\"\\\"}})\"`" && \
test "$$requires" = "false" || ( \
echo "You asked for to merge the composer.json file for $$name but" \
"it is already in the composer requires." && \
exit 2 ) && \
test "$$exists" = "true" || ( \
echo ${indent}Adding $$name to composer.local.json for merge. && \
echo $$json | \
jq ".extra[\"merge-plugin\"].include += [ \"$$extCompPath\" ]" | \
sponge ${compLocalJson} )
#
.PHONY: install-extension
install-extension: stem=extension
install-extension: loc=conf/extensions/${name}
-install-extension: enableStem
+install-extension: conf/extensions enableStem
#
.PHONY: install-skin
install-skin: stem=skin
install-skin: loc=conf/skins/${name}
-install-skin: enableStem
+install-skin: conf/skins enableStem
# Install and enable an extension using require_once
.PHONY: legacy-extension
legacy-extension: verifyLSDir
test -f ${lsDir}/${stem}-${name}.php || ( \
( echo ' \
${lsDir}/${stem}-${name}.php )
${make} install-extension branch=${mwBranch} \
name=${name} \
repo=${gerritHead}/mediawiki/extensions/${name}
# Install an extension using composer
.PHONY: install-composer-extension
install-composer-extension: ${compLocalJson} jq sponge
echo ${indent}Installing ${stem} "${name}"
${make} install-extension tag=${tag} branch=${branch} name=${name} \
repo=${repo}
echo ${indent}updating composer.local.json for ${stem} "${name}"
jq '.["require"]["${compID}"]="${compVer}"' ${compLocalJson} | \
sponge ${compLocalJson}
rm -f composerUpdateNotNeeded
#
.PHONY: enableStem
enableStem: verifyName updateRepo
echo ${indent}$@ for ${name} ${stem}
${make} LocalSettingsAddWf name=${name} stem=${stem}
.PHONY: verifyStem
verifyStem:
test -n "${stem}" || ( \
echo "Choose a stem!"; \
exit 1 )
.PHONY: verifyName
verifyName: verifyStem
test -n "${name}" || ( \
echo A name must be specified for this ${stem}!; \
exit 1 )
ensureRemoteOrigin: url=$(or ${repo},${gerritHead}/mediawiki/extensions/${name})
-ensureRemoteOrigin: verifyName
+ensureRemoteOrigin: verifyName verifyGit
test -d mediawiki/${stem}s/${name} || ( \
echo ${indent}$@ for ${url} at ${loc} && \
export origin=`cd ${loc} && ${git} remote get-url origin` && \
test -z "$$origin" -a "$$origin" = "${url}" || ( \
echo ${indent}Updating url for the ${name} ${stem} \(${url}\). && \
cd ${loc} && ${git} remote set-url origin ${url} ) )
.PHONY: updateRepo
-updateRepo: verifyName checkoutAndLinkGit ensureRemoteOrigin
+updateRepo: verifyName checkoutAndLinkGit ensureRemoteOrigin verifyGit
# don't do this if it is in MediaWiki repo already
test -d mediawiki/${stem}s/${name} || ( \
test ! -n "${tag}" -o ! -n "${branch}" || ( \
echo -n Do not specify both tag \(${tag}\) and branch; \
echo " "\(${branch}\) for ${name}! && \
exit 1 \
) && \
echo ${indent}Updating repo for ${name} in ${loc} && \
( \
cd ${loc} && ${git} reset --hard && ${git} status -s | \
awk '/^\?\?/ {print $2}' | xargs rm -rf; \
${git} fetch origin \
) )
${make} maybeEnsureBranch branch=${branch} stem=${stem} name=${name} \
loc=${loc}
${make} maybeEnsureTag tag=${tag} stem=${stem} name=${name} \
loc=${loc}
echo ${indent}Handling any submodules
cd ${loc} && ${git} submodule update --init --recursive
test ! -e mediawiki/${stem}s/${name} || \
test ! -L ${loc} || \
ln -s ../../mediawiki/${stem}s/${name} ${loc}
test ! -d ${loc} || \
test ! -L mediawiki/${stem}s/${name} || \
ln -s ../../conf/${stem}s/${name} mediawiki/${stem}s/${name}
${make} maybePatch stem=${stem} name=${name} diffFile=${stem}-${name}-${tag}.diff
${make} maybePatch stem=${stem} name=${name} diffFile=${stem}-${name}-${branch}.diff
${make} maybePatch stem=${stem} name=${name} diffFile=${stem}-${name}.diff
.PHONY: maybePatch
maybePatch:
test ! -f patches/${diffFile} || ( \
echo ${indent}Patching ${name} with ${diffFile} && \
cd ${loc} && \
git am ${topDir}/patches/${diffFile} )
.PHONY: checkoutAndLinkGit
-checkoutAndLinkGit: verifyName
+checkoutAndLinkGit: verifyName verifyGit
echo ${indent}Handling the ${name} ${stem}
test -e mediawiki/${stem}s/${name} || ( \
${make} doClone linkLoc=${linkLoc} loc=conf/${stem}s/${name} \
name=${name} stem=${stem} \
repo=$(or ${repo},${gerritHead}/mediawiki/extensions/${name}) && \
${make} maybeUpdateSubmodules loc=conf/${stem}s/${name} )
doClone:
test ! -n "${DESTRUCTIVE}" -o ! -d ${loc} || \
rm -rf ${loc}
echo ${indent}Cloning ${name} into ${stem}s && \
${git} submodule add -f ${repo} ${loc}
-maybeUpdateSubmodules:
+maybeUpdateSubmodules: verifyGit
# Add any submodules
test -e ${loc}/.gitmodules || ( \
cd ${loc} && ${git} ${gitSsl} submodule update --init )
.PHONY: maybeEnsureBranch
-maybeEnsureBranch:
+maybeEnsureBranch: verifyGit
test -z "${branch}" || ( \
echo ${indent}Ensuring ${name} ${stem} is on ${branch} && \
cd ${loc} && ${git} fetch && \
test $$(${git} branch | awk '/^\*/ {print $$2}') = "${branch}" || \
${git} ${gitSsl} checkout ${branch} )
.PHONY: maybeEnsureTag
-maybeEnsureTag:
+maybeEnsureTag: verifyGit
test -z "${tag}" || ( \
echo ${indent}Ensuring ${name} ${stem} is on the tag ${tag} && \
cd ${loc} && ${git} ${gitSsl} fetch && \
${git} checkout ${tag} )
verifyLSDir:
test -n "${lsDir}" || ( \
echo "Please set lsDir!" ; \
exit 1 )
${make} ${lsDir}
.PHONY: LocalSettingsAddWf
LocalSettingsAddWf: verifyName verifyLSDir conf/LocalSettings.php
echo ${indent}$@ for ${stem} ${name}
test -d "${lsDir}" || \
mkdir -p ${lsDir}
# Lucky us, PHP is case-insensitive for function names, so we
# call wfLoadskin() and wfLoadextension()
test -f ${lsDir}/${stem}-${name}.php || ( \
( echo ' ${lsDir}/${stem}-${name}.php )
.PHONY: installExtensions
installExtensions:
export bail='' && \
for ext in ${selectedExtensions} ; do \
test -n "$$bail" || \
${make} install-ext-$$ext || bail=$$ext ; \
done ; \
test -n "$$bail" && ( \
echo "Failed on $$bail!" && \
exit 2 ) || \
true
.PHONY: verifyMWINSTALL
verifyMWINSTALL:
test -f ${MW_INSTALL_PATH}/maintenance/update.php || ( \
echo Please set MW_INSTALL_PATH! MW_INSTALL_PATH is currently && \
echo ${MW_INSTALL_PATH} and maintenance/update.php is not there! && \
echo && exit 1 )
${SMW_CONF_FILE_DIR}:
test -n "${SMW_CONF_FILE_DIR}" || ( \
echo Please set SMW_CONF_FILE_DIR. ; \
exit 1 )
mkdir -p ${SMW_CONF_FILE_DIR}
${SMW_CONF_FILE_DIR}/.smw.json: ${SMW_CONF_FILE_DIR}
echo '{}' | tee $@ > /dev/null
.PHONY: verifySMWjson
verifySMWjson: ${SMW_CONF_FILE_DIR}/.smw.json
test `id -u ${WEB_USER}` -eq `stat -c %u ${SMW_CONF_FILE_DIR}` -a \
`id -u ${WEB_USER}` -eq `stat -c %u $<` || ( \
echo ${indent}sudo chown ${WEB_USER} ${SMW_CONF_FILE_DIR} $< && \
sudo chown ${WEB_USER} ${SMW_CONF_FILE_DIR} $< )
.PHONY: cleanupUsers
cleanupUsers:
${make} logStart section=$@
test ! -f ${MW_INSTALL_PATH}/maintenance/cleanupUsersWithNoId.php || ( \
sudo -u ${WEB_USER} ${php} \
${MW_INSTALL_PATH}/maintenance/cleanupUsersWithNoId.php -p noid )
${make} logStop section=$@
#
.PHONY: rebuildData
rebuildData: composerUpdate dbVerify${MW_DB_TYPE} verifyMWINSTALL verifySMWjson
${make} logStart section=$@
sudo -u ${WEB_USER} ${php} \
${MW_INSTALL_PATH}/extensions/SemanticMediaWiki/maintenance/rebuildData.php --v
${make} logStop section=$@
#
.PHONY: updatePhp
updatePhp: composerUpdate dbVerify${MW_DB_TYPE} verifyMWINSTALL verifySMWjson
${make} logStart section=$@
sudo -u ${WEB_USER} ${php} ${MW_INSTALL_PATH}/maintenance/update.php \
${verboseUpdatePhp} --quick
${make} logStop section=$@
.PHONY: composerInstall
composerInstall: composer
cd ${MW_INSTALL_PATH} && ${php} ${topDir}/composer install
.PHONY: composerUpdate
composerUpdate: composer verifyMWINSTALL
${make} logStart section=$@
cd ${MW_INSTALL_PATH} && ${php} ${topDir}/composer update --no-interaction
${make} logStop section=$@
#
conf ${lsDir}:
test -d $@ || ( \
echo ${indent}Creating $@... && \
mkdir -p $@ )
.PHONY: conf/composer.local.json
conf/composer.local.json: conf/LocalSettings.php
test ! -L mediawiki/composer.local.json -a \
-f mediawiki/composer.local.json && \
mv mediawiki/composer.local.json $@ || true
${make} symlinkConf dir=mediawiki file=composer.local.json
export json="`cat $@ 2>/dev/null| jq -r -M . 2>/dev/null`" || true && \
test -n "$$json" || \
json='{}' && \
echo $$json | jq '.require += { "vlucas/phpdotenv": "~4" }' | sponge $@
.PHONY: conf/composer.lock
conf/composer.lock: conf/composer.local.json
test ! -L mediawiki/composer.lock -a -f mediawiki/composer.lock && \
mv mediawiki/composer.lock $@ || true
${make} symlinkConf dir=mediawiki file=composer.lock
test -f $@ || ${make} composerInstall
.PHONY: conf/extensions
conf/extensions: conf
test -L mediawiki/extensions -o ! -d mediawiki/extensions || ( \
test ! -d $@ || rm -rf $@ && \
mv mediawiki/extensions $@ )
${make} symlinkConf dir=mediawiki file=extensions
test -d $@ || mkdir -p $@
.PHONY: conf/skins
conf/skins: conf
test -L mediawiki/skins -o ! -d mediawiki/skins || ( \
test ! -d $@ || rm -rf $@ && \
mv mediawiki/skins $@ )
${make} symlinkConf dir=mediawiki file=skins
test -d $@ || mkdir -p $@
.PHONY: conf/vendor
conf/vendor: conf
test -L mediawiki/vendor -o ! -d mediawiki/vendor || ( \
test ! -d $@ || rm -rf $@ && \
mv mediawiki/vendor $@ )
${make} symlinkConf dir=mediawiki file=vendor
test -d $@ || mkdir -p $@
+
+.PHONY: verifyGit
+verifyGit:
+ test -n "${git}" || echo Please install git and set \$$\{git\}
+ ${git} --help > /dev/null || echo Please ensure ${git} is git.
diff --git a/pkg.mk b/pkg.mk
index 3d50948..ac34fbf 100644
--- a/pkg.mk
+++ b/pkg.mk
@@ -1,170 +1,171 @@
# Take care of pkg installation
# Copyright (C) 2020 NicheWork, LLC
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
OS=$(shell lsb_release -i | sed 's,^.*:\t,,')
OSMajorVer=$(shell lsb_release -r | sed 's,^.*:\t,,; s,\..*$,,;')
thisDir := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
+#
default:
false
#
updatePkg:
echo in $@
updatePkgRedHatEnterpriseServer:
${make} doCmd cmd='sudo yum update'
updatePkgDebian:
echo in $@
${make} doCmd cmd='sudo apt update'
# Install LAMP stack on remote host
lampPkgSet: updatePkg apachePhp
test -z "${REMOTE_HOST}" || ( \
make doRemote cmd="make $@" )
test -n "${REMOTE_HOST}" || ( \
${make} $@${OS} )
#
lampPkgSetDebian:
${make} doCmd cmd="sh -c 'test -d /etc/apache2 || sudo apt install -y \
php-mysql php-curl php-gd php-intl php-mbstring php-xml php-zip \
libapache2-mod-php'"
${make} doCmd cmd="sh -c 'test -d /var/lib/mysql || sudo apt install -y \
mariadb-server'"
touch $@
#
lampPkgSetRedHatEnterpriseServer:
echo No packages for RHEL.
exit 10
apachePhp: updatePkg
test -z "${REMOTE_HOST}" || ( \
make doRemote cmd="make $@" )
test -n "${REMOTE_HOST}" || ( \
${make} $@${OS} )
apachePhpRedHatEnterpriseServer:
${make} doCmd cmd="sudo yum install -y httpd php${PHP_VER}-fpm mod_ssl"
${make} doCmd cmd="sudo systemctl enable httpd"
${make} doCmd cmd="sudo systemctl enable php-fpm"
${make} setupPhpFpm
${make} doCmd cmd="sudo systemctl restart php-fpm"
${make} doCmd cmd="sudo systemctl restart httpd"
setupPhpFpm:
${make} cpFile file=php-fpm.conf dest=webConfD
${eval destLookup=$$(shell test -z "$$(1)" || jq -r .$${OS}.$$(1) $${thisDir}dest.json)}
cpFile:
test -n "${file}" || ( \
echo No file to copy. Please set file! && \
exit 10 )
test -n "${dest}" || ( \
echo No dest key to copy to. Please set dest! && \
exit 10 )
test "$(call destLookup,${dest})" != "null" || ( \
echo Dest key "(${dest})" does not exist in dest.json! && \
exit 10 )
test -n "${REMOTE_HOST}" || \
sudo cp ${thisDir}${file} "$(call destLookup,${dest})"
test -z "${REMOTE_HOST}" || \
${make} doCmd cmd="make cpFile file=${file} dest=${dest}"
doRemoteCp:
test -n "${REMOTE_HOST}" || ( \
echo No remote host available! && \
exit 1 )
php: updatePkg
test -z "${REMOTE_HOST}" || ( \
make doRemote cmd="make $@" )
test -n "${REMOTE_HOST}" || ( \
${make} $@${OS} )
phpDebian:
${make} doCmd cmd="sudo apt install -y php-curl php-mbstring php-xml \
php-zip php-intl php-gd libapache2-mod-php"
phpRedHatEnterpriseServer:
${make} doCmd cmd="sudo yum install -y \
php${PHP_VER}-mbstring php${PHP_VER}-xml php${PHP_VER}-pecl-zip \
php${PHP_VER}-intl php${PHP_VER}-gd"
coreutils: updatePkg
${make} doCmd cmd="sh -c 'test -x /usr/bin/tee || sudo apt install -y \
coreutils'"
touch $@
etckeeper: updatePkg
${make} doCmd cmd="sh -c 'test -x /usr/bin/etckeeper || \
sudo apt install -y etckeeper'"
${make} doCmd cmd="sudo /usr/bin/etckeeper init"
touch $@
pkgUpgradable:
${make} doCmd cmd="sudo apt list --upgradable"
pkgUpgrade:
${make} doCmd cmd="sudo apt upgrade -y"
/usr/bin/dig /usr/bin/nsupddate:
apt install -y dnsutils
pv: /usr/bin/pv
/usr/bin/pv:
apt install -y pv
jq: /usr/bin/jq
/usr/bin/jq:
yum install -y jq
sponge: moreutils
moreutils: /usr/bin/sponge
/usr/bin/sponge:
yum install -y moreutils
.PHONY: pandoc
pandoc:
test -f /usr/bin/pandoc || \
sudo yum install -y pandoc
.PHONY: xsltproc
xsltproc:
test -f /usr/bin/xsltproc || \
sudo yum install -y libxslt
.PHONY: fop
fop:
test -f /usr/bin/fop || \
sudo yum install -y fop
.PHONY: php-zip
php-zip:
export zipInst="`${PHP} -i | awk '/^Registered PHP Streams/'`" && \
zipInst="`echo $$zipInst | sed 's,.*=> ,,; s/, /\n/g;' | grep ^zip$$`" && \
test -n "'$$zipInst'" || \
sudo yum install -y php${PHP_VER}-php-pecl-zip
.PHONY: php-gd
php-gd:
export gdInst="`${PHP} -i | awk '/^GD Support/' | sed 's,.*=> ,,'`" && \
test "enabled" = "$$gdInst" || \
sudo yum install -y php${PHP_VER}-php-gd