2 # SPDX-FileCopyrightText: 2024 Julien Moutinho (adh14) <julm+rezine@autogeree.net>
3 # SPDX-License-Identifier: AGPL-3.0-or-later
4 # shellcheck disable=SC2034
5 # shellcheck disable=SC2046
6 # shellcheck disable=SC2086
7 # shellcheck disable=SC2119
8 # shellcheck disable=SC2154
13 # FIXME: host it on rezine.org?
14 rfcGitweb
="https://git.sourcephile.fr/julm/$rfcRepo.git"
18 rm -rf "${removeAtExit[@]}"
23 rfcRoot
=$(realpath --relative-to . "${0%/*}"/..)
24 rfcDir
=$(realpath --relative-to "$rfcRoot" "$rfcDir")
25 rfcBranch
=$(realpath --relative-to "$rfcRoot"/rfcs "$rfcDir")
26 rfcYearAdvocacy
=$(git log -1 --pretty=%cd --date=format:%Y "$rfcDir/advocacy.md")
27 rfcDateAdvocacy
=$(git log -1 --pretty=%cd --date=short "$rfcDir/advocacy.md")
28 rfcDateCriticisms
=$(git log -1 --pretty=%cd --date=short "$rfcDir/criticisms.yaml")
32 local advocacyLatestCommit criticismsLatestCommit
33 advocacyLatestCommit
=$(git rev-list --max-count=1 HEAD -- "$rfcDir/advocacy.html")
34 criticismsLatestCommit
=$(git rev-list --max-count=1 HEAD -- "$rfcDir/criticisms.html")
35 rfcTagAdvocacyOld
="$(git describe --tags "$advocacyLatestCommit")" || true
36 rfcTagCriticismsOld
="$(git describe --tags "$criticismsLatestCommit")" || true
37 if test "${rfcTagAdvocacyOld#"${rfcBranch}v"}" != "$rfcTagAdvocacyOld"
38 then IFS
=psvc
read -r _ _num rfcRevAdvocacy _
<<<"$rfcTagAdvocacyOld"
39 else rfcRevAdvocacy
=0; rfcTagAdvocacyOld
=init
41 if test "${rfcTagCriticismsOld#"${rfcBranch}v"}" != "$rfcTagCriticismsOld"
42 then IFS
=psvc
- read -r _ _num _rfcRevAdvocacy rfcRevCriticisms _ rfcRevGit
<<<"$rfcTagCriticismsOld"
43 else rfcRevCriticisms
=0; rfcTagCriticismsOld
=init
45 rfcBranchRevision
="${rfcBranch}v${rfcRevAdvocacy}"
46 rfcTag
="${rfcBranchRevision}c$rfcRevCriticisms${rfcRevGit:+-$rfcRevGit}"
50 mkdir -p "$rfcRoot/rfcs/$rfcBranch/citation"
51 pandoc
>"$rfcRoot/rfcs/$rfcBranch/citation/v${rfcRevAdvocacy}.csl.json" \
54 --template "$rfcRoot/styles/rfc.csl.json" \
62 --template "$rfcRoot"/styles
/rfc.metadata.yaml \
64 if test ! "${rfcNoAdvocacy:+set}"; then
66 cat "$rfcRoot/styles/rfc.information.md"
68 cat "$rfcDir"/advocacy.md
71 if test ! "${rfcNoThanks:+set}"; then
75 --template "$rfcRoot"/styles
/rfc.thanks.md \
79 if test ! "${rfcNoHistory:+set}"; then
83 --template "$rfcRoot"/styles
/rfc.
history.md \
84 "$rfcDir"/history.yaml
87 if test ! "${rfcNoCriticisms:+set}"; then
91 --template "$rfcRoot"/styles
/rfc.criticisms.md \
92 "$rfcDir"/criticisms.yaml
95 cat "$rfcRoot"/styles
/rfc.references.md
99 printf ' --metadata %s' \
100 rfcBranch
="$rfcBranch" \
101 rfcDateAdvocacy
="$rfcDateAdvocacy" \
102 rfcDateCriticisms
="$rfcDateCriticisms" \
104 rfcDomain
="$rfcDomain" \
105 rfcGitweb
="$rfcGitweb" \
109 rfcBranchRevision
="$rfcBranchRevision" \
110 rfcRevAdvocacy
="$rfcRevAdvocacy" \
111 rfcRevisionAdvocacy
="v$rfcRevAdvocacy" \
112 rfcRevisionCriticisms
="c$rfcRevCriticisms" \
114 rfcYearAdvocacy
="$rfcYearAdvocacy"
118 local sourceFile metaFile
119 sourceFile
=$(mktemp --suffix ".md")
120 metaFile
=$(mktemp --suffix ".md")
121 removeAtExit
+=("$sourceFile" "$metaFile")
122 rfcSource
>"$sourceFile"
123 if test ! "${rfcNoAdvocacy:+set}" && test ! "${rfcNoCriticisms:+set}"; then
129 --template "$sourceFile" \
135 pandoc
--from markdown
+emoji
--to plain \
137 --csl "$rfcRoot"/styles
/rfc.csl \
138 $
(printf " --bibliography %s" "$rfcRoot"/refs
/*.json \
139 "$rfcRoot"/rfcs
/*/citation
/*.csl.json
) \
140 --lua-filter "$rfcRoot"/styles
/rfc.lua \
141 --variable lang
=fr
-FR \
147 pandoc
--from markdown
+emoji
--to markdown
+emoji \
148 --table-of-contents \
152 --csl "$rfcRoot"/styles
/rfc.csl \
153 $
(printf " --bibliography %s" "$rfcRoot"/refs
/*.json \
154 "$rfcRoot"/rfcs
/*/citation
/*.csl.json
) \
155 --lua-filter "$rfcRoot"/styles
/rfc.lua \
156 --variable lang
=fr
-FR \
162 pandoc
--from markdown
+emoji
--to html5 \
165 --include-in-header "$rfcRoot"/styles
/rfc.header.html \
166 --table-of-contents \
170 --csl "$rfcRoot"/styles
/rfc.csl \
171 $
(printf " --bibliography %s" "$rfcRoot"/refs
/*.json \
172 "$rfcRoot"/rfcs
/*/citation
/*.csl.json
) \
173 --lua-filter "$rfcRoot"/styles
/rfc.lua \
174 --variable lang
=fr
-FR \
180 pandoc
--from markdown
+emoji
--to pdf \
181 --pdf-engine lualatex \
182 --include-in-header "$rfcRoot"/styles
/rfc.header.tex \
185 --table-of-contents \
189 --csl "$rfcRoot"/styles
/rfc.csl \
190 $(printf " --bibliography %s" "$rfcRoot"/refs/*.json) \
191 --lua-filter "$rfcRoot"/styles
/rfc.lua \
192 --variable colorlinks
=true \
193 --variable lang
=fr
-FR \
194 --variable links
-as-notes=true \
200 git
diff --exit-code -- "$rfcDir" :'!*.html' ||
201 echo >&2 "ERROR: you have changes to commit"
203 : "Check if \$rfcRevAdvocacy must be increased."
204 rfcNoCriticisms
="set" \
207 rfcHTML
-o "$rfcDir"/advocacy.html
208 git add
"$rfcDir"/advocacy.html
209 rfcRevAdvocacyIncrement
=0
210 if ! git
diff --cached --quiet "$rfcDir"/advocacy.html
; then
211 rfcRevAdvocacyIncrement
=1
212 # Note that $rfcRevCriticisms is not reset:
213 # criticisms have their own independant revisions
214 # because, in practice, criticisms to an old $rfcRevAdvocacy
215 # can be received and added after a new $rfcRevAdvocacy has been tagged.
218 : "Check if \$rfcRevCriticisms must be increased."
220 rfcNoAdvocacy
="set" \
223 rfcHTML
-o "$rfcDir"/criticisms.html
224 git add
"$rfcDir"/criticisms.html
225 rfcRevCriticismsIncrement
=0
226 if ! git
diff --cached --quiet "$rfcDir"/criticisms.html
; then
227 rfcRevCriticismsIncrement
=1
230 if test "$rfcRevAdvocacyIncrement" -gt 0 ||
231 test "$rfcRevCriticismsIncrement" -gt 0
233 rfcRevAdvocacy
=$((rfcRevAdvocacy + rfcRevAdvocacyIncrement))
234 rfcRevCriticisms
=$((rfcRevCriticisms + rfcRevCriticismsIncrement))
235 rfcBranchRevision
="${rfcBranch}v$rfcRevAdvocacy"
236 rfcTag
="${rfcBranchRevision}c$rfcRevCriticisms"
237 rfcNoCriticisms
="set" \
240 rfcHTML
-o "$rfcDir"/advocacy.html
242 rfcNoAdvocacy
="set" \
245 rfcHTML
-o "$rfcDir"/criticisms.html
246 rfcHTML
-o "$rfcDir"/index.html
247 #rfcPDF -o "$rfcDir/${rfcRepo}-${rfcBranch}".pdf
248 git add
"$rfcDir"/{advocacy
,criticisms
,index
}.html
249 git add
"$rfcDir/citation/v${rfcRevAdvocacy}.csl.json"
250 #git add "$rfcDir/${rfcRepo}-${rfcBranch}".pdf
251 git
diff --cached --quiet ||
252 git commit
-m "$rfcBranch: v$rfcRevAdvocacy c$rfcRevCriticisms"
253 git tag
--force --sign --message "${rfcOrga} RFC${rfcTag}" "$rfcTag"