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 rfcYear
=$(git log -1 --pretty=%cd --date=format:%Y "$rfcDir/advocacy.md")
27 rfcDate
=$(git log -1 --pretty=%cd --date=short "$rfcDir/advocacy.md")
31 local advocacyLatestCommit criticismsLatestCommit
32 advocacyLatestCommit
=$(git rev-list --max-count=1 HEAD -- "$rfcDir/advocacy.html")
33 criticismsLatestCommit
=$(git rev-list --max-count=1 HEAD -- "$rfcDir/criticisms.html")
34 rfcTagAdvocacyOld
="$(git describe --tags "$advocacyLatestCommit")" || true
35 rfcTagCriticismsOld
="$(git describe --tags "$criticismsLatestCommit")" || true
36 if test "${rfcTagAdvocacyOld#"${rfcBranch}v"}" != "$rfcTagAdvocacyOld"
37 then IFS
=psvc
read -r _ _num rfcRevAdvocacy _
<<<"$rfcTagAdvocacyOld"
38 else rfcRevAdvocacy
=0; rfcTagAdvocacyOld
=init
40 if test "${rfcTagCriticismsOld#"${rfcBranch}v"}" != "$rfcTagCriticismsOld"
41 then IFS
=psvc
read -r _ _num _rfcRevAdvocacy rfcRevCriticisms _
<<<"$rfcTagCriticismsOld"
42 else rfcRevCriticisms
=0; rfcTagCriticismsOld
=init
44 rfcRevision
=v
"$rfcRevAdvocacy"c
"$rfcRevCriticisms"
45 rfcTag
="$rfcBranch$rfcRevision"
49 if test ! "${rfcNoAdvocacy:+set}"; then
50 cat - "$rfcDir"/advocacy.md
<<EOF
52 Ce document est publié sous licence
53 [\${SPDX-License-Identifier}](https://spdx.org/licenses/\${SPDX-License-Identifier}.html).
57 > \${rfcOrga} <[RFC\${rfcTag}](mailto:\${rfcList}+\${rfcTag}@\${rfcDomain})>
58 > — « *\${title}* » — \${rfcDate} — série *Requests for Criticisms*
59 > — \${RFC-Category} « \` \${rfcBranch}\` »,
60 > plaidoirie « \` \${rfcRevisionAdvocacy}\` »,
61 > critiques « \` \${rfcRevisionCriticisms}\` »
62 > — \${for(RFC-Compasses)}boussole \${it}\${sep} & \${endfor}
63 > — <<\${rfcGitweb}/blob_plain/\${rfcTag}:/rfcs/\${rfcBranch}/index.html>>.
65 Vous _devriez_ consulter en priorité sa dernière version
66 qui est disponible en ligne à l'adresse :
67 <<\${rfcGitweb}/blob_plain/\${rfcBranch}:/rfcs/\${rfcBranch}/index.html>>
69 - Statut de cette révision : « \${RFC-Phase} »
75 if test ! "${rfcNoHistory:+set}"; then
76 cat "$rfcDir"/history.md
79 if test ! "${rfcNoCriticisms:+set}"; then
80 cat "$rfcDir"/criticisms.md
93 printf ' --metadata %s' \
94 rfcBranch
="$rfcBranch" \
97 rfcDomain
="$rfcDomain" \
98 rfcGitweb
="$rfcGitweb" \
102 rfcRevision
="$rfcRevision" \
103 rfcRevisionAdvocacy
="v$rfcRevAdvocacy" \
104 rfcRevisionCriticisms
="c$rfcRevCriticisms" \
107 # --metadata-file provides defaults,
108 # its metadata do not override the document's metadata.
109 printf ' --metadata-file %s' "$metaFile"
110 cat >"$metaFile" <<EOF
112 title: "[RFC${rfcBranch}]"
118 local sourceFile metaFile
119 sourceFile
=$(mktemp --suffix ".md")
120 metaFile
=$(mktemp --suffix ".md")
121 removeAtExit
+=("$sourceFile" "$metaFile")
122 rfcSource
>"$sourceFile"
126 --template "$sourceFile" \
132 pandoc
--from markdown
+emoji
--to plain \
134 --csl "$rfcRoot"/styles
/rfc.csl \
135 $(printf " --bibliography %s" "$rfcRoot"/refs/*.json) \
136 --lua-filter "$rfcRoot"/styles
/rfc.lua \
137 --variable lang
=fr
-FR \
143 pandoc
--from markdown
+emoji
--to markdown
+emoji \
144 --table-of-contents \
148 --csl "$rfcRoot"/styles
/rfc.csl \
149 $(printf " --bibliography %s" "$rfcRoot"/refs/*.json) \
150 --lua-filter "$rfcRoot"/styles
/rfc.lua \
151 --variable lang
=fr
-FR \
157 pandoc
--from markdown
+emoji
--to html5 \
160 --include-in-header "$rfcRoot"/styles
/rfc.header.html \
161 --table-of-contents \
165 --csl "$rfcRoot"/styles
/rfc.csl \
166 $(printf " --bibliography %s" "$rfcRoot"/refs/*.json) \
167 --lua-filter "$rfcRoot"/styles
/rfc.lua \
168 --variable lang
=fr
-FR \
174 pandoc
--from markdown
+emoji
--to pdf \
175 --pdf-engine lualatex \
176 --include-in-header "$rfcRoot"/styles
/rfc.header.tex \
179 --table-of-contents \
183 --csl "$rfcRoot"/styles
/rfc.csl \
184 $(printf " --bibliography %s" "$rfcRoot"/refs/*.json) \
185 --lua-filter "$rfcRoot"/styles
/rfc.lua \
186 --variable colorlinks
=true \
187 --variable lang
=fr
-FR \
188 --variable links
-as-notes=true \
194 git
diff --exit-code -- "$rfcDir" :'!*.html'
196 : "Check if \$rfcRevAdvocacy must be increased."
197 rfcNoCriticisms
="set" \
199 rfcHTML
-o "$rfcDir"/advocacy.html
200 git add
"$rfcDir"/advocacy.html
201 rfcRevAdvocacyIncrement
=0
202 if ! git
diff --cached --quiet "$rfcDir"/advocacy.html
; then
203 rfcRevAdvocacyIncrement
=1
204 # Note that $rfcRevCriticisms is not reset:
205 # criticisms have their own independant revisions
206 # because, in practice, criticisms to an old $rfcRevAdvocacy
207 # can be received and added after a new $rfcRevAdvocacy has been tagged.
210 : "Check if \$rfcRevCriticisms must be increased."
212 rfcNoAdvocacy
="set" \
214 rfcHTML
-o "$rfcDir"/criticisms.html
215 git add
"$rfcDir"/criticisms.html
216 rfcRevCriticismsIncrement
=0
217 if ! git
diff --cached --quiet "$rfcDir"/criticisms.html
; then
218 rfcRevCriticismsIncrement
=1
221 if test "$rfcRevAdvocacyIncrement" -gt 0 ||
222 test "$rfcRevCriticismsIncrement" -gt 0
224 rfcRevAdvocacy
=$((rfcRevAdvocacy + rfcRevAdvocacyIncrement))
225 rfcRevCriticisms
=$((rfcRevCriticisms + rfcRevCriticismsIncrement))
226 rfcRevision
=v
"$rfcRevAdvocacy"c
"$rfcRevCriticisms"
227 rfcTag
="$rfcBranch$rfcRevision"
228 rfcNoCriticisms
="set" \
230 rfcHTML
-o "$rfcDir"/advocacy.html
232 rfcNoAdvocacy
="set" \
234 rfcHTML
-o "$rfcDir"/criticisms.html
235 rfcHTML
-o "$rfcDir"/index.html
236 #rfcPDF -o "$rfcDir/${rfcRepo}-${rfcBranch}".pdf
237 git add
"$rfcDir"/{advocacy
,criticisms
,index
}.html
238 #git add "$rfcDir/${rfcRepo}-${rfcBranch}".pdf
239 git
diff --cached --quiet ||
240 git commit
-m "$rfcBranch: v$rfcRevAdvocacy c$rfcRevCriticisms"
241 git tag
--force --sign --message "${rfcOrga} RFC${rfcTag}" "$rfcTag"