| 1 |
#######################################################################
|
| 2 |
# Build debian-reference (v2)
|
| 3 |
# vim: set ts=8:
|
| 4 |
#######################################################################
|
| 5 |
### basic parameters (build condition dependent) ALL
|
| 6 |
#######################################################################
|
| 7 |
BUILD_MODE := xml
|
| 8 |
# parent dir name of the SVN source checkout location
|
| 9 |
# make[1]: Entering directory `/org/www.debian.org/ddp-svn/trunk/quick-reference'
|
| 10 |
PDIR := $(notdir $(realpath $(CURDIR)/../..))
|
| 11 |
ifeq ($(PDIR),ddp-svn)
|
| 12 |
# Building www.debian.org
|
| 13 |
# $(PUBLISHDIR) is set to be: /org/www.debian.org/www/doc/manuals
|
| 14 |
DRPUBLISHDIR := $(PUBLISHDIR)/debian-reference
|
| 15 |
else
|
| 16 |
# Normally
|
| 17 |
# if $(PUBLISHDIR) is not set, set it
|
| 18 |
PUBLISHDIR := $(CURDIR)/html
|
| 19 |
DRPUBLISHDIR := $(PUBLISHDIR)
|
| 20 |
endif
|
| 21 |
|
| 22 |
# Please note package build script overides $(PUBLISHDIR)
|
| 23 |
|
| 24 |
#######################################################################
|
| 25 |
### basic parameters (build condition independent) ALL
|
| 26 |
#######################################################################
|
| 27 |
# base file name excluding file extension
|
| 28 |
DOCNAME := debian-reference
|
| 29 |
# Directories (no trailing slash)
|
| 30 |
PXSLT := xslt
|
| 31 |
PBIN := bin
|
| 32 |
ADOC := asciidoc
|
| 33 |
PODOC := po4a
|
| 34 |
IMAGES := /usr/share/xml/docbook/stylesheet/nwalsh/images
|
| 35 |
# Program name and option
|
| 36 |
XP := xsltproc --nonet --novalid --xinclude
|
| 37 |
#XL := xmllint --nonet --noout --postvalid --xinclude
|
| 38 |
# The threshold should be 80 if translation is completed.
|
| 39 |
THRESHOLD:= 0
|
| 40 |
TRANSLATE:= po4a-translate -M utf-8 --format docbook --keep $(THRESHOLD)
|
| 41 |
GETTEXT := po4a-gettextize -M utf-8 -L utf-8 --format docbook
|
| 42 |
UPDATEPO:= msgmerge --update --previous
|
| 43 |
# # note: the URL is used as identifier, no HTTP is used!
|
| 44 |
# DOCBOOK_XSL=http://docbook.sourceforge.net/release/xsl/current
|
| 45 |
VERBOSE :=
|
| 46 |
# Debian packge archive URL
|
| 47 |
#DEBM := http://ftp.us.debian.org/debian/dists
|
| 48 |
DEBM := http://ftp.jp.debian.org/debian/dists
|
| 49 |
# Debian popcon data source URL
|
| 50 |
UPOPC := http://popcon.debian.org/all-popcon-results.txt.gz
|
| 51 |
# Debian release name and arch used
|
| 52 |
CODE := sid
|
| 53 |
ARCH := amd64
|
| 54 |
UDEBA := $(DEBM)/$(CODE)
|
| 55 |
# language defaults
|
| 56 |
LANGALL := en ja fr it es de pt-br pl zh-tw zh-cn
|
| 57 |
LANGPO := ja
|
| 58 |
LANGNEW :=
|
| 59 |
LANGSGML = $(filter-out en $(LANGPO), $(LANGALL))
|
| 60 |
|
| 61 |
# AsciiDoc source files in $(ADOC) directories
|
| 62 |
ASCSRC := 00_preface.txt 01_tutorial.txt 02_package.txt \
|
| 63 |
03_sysinit.txt 04_auth.txt 05_network.txt 06_netapp.txt \
|
| 64 |
07_xwindow.txt 08_i18nl10ntxt 09_systips.txt 10_datamngt.txt \
|
| 65 |
11_dataconv.txt 12_program.txt 99_appendix.txt \
|
| 66 |
copyright.txt header.txt $(DOCNAME).txt
|
| 67 |
# source files (local update requires these)
|
| 68 |
ASCSRCS := $(addprefix $(ADOC)/, $(ASCSRC))
|
| 69 |
RAWSRCS := $(DOCNAME).raw.xml all-popcon-results.txt packages.txt
|
| 70 |
# source files (build prcess requires these)
|
| 71 |
ENTSRCS := urls.ent datadatepop.ent datadatesize.ent popcon.ent pkgsize.ent common.ent
|
| 72 |
XMLSRCS = $(DOCNAME).en.xml $(addsuffix .po, $(addprefix $(PODOC)/$(DOCNAME)., $(LANGPO))) $(ENTSRCS)
|
| 73 |
|
| 74 |
#########################################################################
|
| 75 |
# Local raw XML files and base data created from asciidoc in lenny LOCAL
|
| 76 |
#########################################################################
|
| 77 |
#=======================================================================#
|
| 78 |
ifeq ($(BUILD_MODE),asciidoc)
|
| 79 |
#=======================================================================#
|
| 80 |
|
| 81 |
.SECONDARY: $(XMLSRCS)
|
| 82 |
|
| 83 |
# -----------------------------------------------------------------------
|
| 84 |
# This is cleaned after "make clean"
|
| 85 |
# create a raw XML source from asciidoc source
|
| 86 |
$(DOCNAME).raw.xml: $(ASCSRCS)
|
| 87 |
asciidoc -a 'newline=\n' -b docbook -d book -o - $(ADOC)/$(DOCNAME).txt |\
|
| 88 |
sed -e "/<\/authorinitials>/r $(ADOC)/copyright.txt" |\
|
| 89 |
xmllint --format - > $@
|
| 90 |
|
| 91 |
# -----------------------------------------------------------------------
|
| 92 |
# Remotely fetched files prior to the build after "make distclean"
|
| 93 |
# These are cleaned after "make clean"
|
| 94 |
# These will not be a part of source except datadate{pop|size}.ent
|
| 95 |
# datadate{pop|size}.ent are generated as secondary side effects
|
| 96 |
|
| 97 |
all-popcon-results.txt:
|
| 98 |
wget -O - $(UPOPC) | zcat - > all-popcon-results.txt
|
| 99 |
echo "<!ENTITY pop-date \"$(shell date -u +'%F %T %Z')\">" > datadatepop.ent
|
| 100 |
|
| 101 |
packages.txt:
|
| 102 |
wget -O - $(UDEBA)/main/binary-$(ARCH)/Packages.bz2 | bzcat - > packages.main.tmp
|
| 103 |
grep-dctrl -e -sPackage,Installed-Size -P "." packages.main.tmp > packages.main
|
| 104 |
rm packages.main.tmp
|
| 105 |
wget -O - $(UDEBA)/contrib/binary-$(ARCH)/Packages.bz2 | bzcat - > packages.contrib.tmp
|
| 106 |
grep-dctrl -e -sPackage,Installed-Size -P "." packages.contrib.tmp > packages.contrib
|
| 107 |
rm packages.contrib.tmp
|
| 108 |
wget -O - $(UDEBA)/non-free/binary-$(ARCH)/Packages.bz2 | bzcat - > packages.non-free.tmp
|
| 109 |
grep-dctrl -e -sPackage,Installed-Size -P "." packages.non-free.tmp > packages.non-free
|
| 110 |
rm packages.non-free.tmp
|
| 111 |
#sync
|
| 112 |
#sleep 1
|
| 113 |
cat packages.main packages.contrib packages.non-free >$@
|
| 114 |
#
|
| 115 |
echo "<!ENTITY all-packages \"$$(grep -e '^Package:' packages.txt | wc -l)\">" > datadatesize.ent
|
| 116 |
echo "<!ENTITY main-packages \"$$( grep -e '^Package:' packages.main | wc -l)\">" >> datadatesize.ent
|
| 117 |
echo "<!ENTITY contrib-packages \"$$(grep -e '^Package:' packages.contrib | wc -l)\">" >> datadatesize.ent
|
| 118 |
echo "<!ENTITY non-free-packages \"$$(grep -e '^Package:' packages.non-free | wc -l)\">" >> datadatesize.ent
|
| 119 |
echo "<!ENTITY pkgsize-date \"$(shell date -u +'%F %T %Z')\">" >> datadatesize.ent
|
| 120 |
rm packages.main packages.contrib packages.non-free
|
| 121 |
|
| 122 |
# trick to allow building source w/o all-popcon-results.txt
|
| 123 |
datadatepop.ent:
|
| 124 |
$(MAKE) all-popcon-results.txt
|
| 125 |
|
| 126 |
# trick to allow building source w/o packages.txt
|
| 127 |
datadatesize.ent:
|
| 128 |
$(MAKE) packages.txt
|
| 129 |
|
| 130 |
# trick to allow building source w/o all-popcon-results.txt and pkg.lst
|
| 131 |
popcon.ent:
|
| 132 |
if ! [ -f all-popcon-results.txt ]; then $(MAKE) all-popcon-results.txt ; fi
|
| 133 |
if ! [ -f pkg.lst ]; then $(MAKE) pkg.lst ; fi
|
| 134 |
echo "<!ENTITY pop-submissions \"$(shell sed -n -e 's/^Submissions: *\([^ ]*\) *$$/\1/p' < all-popcon-results.txt)\">" > $@
|
| 135 |
echo "<!ENTITY pop-architectures \"$(shell grep -e '^Architecture:' all-popcon-results.txt | wc -l)\">" >> $@
|
| 136 |
echo "<!ENTITY pop-packages \"$(shell grep -e '^Package:' all-popcon-results.txt | wc -l)\">" >> $@
|
| 137 |
TOTAL=$(shell sed -n -e 's/^Submissions: *\([^ ]*\) *$$/\1/p' < all-popcon-results.txt) ;\
|
| 138 |
grep -e '^Package:' all-popcon-results.txt | grep -f pkg.lst | $(PBIN)/popconent $$TOTAL >> $@
|
| 139 |
|
| 140 |
# trick to allow building source w/o packages.txt and pkg.lst
|
| 141 |
pkgsize.ent:
|
| 142 |
if ! [ -f packages.txt ]; then $(MAKE) packages.txt ; fi
|
| 143 |
if ! [ -f pkg.lst ]; then $(MAKE) pkg.lst ; fi
|
| 144 |
$(PBIN)/sizeent packages.txt < pkg.lst > $@
|
| 145 |
|
| 146 |
# change if there have been some change in source
|
| 147 |
common.ent: $(filter-out common.ent, $(XMLSRCS))
|
| 148 |
echo "<!ENTITY build-date \"$(shell date -u +'%F %T %Z')\">" > $@
|
| 149 |
echo "<!ENTITY arch \"$(ARCH)\">" >> $@
|
| 150 |
echo "<!ENTITY codename-stable \"lenny\">" >> $@
|
| 151 |
echo "<!ENTITY codename-testing \"squeeze\">" >> $@
|
| 152 |
echo "<!ENTITY codename-nexttesting \"squeeze+1\">" >> $@
|
| 153 |
echo "<!ENTITY codename-unstable \"sid\">" >> $@
|
| 154 |
|
| 155 |
# -----------------------------------------------------------------------
|
| 156 |
# Create final XML sources
|
| 157 |
# This is not cleaned after "make clean" but cleaned by "make distclean"
|
| 158 |
|
| 159 |
# replace table contents with @@@popcon*@@@ and @@@psize*@@@ and
|
| 160 |
# fix URL referencees and table ID.
|
| 161 |
$(DOCNAME).en.xml: $(DOCNAME).raw.xml $(ADOC)/header.txt
|
| 162 |
# $$ in following becomes $ under make: 5.0.2 -> 5.0
|
| 163 |
if [ $$(sed -n "s/^\([^.]*\.[^.]*\).*$$/\1/p" < /etc/debian_version) != "5.0" ]; then \
|
| 164 |
echo "You must be running lenny">&2 ; exit 1 ; fi
|
| 165 |
# use asciidoc generated xml file as main contents
|
| 166 |
xsltproc --novalid $(VERBOSE) $(PXSLT)/table.xsl $(DOCNAME).raw.xml |\
|
| 167 |
$(PBIN)/colspec.py |\
|
| 168 |
sed -e '/<!DOCTYPE /d' -e "1r $(ADOC)/header.txt" |\
|
| 169 |
sed -f bin/replace > $@
|
| 170 |
|
| 171 |
# trick to allow building source w/o regenerating urls.ent unneededly
|
| 172 |
urls.ent: $(ASCSRCS)
|
| 173 |
# $$ in following becomes $ under make: 5.0.2 -> 5.0
|
| 174 |
if [ $$(sed -n "s/^\([^.]*\.[^.]*\).*$$/\1/p" < /etc/debian_version) != "5.0" ]; then \
|
| 175 |
echo "You must be running lenny">&2 ; exit 1 ; fi
|
| 176 |
if ! [ -f $(DOCNAME).raw.xml ]; then $(MAKE) $(DOCNAME).raw.xml ; fi
|
| 177 |
xsltproc --novalid $(VERBOSE) $(PXSLT)/urls.xsl $(DOCNAME).raw.xml | sort | uniq | sed -f bin/replace > $@
|
| 178 |
|
| 179 |
# package name list for popcon and size ent file generation
|
| 180 |
# This file is not part of source
|
| 181 |
pkg.lst: $(DOCNAME).raw.xml
|
| 182 |
xsltproc --novalid $(VERBOSE) $(PXSLT)/pkg.xsl $< > $@
|
| 183 |
|
| 184 |
|
| 185 |
#=======================================================================#
|
| 186 |
else
|
| 187 |
#=======================================================================#
|
| 188 |
# To avoid circular dependency
|
| 189 |
$(DOCNAME).en.xml:
|
| 190 |
echo "You need to run \"make xml\" in lenny environment"
|
| 191 |
exit
|
| 192 |
|
| 193 |
#=======================================================================#
|
| 194 |
endif
|
| 195 |
#=======================================================================#
|
| 196 |
|
| 197 |
#########################################################################
|
| 198 |
# POT/PO file operations LOCAL
|
| 199 |
#########################################################################
|
| 200 |
# Create new POT file in $(PODOC) matching $(DOCNAME).en.xml
|
| 201 |
.PHONY: pot
|
| 202 |
pot: $(PODOC)/$(DOCNAME).pot
|
| 203 |
$(PODOC)/$(DOCNAME).pot: $(DOCNAME).en.xml
|
| 204 |
$(GETTEXT) -m $(DOCNAME).en.xml -p $(PODOC)/$(DOCNAME).pot
|
| 205 |
|
| 206 |
# Update new PO file in $(PODOC) by POT file
|
| 207 |
$(PODOC)/$(DOCNAME).%.po: $(PODOC)/$(DOCNAME).pot
|
| 208 |
$(UPDATEPO) $(PODOC)/$(DOCNAME).$*.po $(PODOC)/$(DOCNAME).pot
|
| 209 |
|
| 210 |
# Update new PO file in $(PODOC) by POT file for English typo fix
|
| 211 |
.PHONY: typo
|
| 212 |
typo:
|
| 213 |
-rm -f $(PODOC)/$(DOCNAME).pot.old
|
| 214 |
cp $(PODOC)/$(DOCNAME).pot $(PODOC)/$(DOCNAME).pot.old
|
| 215 |
$(MAKE) BUILD_MODE=asciidoc $(DOCNAME).en.xml
|
| 216 |
$(GETTEXT) -m $(DOCNAME).en.xml -p $(PODOC)/$(DOCNAME).pot
|
| 217 |
# repeat for all languages
|
| 218 |
for $$xx in $(LANGPO) ; do \
|
| 219 |
msguntypot -o $(PODOC)/$(DOCNAME).pot.old -n $(PODOC)/$(DOCNAME).pot $(PODOC)/$(DOCNAME).$$xx.po ;\
|
| 220 |
done
|
| 221 |
|
| 222 |
#########################################################################
|
| 223 |
# Translate XML files ALL
|
| 224 |
#########################################################################
|
| 225 |
$(DOCNAME).%.xml: $(PODOC)/$(DOCNAME).%.po $(DOCNAME).en.xml
|
| 226 |
$(TRANSLATE) -m $(DOCNAME).en.xml -p $(PODOC)/$(DOCNAME).$*.po -l $(DOCNAME).$*.xml
|
| 227 |
|
| 228 |
#########################################################################
|
| 229 |
# Create HTML files ALL
|
| 230 |
#########################################################################
|
| 231 |
.PHONY: css
|
| 232 |
css:
|
| 233 |
-rm -rf $(DRPUBLISHDIR)/images
|
| 234 |
mkdir -p $(DRPUBLISHDIR)/images
|
| 235 |
cp -f $(PXSLT)/$(DOCNAME).css $(DRPUBLISHDIR)/$(DOCNAME).css
|
| 236 |
cd $(IMAGES) ; cp caution.png home.gif important.png next.gif note.png prev.gif tip.png up.gif warning.png $(DRPUBLISHDIR)/images
|
| 237 |
|
| 238 |
.PHONY: html
|
| 239 |
html: $(foreach lang, en $(LANGPO), $(DRPUBLISHDIR)/$(DOCNAME).$(lang).html) $(foreach lang, en $(LANGPO), $(DRPUBLISHDIR)/index.$(lang).html)
|
| 240 |
|
| 241 |
$(DRPUBLISHDIR)/$(DOCNAME).%.html: $(DOCNAME).%.xml $(ENTSRCS)
|
| 242 |
$(XP) --stringparam root.filename $(DOCNAME) \
|
| 243 |
--stringparam base.dir $(DRPUBLISHDIR)/ \
|
| 244 |
--stringparam html.ext .$*.html \
|
| 245 |
--stringparam admon.graphics 0 \
|
| 246 |
--stringparam callout.graphics 0 \
|
| 247 |
--stringparam navig.graphics 0 \
|
| 248 |
--stringparam html.stylesheet $(DOCNAME).css \
|
| 249 |
xslt/style-onehtml.xsl $<
|
| 250 |
|
| 251 |
$(DRPUBLISHDIR)/index.%.html: $(DOCNAME).%.xml $(ENTSRCS)
|
| 252 |
$(XP) --stringparam root.filename index \
|
| 253 |
--stringparam base.dir $(DRPUBLISHDIR)/ \
|
| 254 |
--stringparam html.ext .$*.html \
|
| 255 |
--stringparam html.stylesheet $(DOCNAME).css \
|
| 256 |
xslt/style-html.xsl $<
|
| 257 |
|
| 258 |
.PHONY: txt
|
| 259 |
txt: $(foreach lang, en $(LANGPO), $(DRPUBLISHDIR)/$(DOCNAME).$(lang).txt)
|
| 260 |
# Build rule for TXT (non-English)
|
| 261 |
# # (UTF-8 compatibility of debiandoc2text is limitted)
|
| 262 |
$(DRPUBLISHDIR)/$(DOCNAME).%.txt: $(DRPUBLISHDIR)/$(DOCNAME).%.html
|
| 263 |
LC_ALL=en_US.UTF-8 w3m -dump -cols 65 -T text/html $(DRPUBLISHDIR)/$(DOCNAME).$*.html >$@
|
| 264 |
|
| 265 |
|
| 266 |
#########################################################################
|
| 267 |
# Utility targets ALL
|
| 268 |
#########################################################################
|
| 269 |
# Replicate
|
| 270 |
REMOTE := people.debian.org:public_html/pub/po4a/
|
| 271 |
|
| 272 |
.PHONY: rsync
|
| 273 |
rsync:
|
| 274 |
rsync --exclude=all-popcon-results.txt --exclude=packages.txt --exclude=pkg.lst --exclude="debian-reference.*.xml" \
|
| 275 |
-rpt --delete-after . $(REMOTE)
|
| 276 |
# somehow rsync does 700, fixit
|
| 277 |
ssh people.debian.org "chmod ugo+rX public_html/pub/po4a"
|
| 278 |
|
| 279 |
.PHONY: url-check
|
| 280 |
# sanity check for url
|
| 281 |
url-check: urls.lst
|
| 282 |
@echo "----- Duplicate URL references (start) -----"
|
| 283 |
-sed -ne "s/<\!ENTITY \([^ ]*\) .*$$/\" \1 \"/p" < $< | uniq -d | xargs -n 1 grep $< -e
|
| 284 |
@echo "----- Duplicate URL references (end) -----"
|
| 285 |
@echo "----- URL check (start) -----"
|
| 286 |
@sed -ne "s/<\!ENTITY [^ ]* \"\(.*\)\">$$/\"\1\"/p" < $< | uniq | xargs -n 1 wget -O /dev/null -nv
|
| 287 |
@echo "----- URL check (end) -----"
|
| 288 |
|
| 289 |
#######################################################################
|
| 290 |
# Update source using remotely fetched data ALL
|
| 291 |
#######################################################################
|
| 292 |
.PHONY: update
|
| 293 |
update:
|
| 294 |
$(MAKE) distclean
|
| 295 |
$(MAKE) xml
|
| 296 |
$(MAKE) clean
|
| 297 |
|
| 298 |
#######################################################################
|
| 299 |
# Build html for web (DDP or alioth) ALL
|
| 300 |
#######################################################################
|
| 301 |
.PHONY: publish
|
| 302 |
|
| 303 |
publish:
|
| 304 |
-mkdir -p $(DRPUBLISHDIR)
|
| 305 |
# -rm -rf $(DRPUBLISHDIR)/debian-reference
|
| 306 |
-rm -f $(PUBLISHDIR)/reference
|
| 307 |
-ln -sf $(DRPUBLISHDIR) $(PUBLISHDIR)/reference
|
| 308 |
$(MAKE) html txt css PUBLISHDIR=$(PUBLISHDIR) "LANGPO=$(LANGPO)"
|
| 309 |
$(MAKE) -C sgml all PUBLISHDIR=$(DRPUBLISHDIR) "LANG_ALL=$(LANGSGML)"
|
| 310 |
# ls -lR $(PUBLISHDIR)
|
| 311 |
|
| 312 |
#######################################################################
|
| 313 |
# Build xml/html for testing source (local) ALL
|
| 314 |
#######################################################################
|
| 315 |
.PHONY: xml
|
| 316 |
xml:
|
| 317 |
# making sure to rebuild all
|
| 318 |
touch asciidoc/00_preface.txt
|
| 319 |
$(MAKE) BUILD_MODE=asciidoc $(XMLSRCS) "LANGPO=$(LANGPO)"
|
| 320 |
|
| 321 |
.PHONY: all
|
| 322 |
all:
|
| 323 |
# making sure to rebuild all
|
| 324 |
touch asciidoc/00_preface.txt
|
| 325 |
$(MAKE) BUILD_MODE=asciidoc html txt css "LANGPO=$(LANGPO)"
|
| 326 |
$(MAKE) -C sgml all PUBLISHDIR=$(DRPUBLISHDIR) "LANG_ALL=$(LANGSGML)"
|
| 327 |
# # skip if DDP
|
| 328 |
# export HTMLROOT=$(PUBLISHDIR) ; bin/mkindexhtml
|
| 329 |
# if [ $$USER = "osamu" ]; then $(MAKE) rsync ; fi
|
| 330 |
|
| 331 |
#######################################################################
|
| 332 |
# Clean targets ALL
|
| 333 |
#######################################################################
|
| 334 |
.PHONY: clean distclean
|
| 335 |
|
| 336 |
clean:
|
| 337 |
-rm -f *.swp *~ *.tmp
|
| 338 |
-rm -rf html
|
| 339 |
-rm -f $(PODOC)/*~
|
| 340 |
ifneq ($(PDIR),ddp-svn)
|
| 341 |
-rm -f all-popcon-results.txt packages.txt pkg.lst
|
| 342 |
-rm -f $(addsuffix .xml, $(addprefix $(DOCNAME)., $(LANGPO)))
|
| 343 |
-rm -f $(DOCNAME).raw.xml
|
| 344 |
$(MAKE) -C sgml clean "LANG_ALL=$(LANGSGML)" PUBLISHDIR=$(DRPUBLISHDIR)
|
| 345 |
endif
|
| 346 |
|
| 347 |
distclean: clean
|
| 348 |
-rm -f *.html
|
| 349 |
-rm -f $(ENTSRCS)
|
| 350 |
ifeq ($(PDIR),ddp-svn)
|
| 351 |
-rm -f all-popcon-results.txt packages.txt pkg.lst
|
| 352 |
-rm -f $(DOCNAME).*.xml
|
| 353 |
$(MAKE) -C sgml distclean "LANG_ALL=$(LANGSGML)" PUBLISHDIR=$(DRPUBLISHDIR)
|
| 354 |
endif
|
| 355 |
|