-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
146 lines (117 loc) · 3.65 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
143
144
145
146
# Automated VDR repository mirror and wiki page generator
# Copyright © 2023 Manuel Reimer <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
VDR_REPO = git://git.tvdr.de/vdr.git
MIRROR_REPO = [email protected]:vdr-projects/vdr.git
WIKI_REPO = [email protected]:vdr-projects/vdr.wiki.git
MD_FILES = vdr.wiki/VDR-Command-Reference.md\
vdr.wiki/VDR-File-Formats-and-Conventions.md\
vdr.wiki/Svdrpsend-Command-Reference.md\
vdr.wiki/VDR-Manual.md\
vdr.wiki/SVDRP-Help.md\
vdr.wiki/The-VDR-Plugin-System.md\
vdr.wiki/Version-History.md
.PHONY: all
all: vdr.git vdr.wiki $(MD_FILES) wiki-push mirror-push
#
# Prepares a bare repo local mirror of the VDR upstream repo
#
vdr.git:
# Cleanup
rm -rf vdr.git
# Clone our GitHub mirror, first.
# Then replace the origin URL with the upstream URL and fetch changes.
# Doing it this way heavily reduces load on the upstream server.
git clone --mirror $(MIRROR_REPO)
git -C vdr.git remote set-url origin $(VDR_REPO)
git -C vdr.git remote update
git -C vdr.git remote prune origin
#
# Checks out a local working copy of VDR. We use our previously created
# bare repo for this.
#
# Require vdr.wiki to exist before checking out the VDR source code.
# This is to ensure that all Wiki files are recreated.
vdr: vdr.git vdr.wiki
rm -rf vdr
git clone vdr.git
vdr/vdr.1: vdr
vdr/vdr.5: vdr
vdr/svdrpsend.1: vdr
vdr/MANUAL: vdr
vdr/svdrp.c: vdr
vdr/PLUGINS.html: vdr
#
# Checks out our Wiki
#
vdr.wiki:
git clone $(WIKI_REPO)
#
# man page convertings
#
define MAN_TO_MD =
mandoc -T html $(1) | python3 ./process_manpage_html.py > $(2)
endef
vdr.wiki/VDR-Command-Reference.md: vdr/vdr.1
$(call MAN_TO_MD, $<, $@)
vdr.wiki/VDR-File-Formats-and-Conventions.md: vdr/vdr.5
$(call MAN_TO_MD, $<, $@)
vdr.wiki/Svdrpsend-Command-Reference.md: vdr/svdrpsend.1
$(call MAN_TO_MD, $<, $@)
#
# MANUAL
#
vdr.wiki/VDR-Manual.md: vdr/MANUAL
python3 convert_vdr_manual.py < $< > $@
#
# SVDRP documentation
#
vdr.wiki/SVDRP-Help.md: vdr/svdrp.c
python3 convert_svdrp_c.py < $< > $@
#
# PLUGINS.html
#
vdr.wiki/The-VDR-Plugin-System.md: vdr/PLUGINS.html vdr.wiki
python3 convert_plugins_html.py < $< > $@
#
# Version History
#
vdr.wiki/Version-History.md: vdr
python3 create_version_history.py vdr > $@
#
# Pushes the wiki pages to GitHub.
# This target also creates a commit if changes where made.
#
.PHONY: wiki-push
wiki-push: $(MD_FILES)
git -C vdr.wiki diff --quiet || git -C vdr.wiki commit -am 'Auto-Update wiki pages'
git -C vdr.wiki push
#
# Pushes the VDR GIT mirror to GitHub.
#
# Require the Wiki files to be created before pushing the mirror.
# This is an added security. If something fails when creating the Wiki files
# then an admin should check the automated job.
.PHONY: mirror-push
mirror-push: $(MD_FILES)
# Make sure our mirror is set as the origin URL. Then push a mirror.
git -C vdr.git remote set-url origin $(MIRROR_REPO)
git -C vdr.git push --mirror
#
# Cleanup
#
.PHONY: clean
clean:
rm -rf vdr.git vdr vdr.wiki __pycache__