Debian Codegraph @

Makefile

raw symbols SCIP
1 #######################################################################
2 # Build debian-reference (v2)
3 # vim: set ts=8:
4 #######################################################################
5 #======================================================================
6 # ===== Adjustable parameters =========================================
7 #======================================================================
8 # base file name excluding file extension
9 MANUAL := debian-reference
10 #
11 # build strategy depends on build environment (robust build)
12 #STRATEGY := $(shell if [ "$$(lsb_release -s -r)" = "n/a" ]; then echo "unstable"; else echo "stable" ; fi)
13
14 # When texlive tool chain suffer problem, run "make prep" and commit "keep/"
15 # directory in stable environment and build package in STRATEGY=unstable
16 # environment
17 STRATEGY := stable
18 # When OK situation, uncomment to set as above
19
20 LANGPO := ja fr it es zh-cn id de pt-br pt zh-tw sv ro ca ru ta lv uk
21 LANGPO_PREP := ja fr it es zh-cn id de pt-br pt zh-tw sv ro ca ru ta lv uk
22 # languages to skip generation of PDF files (not used now)
23
24 NOPDF :=
25 # languages to build document
26 LANGALL = en $(LANGPO)
27 # Packages uploaded to unstable repo generate official Debian web pages
28 # Change these to post-release state when Debian is under soft freeze
29 #
30 # https://www.debian.org/releases/
31 # current "stable" release name (2025 June)
32 RELEASE_NAME0L := trixie
33 RELEASE_NAME0U := Trixie
34 # next "stable" / "testing" release name
35 RELEASE_NAME1L := forky
36 RELEASE_NAME1U := Forky
37 # next next "stable" / next "testing" release name
38 RELEASE_NAME2L := duke
39 RELEASE_NAME2U := Duke
40 # release name considered outdated (Release_Date-EOL_for_LTS)
41 RELEASE_NAMEXX := Jessie 8 (2015-2020)
42 # release names when this document was last updated
43 RELEASE_DOC_1 := Trixie (=<literal>stable</literal>)
44 RELEASE_DOC_2 := Forky (=<literal>testing</literal>)
45
46 #######################################################################
47 # Used as $(call check_command, <command>, <package>)
48 define check_command
49 set -e; if ! type $(1) >/dev/null; then \
50 echo "Missing command: '$(1)', install package: '$(2)'"; \
51 false; \
52 fi
53 endef
54 # Used as $(call check_file, <file>)
55 define check_file
56 set -e; if ! [ -r $(1) ]; then \
57 echo "Missing file: '$(1)'"; \
58 false; \
59 fi
60 endef
61 #######################################################################
62 # CHECK FOR MAJOR UPDATE (drifting binary package name)
63 # * https://tracker.debian.org/pkg/poppler installs libpoppler???
64 # * https://packages.debian.org/unstable/gcc for amd64 install gcc-?? etc.
65 #
66 # Address drifting package name without affecting PO-translation
67 # These needs to be executed in unstable chroot by "make entity) or by CI
68 #
69 # CI environment must install "gcc"
70 # need apt in CI and build (unstable)
71 REPO_TYPE := $(shell \
72 apt show base-files | \
73 sed -n -e '/APT-Sources/s/^[^ ]* [^ ]* \([^ ]*\)\/[^ ]* .*$$/\1/p')
74 # need linux as kernl for "make entity" and "make test_version"
75 LINUX_VERSION := $(shell uname -r | sed -e 's/+.*$$//')
76 LINUX_VERSION_X := $(shell uname -r | sed -e 's/\..*$$//')
77 # need gcc for "make entity" and "make test_version"
78 GCC_VERSION := $(shell \
79 readlink /usr/bin/gcc | sed -e 's/gcc-//')
80 # version for libstdc++-??-dev (this is same as GCC_VERSION
81 LIBSTDC_VERSION := $(GCC_VERSION)
82 # need poppler-utils (depends on the latest libpoppler???) for "make entity" and "make test_version"
83 POPPLER_VERSION := $(shell \
84 cd /usr/lib/x86_64-linux-gnu ; \
85 ls -F -1 libpoppler* | \
86 sed -n -e '/@/s/^libpoppler\.so\.\(.*\)@$$/\1/p' | \
87 sort -n -r | head -n 1 )
88
89 # replace placeholder marker string in XML with versioned package name
90 SED_ADD_VERSION := \
91 -e s/@libpoppler@/libpoppler$(POPPLER_VERSION)/g \
92 -e s/@libstdc++-dev@/libstdc++-$(LIBSTDC_VERSION)-dev/g \
93 -e s/@gcc@/gcc-$(GCC_VERSION)/g \
94 -e s/@linux_version_x@/$(LINUX_VERSION_X)/g \
95 -e s/@linux_version@/$(LINUX_VERSION)/g
96
97 # Please note, @gcc@ is used not in table part requiring remote.ent generation
98
99 # replace versioned package name with version stripped one
100 # this ensures correct entity name generated from placeholder marker string
101 SED_DROP_VERSION := \
102 -e s/libpoppler$(POPPLER_VERSION)/libpoppler/g \
103 -e s/libstdc++-$(LIBSTDC_VERSION)-dev/libstdcdev/g
104
105 # Match <literal>command_name</literal>(1) and
106 # replace it with <ulink url="https://manpages.debian.org/unstable/command_name(1)">command_name(1)</ulink>
107 SET_MANPAGE_URL := \
108 -e 's,<literal>\([a-zA-Z0-9_\.-]*\)<\/literal>(\([1-9]\)),<ulink url="https://manpages.debian.org/unstable/\1(\2)">\1(\2)</ulink>,g'
109
110 # version in changelog
111 DR_VERSION := $(shell dpkg-parsechangelog --show-field Version)
112
113 # set SOURCE_DATE_EPOCH if unset (when not called from debhelper)
114 SOURCE_DATE_EPOCH ?= $(shell dpkg-parsechangelog -STimestamp)
115 # Export for reproducible PDF build
116 # 2020: https://tex.stackexchange.com/questions/568235/how-do-i-configure-pdflatex-to-output-binary-equivalent-pdfs-if-the-input-tex-fi
117 # 2015: https://tex.stackexchange.com/questions/229605/reproducible-latex-builds-compile-to-a-file-which-always-hashes-to-the-same-va
118 export SOURCE_DATE_EPOCH
119 FORCE_SOURCE_DATE = 1
120 export FORCE_SOURCE_DATE
121
122 # date in changelog
123 SOURCE_DATE := $(shell date -u +'%F %T %Z' --date=@$(SOURCE_DATE_EPOCH))
124
125 # BUILD_DIR is not mean to be set to generic TMPDIR
126 BUILD_DIR := $(CURDIR)/build
127 # KEEP_DIR holds PDFs build in the stable environment
128 KEEP_DIR := $(CURDIR)/keep
129
130 # Change $(DRAFTMODE) from "yes" to "maybe" when this document
131 # should go into production mode
132 #DRAFTMODE := yes
133 DRAFTMODE := maybe
134 export DRAFTMODE
135
136 # define EXPOSEMODE to yes to expose not-so-popular program listings in table list
137 # (This is used to hide marginal table list entry.)
138 EXPOSEMODE ?= no
139 ifeq "$(EXPOSEMODE)" "yes"
140 XML_COMMENT_START=
141 XML_COMMENT_END=
142 else
143 XML_COMMENT_START= <!--
144 XML_COMMENT_END= -->
145 endif
146
147 # Prevent external environment vriables to impact build result
148 TZ := "0"
149 export TZ
150 # Reset all locale variables for clean perl execution
151 unexport LANG
152 unexport LANGUAGE
153 unexport LC_TIME
154 unexport LC_COLLATE
155 unexport LC_ALL
156 unexport LC_MEASUREMENT
157 unexport LC_NUMERIC
158 unexport LC_PAPER
159 unexport LC_MONETARY
160
161 # for reproducible build
162 FORCE_SOURCE_DATE = 1
163 export FORCE_SOURCE_DATE
164 #######################################################################
165 ### basic constant parameters
166 #######################################################################
167 # Directories (no trailing slash)
168 DXSL := xslt
169 DBIN := bin
170 DRAW := rawxml
171 DPO := po
172 DIMG := /usr/share/xml/docbook/stylesheet/nwalsh/images
173
174 # work around https://bugs.debian.org/725931
175 PERL_PERTURB_KEYS := 0
176 export PERL_PERTURB_KEYS
177 PERL_HASH_SEED := 0
178 export PERL_HASH_SEE
179
180 # Program name and option
181 # stop using faketime
182 XLINT := xmllint --format
183 XPNO := xsltproc --novalid --nonet
184 XPINC := xsltproc --novalid --nonet --xinclude
185 MSGATTR := msgattrib
186 MSGCAT := msgcat
187 MSGUNIQ := msguniq --use-first
188 DBLATEX := /usr/bin/dblatex
189 SED := sed
190 ZIP := zip
191
192 # Source files
193 SRC_XML := $(wildcard $(DRAW)/*_*.rawxml)
194 SRC_PARA := sed_add_version sed_drop_version package_list marker_package_version
195 SRC_ENT:= remote.ent common.ent
196 # source PO files for all languages (build process requires these)
197 SRC_PO := $(addsuffix .po, $(addprefix $(DPO)/, $(LANGPO)))
198 # sed script for replace
199 SEDF ?= $(DBIN)/replace0
200
201 # po4a/opencc translation
202 PO4A1 ?= $(DBIN)/po4a1
203 PO4A2 ?= $(DBIN)/po4a2
204 PO4ATMP ?= $(DBIN)/po4atmp
205 POFUZZY1 ?= $(DBIN)/pofuzzy1
206 POFUZZY2 ?= $(DBIN)/pofuzzy2
207
208 # Remote file source (related to Debian package archive URLs)
209 #DEBM := http://ftp.us.debian.org/debian/dists
210 #DEBM := http://ftp.jp.debian.org/debian/dists
211 DEBM := http://deb.debian.org/debian/dists
212 # Debian popcon data source URL
213 UPOPC := https://popcon.debian.org/all-popcon-results.txt.gz
214 # Debian release name and arch used
215 CODE := sid
216 ARCH := amd64
217 UDEBA := $(DEBM)/$(CODE)
218 UDEBB := $(DEBM)/experimental
219 UDEBC := $(DEBM)/stable
220 UDEBD := $(DEBM)/oldstable
221 # processed remote data
222 PACKAGES_DATA := packages.main packages.non-free-firmware packages.contrib packages.non-free \
223 packages.txt packages.experimental.txt \
224 packages.stable.txt packages.oldstable.txt
225 POPCON_DATA := all-popcon-results.txt \
226 all-popcon-date.txt \
227 all-popcon-submissions.txt \
228 all-popcon-pkgs.txt
229 REMOTE_DATA := $(PACKAGES_DATA) $(POPCON_DATA)
230
231
232 #======================================================================
233 # ===== Utility targets ===============================================
234 #======================================================================
235 #######################################################################
236 # $ make all # build all formats
237 #######################################################################
238 .PHONY: all
239 # You may set LANGPO to limit language to build target files
240 all: css html txt pdf
241 @echo "PO status: po_completed.md"
242 -cat po_completed.md
243
244 #######################################################################
245 # $ make test_html # build html for all languages (for Translator)
246 #######################################################################
247 .PHONY: test_html
248 # You may set LANGPO to limit language to build target files
249 test_html: html css
250 @echo "PO status: po_completed.md"
251 -cat po_completed.md
252
253 #######################################################################
254 # $ make test_version # check gcc and poppler version in sid (CI)
255 #######################################################################
256 # run this in the unstable chroot with remote access
257 test_version: marker_package_version
258 @$(call check_command,gcc,gcc)
259 @$(call check_command,pdfinfo,poppler-utils)
260 @echo "Current version: $(GCC_VERSION):$(POPPLER_VERSION)"
261 @echo "Entity version: $(shell cat marker_package_version)"
262 @if [ "$(GCC_VERSION):$(POPPLER_VERSION)" = "$(shell cat marker_package_version)" ]; then \
263 echo "Correct version based entity.ent" ; \
264 else \
265 echo "Bad version based entity.ent" ; \
266 false ; \
267 fi
268
269 #######################################################################
270 # $ make entity # refresh remote.ent (Need remote access)
271 #######################################################################
272 # For major English update and version update of GCC/POPPLER,
273 # run this and commit updated data in the unstable chroot with remote access
274 .PHONY: entity
275 entity:
276 @$(call check_command,apt,apt)
277 @$(call check_command,gcc,gcc)
278 @$(call check_command,pdfinfo,poppler-utils)
279 # Ensure to run in sid chroot
280 if [ "$(REPO_TYPE)" != "unstable" ]; then echo "Run 'make entity' in sid chroot" ; false ; fi
281 $(MAKE) entityclean
282 $(MAKE) $(REMOTE_DATA)
283 $(MAKE) $(SRC_PARA)
284 $(MAKE) $(SRC_ENT)
285
286
287 #======================================================================
288 # ===== Common-build targets (no remote access ) ======================
289 #======================================================================
290 $(DRAW)/$(MANUAL).rawxml: $(SRC_XML)
291 { cd $(DRAW) >/dev/null 2>/dev/null ; ./merge.sh ; } > $@
292
293 #======================================================================
294 # ===== Pre-build only (remote access) ================================
295 #======================================================================
296 #======================================================================
297 # Phase 1.0 (pre-build): source update targets ========================
298 #======================================================================
299 # run these in unstable chroot
300 marker_package_version:
301 @$(call check_command,gcc,gcc)
302 @$(call check_command,pdfinfo,poppler-utils)
303 echo "$(GCC_VERSION):$(POPPLER_VERSION)" > $@
304
305 sed_add_version:
306 @$(call check_command,gcc,gcc)
307 @$(call check_command,pdfinfo,poppler-utils)
308 echo "$(SED_ADD_VERSION)" > $@
309
310 sed_drop_version:
311 @$(call check_command,gcc,gcc)
312 @$(call check_command,pdfinfo,poppler-utils)
313 echo "$(SED_DROP_VERSION)" > $@
314
315 #######################################################################
316 # Phase 1.1 (pre-build): download Debian stat data (REMOTE_DATA)
317 #######################################################################
318 packages.main:
319 # FETCH PACKAGE (sid main)
320 @$(call check_command,wget,wget)
321 @$(call check_command,grep-dctrl,dctrl-tools)
322 wget -O - $(UDEBA)/main/binary-$(ARCH)/Packages.xz | xzcat - > packages.main.tmp
323 grep-dctrl -e -sPackage,Installed-Size -P "." packages.main.tmp > packages.main
324 rm packages.main.tmp
325
326 packages.contrib:
327 # FETCH PACKAGE (sid contrib)
328 @$(call check_command,wget, wget)
329 @$(call check_command,grep-dctrl,dctrl-tools)
330 wget -O - $(UDEBA)/contrib/binary-$(ARCH)/Packages.xz | xzcat - > packages.contrib.tmp
331 grep-dctrl -e -sPackage,Installed-Size -P "." packages.contrib.tmp > packages.contrib
332 rm packages.contrib.tmp
333
334 packages.non-free-firmware:
335 # FETCH PACKAGE (sid non-free-firmware)
336 @$(call check_command,wget,wget)
337 @$(call check_command,grep-dctrl,dctrl-tools)
338 wget -O - $(UDEBA)/non-free-firmware/binary-$(ARCH)/Packages.xz | xzcat - > packages.non-free-firmware.tmp
339 grep-dctrl -e -sPackage,Installed-Size -P "." packages.non-free-firmware.tmp > packages.non-free-firmware
340 rm packages.non-free-firmware.tmp
341
342 packages.non-free:
343 # FETCH PACKAGE (sid non-free)
344 @$(call check_command,wget,wget)
345 @$(call check_command,grep-dctrl,dctrl-tools)
346 wget -O - $(UDEBA)/non-free/binary-$(ARCH)/Packages.xz | xzcat - > packages.non-free.tmp
347 grep-dctrl -e -sPackage,Installed-Size -P "." packages.non-free.tmp > packages.non-free
348 rm packages.non-free.tmp
349
350 packages.experimental.txt:
351 # FETCH PACKAGE (experimental main)
352 @$(call check_command,wget,wget)
353 @$(call check_command,grep-dctrl,dctrl-tools)
354 wget -O - $(UDEBB)/main/binary-$(ARCH)/Packages.xz | xzcat - > packages.experimental.tmp
355 grep-dctrl -e -sPackage,Installed-Size -P "." packages.experimental.tmp > packages.experimental.txt
356 rm packages.experimental.tmp
357
358 packages.txt: packages.main packages.non-free-firmware packages.contrib packages.non-free
359 # FETCH PACKAGE (sid)
360 cat packages.main packages.non-free-firmware packages.contrib packages.non-free >packages.txt
361
362 packages.stable.txt:
363 # FETCH PACKAGE (stable main)
364 @$(call check_command,wget,wget)
365 @$(call check_command,grep-dctrl,dctrl-tools)
366 wget -O - $(UDEBC)/main/binary-$(ARCH)/Packages.xz | xzcat - > packages.stable.tmp
367 grep-dctrl -e -sPackage,Installed-Size -P "." packages.stable.tmp > packages.stable.txt
368 rm packages.stable.tmp
369
370 packages.oldstable.txt:
371 # FETCH PACKAGE (oldstable main contrib)
372 @$(call check_command,wget,wget)
373 @$(call check_command,grep-dctrl,dctrl-tools)
374 wget -O - $(UDEBD)/main/binary-$(ARCH)/Packages.xz | xzcat - > packages.oldstable.tmp
375 grep-dctrl -e -sPackage,Installed-Size -P "." packages.oldstable.tmp > packages.oldstable.txt
376 rm packages.oldstable.tmp
377 wget -O - $(UDEBD)/contrib/binary-$(ARCH)/Packages.xz | xzcat - > packages.oldstable.tmp
378 grep-dctrl -e -sPackage,Installed-Size -P "." packages.oldstable.tmp >> packages.oldstable.txt
379 rm packages.oldstable.tmp
380
381 all-popcon-results.txt:
382 # POPCON RESULTS
383 wget -O - $(UPOPC) | zcat - > all-popcon-results.txt
384
385 all-popcon-submissions.txt: all-popcon-results.txt
386 sed -n -e 's/^Submissions: *\([^ ]*\) *$$/\1/p' < all-popcon-results.txt > all-popcon-submissions.txt
387
388 all-popcon-date.txt: all-popcon-results.txt
389 echo "<!ENTITY pop-date \"$(shell date -u +'%F %T %Z')\">" > all-popcon-date.txt
390
391 all-popcon-pkgs.txt: all-popcon-results.txt
392 grep --binary-files=text -e '^Package: [a-z0-9][-+a-z0-9.]*[ 0-9]*$$' < all-popcon-results.txt > all-popcon-pkgs.txt
393
394 # download base data for package data and popcon data
395 .PHONY: remote
396 remote: $(REMOTE_DATA)
397
398 #######################################################################
399 # Phase 1.2 (pre-build): extract package name list (package_list)
400 #######################################################################
401
402 # extract package name (@emacs@ etc.) list from RAWXML
403 # used pre-build time only
404 package_list: $(DRAW)/$(MANUAL).rawxml
405 @$(call check_command,xsltproc,xsltproc)
406 @$(call check_command,gcc,gcc)
407 @$(call check_command,pdfinfo,poppler-utils)
408 # PACKAGE LIST of packages mentioned in the source XML
409 $(XPNO) $(DXSL)/pkg.xsl $(DRAW)/$(MANUAL).rawxml | \
410 sed $(SED_ADD_VERSION) | \
411 sort -u > $@
412
413 #######################################################################
414 # Phase 1.3 (pre-build): update Debian archive stat data (remote.ent)
415 #######################################################################
416
417 # source XML inclusion file (pre-commited since this needs remote access)
418 # no dependency claimed to avoid remote access to update data
419 remote.ent:
420 cat all-popcon-date.txt > $@
421 echo "<!ENTITY all-packages \"$$(grep -e '^Package:' packages.txt | wc -l)\">" >> $@
422 echo "<!ENTITY main-packages \"$$( grep -e '^Package:' packages.main | wc -l)\">" >> $@
423 echo "<!ENTITY contrib-packages \"$$(grep -e '^Package:' packages.contrib | wc -l)\">" >> $@
424 echo "<!ENTITY non-free-firmware-packages \"$$(grep -e '^Package:' packages.non-free-firmware | wc -l)\">" >> $@
425 echo "<!ENTITY non-free-packages \"$$(grep -e '^Package:' packages.non-free | wc -l)\">" >> $@
426 # pre size entity
427 sort package_list | uniq | $(DBIN)/sizeent packages.txt packages.experimental.txt packages.stable.txt packages.oldstable.txt >> $@
428 # post size entity
429 echo "<!ENTITY pop-submissions \"$$(sed -n -e 's/^Submissions: *\([^ ]*\) *$$/\1/p' < all-popcon-results.txt)\">" >> $@
430 echo "<!ENTITY pop-architectures \"$$(grep --binary-files=text -e '^Architecture:' all-popcon-results.txt | wc -l)\">" >> $@
431 echo "<!ENTITY pop-packages \"$$(grep -e '^Package:' all-popcon-pkgs.txt | wc -l)\">" >> $@
432 # pre popcon entity
433 grep -e '^Package:' all-popcon-pkgs.txt | grep -f package_list | $(DBIN)/popconent.py `cat all-popcon-submissions.txt` >> $@
434 # post popcon entity
435
436 #======================================================================
437 # ===== Main-build only (no remote access) ============================
438 #======================================================================
439 #######################################################################
440 # Phase 2(build): RAWXML (template) -> English XML
441 #######################################################################
442
443 # Make updated URL list for header from $(MANUAL).rawxml
444 # Sanity check of URLS
445 # - Check duplicates of id with different URLs
446 # - Check site URL is active or not
447 # - Basically always use URL with https://...
448 # - Exceptions:
449 # - APT source URLs
450 # - http://localhost
451 #
452 # Translate URL for en.wikipedia.org only
453 #
454 # Minimize use of sourceforge.net and sf.net
455 #
456 $(DRAW)/headerurl.rawxml: $(DRAW)/$(MANUAL).rawxml
457 $(XPNO) $(DXSL)/urls.xsl $(DRAW)/$(MANUAL).rawxml | sort | uniq | sed -e 's/&/\&amp;/g' > $@
458 # sanity check source for URL links (duplicates)
459 sed -e 's,<!ENTITY \([^ ]*\) .*$$, \1 ,' < $@ | uniq -d > [email protected]
460 # sanity check source for URL links (non-HTTPS)
461 fgrep -e ' "http://' < $@ | sort | fgrep -v \
462 -e 'http://localhost' \
463 -e 'http://deb.debian.org' \
464 -e 'http://security.debian.org' \
465 -e 'http://archive.ubuntu.com' \
466 > [email protected] || true
467 # prep for sanity check source for URL links (non-reachable HTTPS)
468 fgrep -e ' "https://' < $@ | sed -e 's,<!ENTITY [^"]*"\([^"]*\)".*$$,\1,' < $@ | sort | uniq > [email protected]
469 #
470 @if [ "$$(wc -l < [email protected])" -gt 0 ]; then \
471 echo ; echo ">>> W: Duplicate id with different URLs found. ([email protected]) ." ; \
472 grep -f "[email protected]" < $@ | tee [email protected]; \
473 echo ; fi
474 @if [ "$$(wc -l < [email protected])" -gt 0 ]; then \
475 echo ; echo ">>> W: Non-HTTPS URL links found. Check HTTPS-URLs works or not. ([email protected])" ; \
476 sed -e 's/^[^"]*"http/https/' -e 's/"[^"]*$$//' [email protected] | sort | tee [email protected] ; \
477 echo ; fi
478 @if grep -e '<!ENTITY "">' < $@ >/dev/null ; then echo ; \
479 echo ">>> W: empty entity value found. Check sources in $(DRAW)/ ." ; \
480 echo ; fi
481
482 # download base data for package data and popcon data
483 .PHONY: url
484 url: $(DRAW)/headerurl.rawxml
485
486 # slow, remote access and check URL link
487 .PHONY: badurl
488 badurl:
489 $(MAKE) clean
490 $(MAKE) url
491 : > $(DRAW)/headerurl.rawxml.urlsbad
492 # check accessibility of URL: '--head' or '-r 0-0'
493 @for f in $$(cat $(DRAW)/headerurl.rawxml.urls) ; do \
494 if curl --user-agent "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" \
495 --output /dev/null --connect-timeout 15 --silent --head --fail $$f ; then \
496 echo "I: good URL $$f" ; \
497 else \
498 echo ">>> W: possibly bad URL $$f" ; \
499 echo ">>> W: possibly bad URL $$f" >> $(DRAW)/headerurl.rawxml.urlsbad ; \
500 fi; \
501 done; echo
502
503 # Even with user-agent spoofing, followings fail but these are good URLs
504 #
505 # (errors happen with "--head")
506 # >>> W: possibly bad URL https://tldp.org/pub/Linux/docs/ldp-archived/users-guide/
507 # >>> W: possibly bad URL https://unix.org/
508 # >>> W: possibly bad URL https://unix.org/version2/
509 # >>> W: possibly bad URL https://unix.org/version3/
510 # >>> W: possibly bad URL https://unix.org/version4/
511 #
512 # (errors happen with "-r 0-0")
513 # >>> W: possibly bad URL https://unix.org/
514 # >>> W: possibly bad URL https://unix.org/version2/
515 # >>> W: possibly bad URL https://unix.org/version3/
516 # >>> W: possibly bad URL https://unix.org/version4/
517 # >>> W: possibly bad URL https://www.netfilter.org/documentation/
518 # >>> W: possibly bad URL https://www.netfilter.org/documentation/HOWTO/NAT-HOWTO.html
519 # >>> W: possibly bad URL https://www.netfilter.org/documentation/HOWTO/networking-concepts-HOWTO.html
520 # >>> W: possibly bad URL https://www.netfilter.org/documentation/HOWTO/packet-filtering-HOWTO.html
521
522
523 # Make updated en.wikipedia URL list entity (DRAW)/header.rawxml
524 $(DRAW)/header.rawxml: $(DRAW)/header1.rawxml $(DRAW)/header2.rawxml $(DRAW)/headerurl.rawxml
525 cat $(DRAW)/header1.rawxml > $@
526 fgrep -e ' "https://en.wikipedia.org/' $(DRAW)/headerurl.rawxml >> $@
527 cat $(DRAW)/header2.rawxml >> $@
528
529 # GENERATE
530 # source XML inclusion file updated for normal build (no remote access)
531 common.ent: Makefile debian/changelog $(DRAW)/headerurl.rawxml
532 # Update parameters
533 echo "<!ENTITY build-date \"$(SOURCE_DATE)\">" > $@
534 echo "<!ENTITY dr-version \"$(DR_VERSION)\">" >> $@
535 echo "<!ENTITY arch \"$(ARCH)\">" >> $@
536 echo "<!ENTITY codename-stable \"$(RELEASE_NAME0L)\">" >> $@
537 echo "<!ENTITY Codename-stable \"$(RELEASE_NAME0U)\">" >> $@
538 echo "<!ENTITY codename-testing \"$(RELEASE_NAME1L)\">" >> $@
539 echo "<!ENTITY Codename-testing \"$(RELEASE_NAME1U)\">" >> $@
540 echo "<!ENTITY codename-nexttesting \"$(RELEASE_NAME2L)\">" >> $@
541 echo "<!ENTITY Codename-nexttesting \"$(RELEASE_NAME2U)\">" >> $@
542 echo "<!ENTITY codename-unstable \"sid\">" >> $@
543 echo "<!ENTITY Codename-unstable \"Sid\">" >> $@
544 echo "<!ENTITY release-outdated \"$(RELEASE_NAMEXX)\">" >> $@
545 echo "<!ENTITY Codename-doc-1 \"$(RELEASE_DOC_1)\">" >> $@
546 echo "<!ENTITY Codename-doc-2 \"$(RELEASE_DOC_2)\">" >> $@
547 # Don't trancelate non-wikipedia URL links
548 fgrep -v -e ' "https://en.wikipedia.org/' $(DRAW)/headerurl.rawxml >> $@
549
550 # Replace table contents with @-@popcon*@-@ and @@@psize*@-@ and
551 # fix URL referencees and table ID (but keep drifting package names as @...@).
552 $(MANUAL).en.xmlf: $(DRAW)/$(MANUAL).rawxml $(DRAW)/header.rawxml
553 @$(call check_command,xsltproc,xsltproc)
554 $(XPNO) $(DXSL)/table.xsl $(DRAW)/$(MANUAL).rawxml |\
555 $(DBIN)/colspec.py |\
556 sed -e '/<!DOCTYPE /d' -e "1r $(DRAW)/header.rawxml" |\
557 sed -e 's/@-@amp@-@/\&/g' \
558 -e 's/@-@XML_COMMENT_START@-@/$(XML_COMMENT_START)/g' \
559 -e 's/@-@XML_COMMENT_END@-@/$(XML_COMMENT_END)/g' \
560 -e 's/@-@\([^@]\+\)@-@/\&\1;/g' \
561 > $@
562
563 # Replace table contents with dummy text and
564 # fix URL references and table ID as the template for translation.
565 # This avoids bloated PO/POT files. (tablet.xsl used instead of table.xsl)
566 $(MANUAL).en.xmlt: $(DRAW)/$(MANUAL).rawxml $(DRAW)/header.rawxml
567 # GENERATE $(MANUAL).en.xmlt (TEMPLATE to avoid bloated PO/POT files)
568 @$(call check_command,xsltproc,xsltproc)
569 # Note: tablet.xsl with tailing "t"
570 $(XPNO) $(DXSL)/tablet.xsl $(DRAW)/$(MANUAL).rawxml |\
571 $(DBIN)/colspec.py |\
572 sed -e '/<!DOCTYPE /d' -e "1r $(DRAW)/header.rawxml" |\
573 sed -e 's/@-@amp@-@/\&/g' \
574 -e 's/@-@XML_COMMENT_START@-@/$(XML_COMMENT_START)/g' \
575 -e 's/@-@XML_COMMENT_END@-@/$(XML_COMMENT_END)/g' \
576 -e 's/@-@\([^@]\+\)@-@/\&\1;/g' \
577 > $@
578
579 #######################################################################
580 # Phase 3 build : English XMLF -> POT/PO/XMLF non-ENGLISH
581 #######################################################################
582 # This phase of build now calls po4a twice via $(PO4A1) and $(PO4A2)
583 # base XMLF files for all languages and update PO
584 # Completion marker is fuzzy1.log and fuzzy2.log for translation status
585
586 POFILES = $(addsuffix .po, $(addprefix po/, $(LANGPO)))
587
588 fuzzy1.log: $(POFILES) $(MANUAL).en.xmlf $(MANUAL).en.xmlt
589 @$(call check_command,po4a,po4a)
590 @$(call check_command,msgcat,gettext)
591 $(PO4A1) $(LANGPO)
592 $(POFUZZY1) $(LANGPO) >$@
593
594 po_completed.md: fuzzy1.log
595 echo "# Translation status" >$@
596 echo "" >>$@
597 sed -n -e '/COMPLETE/s/^/* /p' fuzzy1.log | \
598 sort -n -r -k 3 >>$@
599
600 fuzzy2.log: po_completed.md
601 $(PO4ATMP) $(LANGPO)
602 $(POFUZZY2) $(LANGPO) >$@
603 cp -r po-tmp po-keep
604 $(PO4A2) $(LANGPO)
605
606 .PHONY: po
607 po: po_completed.md
608
609 $(addsuffix .xmlf, $(addprefix $(MANUAL)., $(LANGPO))): fuzzy2.log
610
611 # post-translation string substitution
612 $(MANUAL).%.xml: $(MANUAL).%.xmlf
613 sed $(shell cat sed_add_version) $(SET_MANPAGE_URL) $< > $@
614
615 .PHONY: xml
616 xml: $(addsuffix .xml, $(addprefix $(MANUAL)., $(LANGPO)))
617
618 #######################################################################
619 # Phase 4 build : Formatted conversion from XML
620 #######################################################################
621
622 #######################################################################
623 # $ make css # update CSS and DIMG in $(BUILD_DIR)
624 #######################################################################
625 .PHONY: css
626 css:
627 -rm -rf $(BUILD_DIR)/images
628 mkdir -p $(BUILD_DIR)/images
629 cp -f $(DXSL)/$(MANUAL).css $(BUILD_DIR)/$(MANUAL).css
630 echo "AddCharset UTF-8 .txt" > $(BUILD_DIR)/.htaccess
631 #cd $(DIMG) ; cp caution.png home.png important.png next.png note.png prev.png tip.png up.gif warning.png $(BUILD_DIR)/images
632 cd $(DIMG) ; cp caution.png important.png note.png tip.png up.gif warning.png $(BUILD_DIR)/images
633 cd png ; cp home.png next.png prev.png $(BUILD_DIR)/images
634
635 #######################################################################
636 # $ make html # update all HTML in $(BUILD_DIR)
637 #######################################################################
638 .PHONY: html
639 html: $(foreach LX, $(LANGALL), $(BUILD_DIR)/index.$(LX).html)
640
641 $(BUILD_DIR)/index.%.html: $(MANUAL).%.xml $(SRC_ENT)
642 @$(call check_command,xsltproc,xsltproc)
643 -mkdir -p $(BUILD_DIR)
644 $(XPINC) --stringparam base.dir $(BUILD_DIR)/ \
645 --stringparam html.ext .$*.html \
646 $(DXSL)/style-html.xsl $<
647
648 #######################################################################
649 # $ make txt # update all Plain TEXT in $(BUILD_DIR)
650 #######################################################################
651 .PHONY: txt
652 txt: $(foreach LX, $(LANGALL), $(BUILD_DIR)/$(MANUAL).$(LX).txt.gz)
653
654 # style-txt.xsl provides work around for hidden URL links by appending them explicitly.
655 $(BUILD_DIR)/$(MANUAL).%.txt.gz: $(MANUAL).%.xml $(SRC_ENT)
656 @$(call check_command,w3m,w3m)
657 @$(call check_command,xsltproc,xsltproc)
658 -mkdir -p $(BUILD_DIR)
659 @test -n /usr/bin/w3m || { echo "ERROR: w3m not found. Please install the w3m package." ; false ; }
660 $(XPINC) $(DXSL)/style-txt.xsl $< | LC_ALL=en_US.UTF-8 \
661 w3m -o display_charset=UTF-8 -cols 70 -dump -no-graph -T text/html | \
662 gzip -n -9 - > $@
663
664 #######################################################################
665 # $ make pdf # update all PDF in $(BUILD_DIR)
666 #######################################################################
667 .PHONY: pdf
668 pdf: $(foreach LX, $(LANGALL), $(BUILD_DIR)/$(MANUAL).$(LX).pdf)
669
670 ifeq "$(STRATEGY)" "stable"
671 nopdf: $(BUILD_DIR)/nopdf.pdf
672
673 $(BUILD_DIR)/nopdf.pdf: nopdf.tex
674 -mkdir -p $(BUILD_DIR)
675 cd $(BUILD_DIR); \
676 xelatex ../nopdf.tex
677
678 $(foreach LX, $(NOPDF), $(BUILD_DIR)/$(MANUAL).$(LX).pdf): $(BUILD_DIR)/nopdf.pdf
679 -mkdir -p $(BUILD_DIR)
680 cp $(BUILD_DIR)/nopdf.pdf $@
681
682 # dblatex.xsl provide work around for hidden URL links by appending them explicitly.
683 $(BUILD_DIR)/$(MANUAL).%.pdf: $(MANUAL).%.xml $(SRC_ENT)
684 @$(call check_command,dblatex,dblatex)
685 @$(call check_command,xsltproc,xsltproc)
686 -mkdir -p $(BUILD_DIR)
687 @test -n "$(DBLATEX)" || { echo "ERROR: dblatex not found. Please install the dblatex package." ; false ; }
688 export TEXINPUTS=".:"; \
689 $(XPINC) $(DXSL)/dblatex.xsl $< | \
690 $(DBLATEX) --style=native \
691 --debug \
692 --backend=xetex \
693 --xsl-user=$(DXSL)/user_param.xsl \
694 --xsl-user=$(DXSL)/xetex_param.xsl \
695 --param=draft.mode=$(DRAFTMODE) \
696 --param=lingua=$* \
697 --output=$@ - || { \
698 echo "Error message here may be ignored as long as PDF(language=$*) file is generated."; \
699 if test -e $@ ; then \
700 echo "PDF($@) build successfully"; true ; \
701 else \
702 echo "PDF($@) is missing"; false ; \
703 fi ; }
704
705 $(KEEP_DIR)/$(MANUAL).%.pdf: $(BUILD_DIR)/$(MANUAL).%.pdf
706 cp -f $(BUILD_DIR)/$(MANUAL).$*.pdf $(KEEP_DIR)/$(MANUAL).$*.pdf
707
708 .PHONY: copy-pdf
709 copy-pdf:
710 $(MAKE) $(foreach LX, $(LANGALL), $(KEEP_DIR)/$(MANUAL).$(LX).pdf)
711
712 .PHONY: prep
713 prep:
714 mkdir -p $(KEEP_DIR)
715 git describe > $(KEEP_DIR)/git_id
716 $(MAKE) copy-pdf "LANGPO=$(LANGPO_PREP)"
717
718 else # STRATEGY "unstable"
719 # When texlive tool chain suffer problem, run "make prep" and commit "keep/"
720 # directory in stable environment and build package in STRATEGY=unstable
721 # environment
722 #
723 # Some sanity checks when using "keep/" contents
724
725 # dblatex.xsl provide work around for hidden URL links by appending them explicitly.
726 $(BUILD_DIR)/$(MANUAL).%.pdf: $(MANUAL).%.xml $(SRC_ENT)
727 @$(call check_command,dblatex,dblatex)
728 @$(call check_command,xsltproc,xsltproc)
729 -mkdir -p $(BUILD_DIR)
730 @test -n "$(DBLATEX)" || { echo "ERROR: dblatex not found. Please install the dblatex package." ; false ; }
731 export TEXINPUTS=".:"; \
732 $(XPINC) $(DXSL)/dblatex.xsl $< | \
733 $(DBLATEX) --style=native \
734 --debug \
735 --backend=xetex \
736 --xsl-user=$(DXSL)/user_param.xsl \
737 --xsl-user=$(DXSL)/xetex_param.xsl \
738 --param=draft.mode=$(DRAFTMODE) \
739 --param=lingua=$* \
740 --output=$@ - || { \
741 echo "Error message here may be ignored as long as PDF(language=$*) file is generated."; \
742 if test -e $@ ; then \
743 echo "PDF($@) build successfully"; true ; \
744 elif git diff --quiet $(shell cat $(KEEP_DIR)/git_id)..HEAD po rawxml && test -e $(KEEP_DIR)/$(MANUAL).$*.pdf; then \
745 cp -f $(KEEP_DIR)/$(MANUAL).$*.pdf $(BUILD_DIR)/$(MANUAL).$*.pdf ; true ;\
746 else \
747 echo "valid PDF($(KEEP_DIR)/$(MANUAL).$*.pdf) is missing"; false ; \
748 fi ; }
749 endif
750
751 #######################################################################
752 # $ make tex # update all TeX source in $(BUILD_DIR)
753 #######################################################################
754 .PHONY: tex
755 tex: $(foreach LX, $(LANGALL), $(BUILD_DIR)/$(MANUAL).$(LX).tex)
756
757 # dblatex.xsl provide work around for hidden URL links by appending them explicitly.
758 $(BUILD_DIR)/$(MANUAL).%.tex: $(MANUAL).%.xml $(SRC_ENT)
759 -mkdir -p $(BUILD_DIR)
760 @test -n "$(DBLATEX)" || { echo "ERROR: dblatex not found. Please install the dblatex package." ; false ; }
761 export TEXINPUTS=".:"; \
762 $(XPINC) $(DXSL)/dblatex.xsl $< | \
763 $(DBLATEX) --style=native \
764 --debug \
765 --type=tex \
766 --backend=xetex \
767 --xsl-user=$(DXSL)/user_param.xsl \
768 --xsl-user=$(DXSL)/xetex_param.xsl \
769 --param=draft.mode=$(DRAFTMODE) \
770 --param=lingua=$* \
771 --output=$@ - || { \
772 echo "Error message here may be ignored as long as PDF(language=$*) file is generated."; \
773 if test -e $@ ; then \
774 echo "tex source ($@) build successfully"; true ; \
775 else \
776 echo "tex source ($@) is missing"; false ; \
777 fi }
778
779 #######################################################################
780 # $ make epub # update all epub in $(BUILD_DIR)
781 #######################################################################
782 .PHONY: epub
783 epub: $(foreach LX, $(LANGALL), $(BUILD_DIR)/$(MANUAL).$(LX).epub)
784
785 $(BUILD_DIR)/$(MANUAL).%.epub: $(MANUAL).%.xml $(SRC_ENT)
786 @$(call check_command,xsltproc,xsltproc)
787 -mkdir -p $(BUILD_DIR)/$*/
788 cd $(BUILD_DIR)/$*/ ; $(XPINC) $(CURDIR)/$(DXSL)/style-epub.xsl $(CURDIR)/$<
789 cp -f $(DXSL)/mimetype $(BUILD_DIR)/$*/mimetype
790 cp -f $(DXSL)/$(MANUAL).css $(BUILD_DIR)/$*/OEBPS/$(MANUAL).css
791 cp -f $(DXSL)/debian-openlogo.png $(BUILD_DIR)/$*/OEBPS/debian-openlogo.png
792 find $(BUILD_DIR)/$*/ | xargs -n1 touch -d"$(SOURCE_DATE)"
793 cd $(BUILD_DIR)/$*/ ; $(ZIP) --latest-time -r $@ ./
794
795 #######################################################################
796 # Phase 5 cleans
797 #######################################################################
798 #######################################################################
799 # $ make clean # clean files ready for tar
800 # (override_dh_auto_clean call this)
801 #######################################################################
802 .PHONY: clean
803 clean: localclean remoteclean
804 .PHONY: distclean
805 distclean: clean
806 #######################################################################
807 # $ make localclean # clean locally generated files
808 #######################################################################
809 .PHONY: localclean
810 localclean:
811 # CLEAN
812 -rm -rf $(BUILD_DIR)
813 -rm -rf po-tmp po-keep
814 -rm -rf debian/tmp
815 -rm -f *.swp *~ *.tmp
816 -rm -f $(DPO)/*~ $(DPO)/*.mo $(DPO)/*.po.*
817 -rm -f common.ent
818 -rm -f package_list
819 -rm -f $(addsuffix .xmlf, $(addprefix $(MANUAL)., *))
820 -rm -f $(addsuffix .xmlt, $(addprefix $(MANUAL)., *))
821 -rm -f $(addsuffix .xml, $(addprefix $(MANUAL)., *))
822 -rm -f $(DRAW)/$(MANUAL).rawxml
823 -rm -f $(DRAW)/headerurl.rawxml
824 -rm -f $(DRAW)/headerurl.rawxml.dups
825 -rm -f $(DRAW)/headerurl.rawxml.entdups
826 -rm -f $(DRAW)/headerurl.rawxml.http
827 -rm -f $(DRAW)/headerurl.rawxml.https
828 -rm -f $(DRAW)/headerurl.rawxml.urls
829 -rm -f $(DRAW)/headerurl.rawxml.urlsbad
830 -rm -f $(DRAW)/header.rawxml
831 -rm -f fuzzy*.log
832 -rm -f all-xml.stamp
833 -rm -f po4a.cfg po4a-tmp.cfg
834
835 #######################################################################
836 # $ make remoteclean # clean remote data to generate entity files
837 #######################################################################
838 .PHONY: remoteclean
839 remoteclean:
840 -rm -f $(REMOTE_DATA)
841
842 #######################################################################
843 # $ make entityclean # clean entity files generated from remote data
844 #######################################################################
845 .PHONY: entityclean
846 entityclean:
847 -rm -f $(SRC_PARA)
848 -rm -f $(SRC_ENT)
849
850 #======================================================================
851 # ===== Utility targets ===============================================
852 #======================================================================
853
854 #######################################################################
855 # $ make wrap # wrap all PO
856 #######################################################################
857 .PHONY: wrap wrapx nowrap nowrapx unwrap wip replace check stat
858 wrap:
859 @$(call check_command,msgcat,gettext)
860 for XX in $(foreach LX, $(LANGPO), $(DPO)/$(LX).po); do \
861 $(MSGCAT) -o $$XX $$XX ;\
862 done
863 $(MSGCAT) -o $(DPO)/$(MANUAL).pot $(DPO)/$(MANUAL).pot
864
865 unwrap: nowrap
866
867 nowrap:
868 @$(call check_command,msgcat,gettext)
869 for XX in $(foreach LX, $(LANGPO), $(DPO)/$(LX).po); do \
870 $(MSGCAT) -o $$XX --no-wrap $$XX ;\
871 echo "I: $$XX FUZZY=$$(grep -e '^#,.*fuzzy' $$XX|wc -l) BLANK=$$(grep -e '^msgstr \"\"' $$XX|wc -l)" ;\
872 done
873 $(MSGCAT) -o $(DPO)/$(MANUAL).pot --no-wrap $(DPO)/$(MANUAL).pot
874
875 # remove obsolete
876 wrapx:
877 @$(call check_command,msgcat,gettext)
878 for XX in $(foreach LX, $(LANGPO), $(DPO)/$(LX).po); do \
879 $(MSGATTR) --no-obsolete -o $$XX $$XX ;\
880 done
881
882 # remove obsolete
883 nowrapx:
884 @$(call check_command,msgcat,gettext)
885 for XX in $(foreach LX, $(LANGPO), $(DPO)/$(LX).po); do \
886 $(MSGATTR) --no-wrap --no-obsolete -o $$XX $$XX ;\
887 done
888
889 # "make nowrap; make wrap" produces original good POs of "make po" but not for POT
890
891 # For global "sed" for RAWXMLs and POs, edit and use bin/sedxmlpo
892
893 # use sed to replace text with $(DBIN)/replace0
894 po-replace:
895 @$(call check_file,$(SEDF))
896 @$(call check_command,msgcat,gettext)
897 @$(call check_command,msguniq,gettext)
898 for XX in $(foreach LX, $(LANGPO), $(DPO)/$(LX).po); do \
899 $(MSGCAT) -o $$XX --no-wrap $$XX ;\
900 done
901 for XX in $(foreach LX, $(LANGPO), $(DPO)/$(LX).po); do \
902 cat $$XX >$$XX.sed ;\
903 $(SED) -f $(SEDF) <$$XX | sed -n -e '/^msgid "[^"]/,$$p' >>$$XX.sed ;\
904 $(MSGUNIQ) -o $$XX.uniq $$XX.sed ;\
905 done
906 for XX in $(foreach LX, $(LANGPO), $(DPO)/$(LX).po); do \
907 $(MSGCAT) -o $$XX $$XX.uniq ;\
908 done
909
910 po-wip:
911 @$(call check_command,msgattrib,gettext)
912 for XX in $(foreach LX, $(LANGPO), $(DPO)/$(LX).po); do \
913 $(MSGATTR) -o $$XX.fuzz --fuzzy $$XX ;\
914 $(MSGATTR) -o $$XX.untr --untranslated $$XX ;\
915 done
916
917 po-check:
918 # check for po file syntax such as "
919 @$(call check_command,msgcat,gettext)
920 for XX in $(foreach LX, $(LANGPO), $(DPO)/$(LX).po); do \
921 $(MSGCAT) $$XX >/dev/null ;\
922 done
923 # check for URL string with %
924 for XX in $(foreach LX, $(LANGPO), $(DPO)/$(LX).po); do \
925 $(MSGCAT) --no-wrap $$XX | grep -e '^msgstr "http.*%' || true ;\
926 done
927 # check for XML sanity in PO%
928 for XX in $(foreach LX, $(LANGPO), $(DPO)/$(LX).po); do \
929 $(DBIN)/xmlpo $$XX || true ;\
930 done
931
932 po-stat:
933 @$(call check_command,msgcat,gettext)
934 for XX in $(foreach LX, $(LANGPO), $(DPO)/$(LX).po); do \
935 echo "I: $$XX --> FUZZY+BLANK=$$($(MSGCAT) --no-wrap $$XX | grep -e '^#,.*fuzzy' -e '^msgstr \"\"' |wc -l)" ;\
936 done
937
938 #######################################################################
939 # $ make rsync
940 # export build result to http://people.debian.org/~osamu/$(MANUAL)/
941 #######################################################################
942 .PHONY: rsync
943 rsync: all
944 rsync -avz $(BUILD_DIR)/ [email protected]:public_html/$(MANUAL)/
945
946 #######################################################################
947 # $ make sbuild # check build in sbuld
948 #######################################################################
949 .PHONY: sbuild
950 # ~/.sbuildrc can be linked to ~/.sbuildrc-src or others
951 # Just use this to test build locally
952 sbuild:
953 # update chroot with my local command
954 echo "Did I run 'upu'?"
955 # build in chroot
956 sbuild
957 #######################################################################
958 # $ make dgit # upload with dgit
959 #######################################################################
960 .PHONY: dgit
961 # Source only upload as native package per dgit-maint-native(7)
962 # Local build results are irrerevant for upload
963 dgit:
964 dgit -wgf build-source
965 dgit -wgf push-source
966