-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
143 lines (122 loc) · 5.34 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# Makefile help copied from https://github.com/ianstormtaylor/makefile-help
# files to link to in the top dir
topdirLinkTargets := composer.lock vendor composer.local.json LocalSettings.php package-lock.json images
# Directories to link to that are in subdirectories
subdirLinkTargets := $(shell echo extensions/* skins/*)
# Secret flag file
# See https://www.cmcrossroads.com/article/gnu-make-meets-file-names-spaces-them
reallyDeploy := .run\ \\\"make\ reallyDeploy\\\"\ to\ continue
rdTarget := .run\ \"make\ reallyDeploy\"\ to\ continue
.PHONY: help
# Show this help prompt.
help:
@ echo
@ echo ' Usage:'
@ echo ''
@ echo ' make <target> [flags...]'
@ echo ''
@ echo ' Targets:'
@ echo ''
@ awk '/^#/{ comment = substr($$0,3) } comment && /^[a-zA-Z][a-zA-Z0-9_-]+ ?: *[^=]*$$/{ print " ", $$1, comment }' $(MAKEFILE_LIST) | column -t -s ':' | sort
@ echo ''
@ echo ' Flags:'
@ echo ''
@ awk '/^#/{ comment = substr($$0,3) } comment && /^[a-zA-Z][a-zA-Z0-9_-]+ ?\?=/{ print " ", $$1, $$2, comment }' $(MAKEFILE_LIST) | column -t -s '?=' | sort
@ echo ''
conf/apache2/envvars.private:
setup/create-private-envvars.sh
# Composer automation adapted from
# https://getcomposer.org/doc/faqs/how-to-install-composer-programmatically.md
# Download composer
composer: composer-setup.php
# Downloading composer
@EXPECTED=$(shell wget -q -O - https://composer.github.io/installer.sig); \
ACTUAL=$(shell php -r "echo hash_file('sha384', 'composer-setup.php');"); \
if [ "$$EXPECTED" != "$$ACTUAL" ]; then \
>&2 echo 'ERROR: Invalid installer signature'; \
rm composer-setup.php; \
exit 1; \
fi
@php composer-setup.php --quiet
@mv composer.phar composer
composer-setup.php:
# Downloading composer-setup.php
@php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
# Remove links from mediawiki checkout
delinkifyMediaWiki: $(rdTarget)
# Removing MediaWiki symlinks
@test -e "mediawiki/.htaccess" && rm -f "mediawiki/.htaccess" || true
@test -e "mediawiki/images" && rm -rf "mediawiki/images" || true
@test -e "mediawiki/vendor" && rm -rf "mediawiki/vendor" || true
@for i in ${topdirLinkTargets} ${subdirLinkTargets}; do \
test -L "mediawiki/$$i" && rm "mediawiki/$$i" || true; \
done;
@touch $@
@rm -f linkifyMediaWiki
# Add links to mediawiki checkout
linkifyMediaWiki: $(rdTarget)
# Adding MediaWiki symlinks
@test -L "mediawiki/.htaccess" || ln -s ../htaccess "mediawiki/.htaccess"
@for i in ${topdirLinkTargets}; do \
test -L "mediawiki/$$i" || ln -s ../$$i "mediawiki/$$i"; \
done;
@for i in ${subdirLinkTargets}; do \
test -L "mediawiki/$$i" || ln -s ../../$$i "mediawiki/$$i"; \
done;
@touch $@
@rm -f delinkifyMediaWiki
# Linkify configuration files to /etc
setupConfLinks:
# Linkifying the configuration files
@test -d conf || ( >&2 echo 'ERROR: no conf directory'; exit 1 )
@export PWD=`pwd`; \
cd conf && \
find . -type f -a \! -name '*~' | \
xargs -i{} sudo sh -c "cd /etc; test ! -e {} && ln -s $$PWD/{} {}" || true
@cd conf && \
find . -type f -a \! -name '*~' | \
xargs -i{} sudo sh -c "cd /etc; test ! -L {} && ( \
>&2 echo \"/etc/{} is not a symlink. (touch setupLinks to bypass this)\"; false )" || true
@touch $@
.PHONY: updateCheckout
# Pull in all updates from git
updateCheckout: $(rdTarget)
# Updating checkout and submodules from git
@git pull -q
@git submodule foreach -q git reset -q --hard
@git submodule update -q --init --recursive
.PHONY: reallyDeploy
# Set the "really do this" deploy flag file
reallyDeploy:
# Make sure you are ready to deploy. If not remove this file:
touch $(reallyDeploy)
installPackages:
@setup/install-packages.sh
@touch $@
confGPMLConverter:
bash extensions/GPMLConverter/install wikipathways
@touch $@
setupApache:
# configuring apache
a2query -m mod_headers || sudo a2enmod headers
a2query -s wikipathways.conf || sudo a2ensite wikipathways.conf
sudo systemctl restart apache2
touch $@
.PHONY: setup
# Set up the site <-------------------------- Main entry point
setup: conf/apache2/envvars.private composer setupConfLinks delinkifyMediaWiki updateCheckout linkifyMediaWiki installPackages confGPMLConverter setupApache
# Done.
.PHONY: distclean
# Revert to a naked checkout
distclean: delConfLinks delinkifyMediaWiki
# Removing ignored files setup creates
@rm -f composer setupConfLinks composer-setup.php ${reallyDeploy} installPackages confGPMLConveter setupApache
@test -f conf/apache2/envvars.private && echo Not touching envvars.private || true
.PHONY: delConfLinks
# Remove links to configurations
delConfLinks:
# Removing links to configuraion
@export PWD=`pwd`; \
cd conf && \
find . -type f -a \! -name '*~' | \
xargs -i{} sudo sh -c "cd /etc; test -L {} && rm -f {}" || true