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>>
73 if test ! "${rfcNoCriticisms:+set}"; then
74 cat "$rfcDir"/criticisms.md
87 printf ' --metadata %s' \
88 rfcBranch
="$rfcBranch" \
91 rfcDomain
="$rfcDomain" \
92 rfcGitweb
="$rfcGitweb" \
96 rfcRevision
="$rfcRevision" \
97 rfcRevisionAdvocacy
="v$rfcRevAdvocacy" \
98 rfcRevisionCriticisms
="c$rfcRevCriticisms" \
101 # --metadata-file provides defaults,
102 # its metadata do not override the document's metadata.
103 printf ' --metadata-file %s' "$metaFile"
104 cat >"$metaFile" <<EOF
106 title: "[RFC${rfcBranch}]"
112 local sourceFile metaFile
113 sourceFile
=$(mktemp --suffix ".md")
114 metaFile
=$(mktemp --suffix ".md")
115 removeAtExit
+=("$sourceFile" "$metaFile")
116 rfcSource
>"$sourceFile"
120 --template "$sourceFile" \
126 pandoc
--from markdown
+emoji
--to plain \
128 --csl "$rfcRoot"/styles
/rfc.csl \
129 $(printf " --bibliography %s" "$rfcRoot"/refs/*.json) \
130 --lua-filter "$rfcRoot"/styles
/rfc.lua \
131 --variable lang
=fr
-FR \
137 pandoc
--from markdown
+emoji
--to markdown
+emoji \
138 --table-of-contents \
142 --csl "$rfcRoot"/styles
/rfc.csl \
143 $(printf " --bibliography %s" "$rfcRoot"/refs/*.json) \
144 --lua-filter "$rfcRoot"/styles
/rfc.lua \
145 --variable lang
=fr
-FR \
151 pandoc
--from markdown
+emoji
--to html5 \
154 --include-in-header "$rfcRoot"/styles
/rfc.header.html \
155 --table-of-contents \
159 --csl "$rfcRoot"/styles
/rfc.csl \
160 $(printf " --bibliography %s" "$rfcRoot"/refs/*.json) \
161 --lua-filter "$rfcRoot"/styles
/rfc.lua \
162 --variable lang
=fr
-FR \
168 pandoc
--from markdown
+emoji
--to pdf \
169 --pdf-engine lualatex \
170 --include-in-header "$rfcRoot"/styles
/rfc.header.tex \
173 --table-of-contents \
177 --csl "$rfcRoot"/styles
/rfc.csl \
178 $(printf " --bibliography %s" "$rfcRoot"/refs/*.json) \
179 --lua-filter "$rfcRoot"/styles
/rfc.lua \
180 --variable colorlinks
=true \
181 --variable lang
=fr
-FR \
182 --variable links
-as-notes=true \
188 git
diff --exit-code -- "$rfcDir" :'!*.html'
190 : "Check if \$rfcRevAdvocacy must be increased."
191 rfcNoCriticisms
="set" \
192 rfcHTML
-o "$rfcDir"/advocacy.html
193 git add
"$rfcDir"/advocacy.html
194 rfcRevAdvocacyIncrement
=0
195 if ! git
diff --cached --quiet "$rfcDir"/advocacy.html
; then
196 rfcRevAdvocacyIncrement
=1
197 # Note that $rfcRevCriticisms is not reset:
198 # criticisms have their own independant revisions
199 # because, in practice, criticisms to an old $rfcRevAdvocacy
200 # can be received and added after a new $rfcRevAdvocacy has been tagged.
203 : "Check if \$rfcRevCriticisms must be increased."
205 rfcNoAdvocacy
="set" \
206 rfcHTML
-o "$rfcDir"/criticisms.html
207 git add
"$rfcDir"/criticisms.html
208 rfcRevCriticismsIncrement
=0
209 if ! git
diff --cached --quiet "$rfcDir"/criticisms.html
; then
210 rfcRevCriticismsIncrement
=1
213 if test "$rfcRevAdvocacyIncrement" -gt 0 ||
214 test "$rfcRevCriticismsIncrement" -gt 0
216 rfcRevAdvocacy
=$((rfcRevAdvocacy + rfcRevAdvocacyIncrement))
217 rfcRevCriticisms
=$((rfcRevCriticisms + rfcRevCriticismsIncrement))
218 rfcRevision
=v
"$rfcRevAdvocacy"c
"$rfcRevCriticisms"
219 rfcTag
="$rfcBranch$rfcRevision"
220 rfcNoCriticisms
="set" \
221 rfcHTML
-o "$rfcDir"/advocacy.html
223 rfcNoAdvocacy
="set" \
224 rfcHTML
-o "$rfcDir"/criticisms.html
225 rfcHTML
-o "$rfcDir"/index.html
226 #rfcPDF -o "$rfcDir/${rfcRepo}-${rfcBranch}".pdf
227 git add
"$rfcDir"/{advocacy
,criticisms
,index
}.html
228 #git add "$rfcDir/${rfcRepo}-${rfcBranch}".pdf
229 git
diff --cached --quiet ||
230 git commit
-m "$rfcBranch: v$rfcRevAdvocacy c$rfcRevCriticisms"
231 git tag
--force --sign --message "${rfcOrga} RFC${rfcTag}" "$rfcTag"