Subversion Repositories svn LFS-FR

Rev

Rev 8423 | Blame | Compare with Previous | Last modification | View Log | RSS feed

#!/usr/bin/make -f

# Use make L=... to build only a subset of the languages.

LANGUAGES := fr zh_CN
LANG_fr := fr_FR.UTF-8
LANG_zh_CN := zh_CN.UTF-8
UPLOAD_LANGUAGES := fr
L = all

# Use config.mk to configure username and password for download and upload
include config.mk

ORIGDIR := lfs-en

FR_REPO:=svn://svn.linuxfromscratch.org/fr-lfs
EN_REPO:=svn://svn.linuxfromscratch.org/LFS

RENDERTMP=~/tmp


# Note for releasing a new stable version:
# ----------------------------------------
#
# When a new stable version is released upstream, this Makefile will automatically
# track it, so translate it as usual. Once the stable version is translated,
# create a new branch that keeps tracking this release:
#
#   svn cp http://svn.linuxfromscratch.org/fr-lfs/trunk/lfs \
#          http://svn.linuxfromscratch.org/fr-lfs/branches/lfs-$(MILESTONE)
#
# Once this is done, you can publish the new version by running:
#
#   make release
#
# Then, update the MILESTONE to the next (unreleased) version of LFS in the
# development branch and commit.

# What we follow from upstream.
MILESTONE := 10.1

# Select the current version we are tracking from master
EN_CURR_VER := $(shell svn info $(ORIGDIR) | grep ^URL | sed 's|^[^s]*||')
REVISION := $(shell svn info $(ORIGDIR) | grep ^Revision | sed 's|^.* ||')

# If the version we are tracking is released, there should be a tag named $(MILESTONE).
# If this tag doesn't exist, it means the version is not released yet. Try to
# list files in this tag. If it succeeds, it exists, if it fails it doesn't
# exist. From that, choose what tag to follow: $(MILESTONE) or trunk.
TAG := $(shell (svn ls svn://svn.linuxfromscratch.org/LFS/tags/$(MILESTONE) --depth empty >/dev/null 2>&1 && printf $(MILESTONE)) || printf trunk)

# Depending on what we track, we choose the correct branch from upstream.
ifeq ($(TAG), trunk)
EN_VER := trunk/BOOK
else
EN_VER := tags/$(TAG)
endif

# echo is not portable acroos shells. Let's use printf.
ECHO:=printf

# Files that are needed for the build process once translations are generated.
filestocopy := INSTALL README process-scripts.sh obfuscate.sh pdf-fixups.sh \
               bootscripts udev-lfs aux-file-data.sh make-aux-files.sh
# Additional files that may require some changes.
filestoget := $(filestocopy) packages.ent tidy.conf patches.ent general.ent Makefile

# Use REV=sysv or REV=systemd to only build that version.
REV=all

ifeq ($(REV), all)
SYSV=1
SYSD=1
REVS=sysv systemd
else
ifeq ($(REV), systemd)
SYSV=
SYSD=1
REVS=systemd
else
SYSV=1
SYSD=
REVS=sysv
endif
endif

# The complete upstream URI we follow.
SVN_en := "$(EN_REPO)/$(EN_VER)"


IMAGES := $(shell find images -type f)
STYLESHEETS := $(shell find stylesheets -type f)
CSS := $(shell ls stylesheets/lfs-xsl/*.css)

CHUNK_QUIET = 1

.PHONY: svnup

# Don't delete intermediates (.po files).
.SECONDARY:

default:
        @echo 'Hi!'
        @echo 'To build the HTML documentation, please run `make genhtml`. For'
        @echo 'the PDF version, run `make genpdf`. For both run `make all`.'
        @echo 'Restrict to a subset of the available language with L=... and'
        @echo 'to a subset of the versions with REV=<sysv or systemd>.'
        @echo 'Good luck!'

all: genhtml genpdf
        @echo DONE

include include.mk

config.mk:
        @echo 'Hi!'
        @echo 'To use this Makefile, you will need a config.mk file, with your username'
        @echo 'and password in it. That is required for uploading to the lfs website.'
        @echo 'An example config.mk is simply:'
        @echo ''
        @echo 'USER:=my-user'
        @echo 'PRIVKEY:=~/.ssh/id_rsa'
        @echo 'USE_SSH_AGENT:=yes'
        @false

# So, if USE_SSH_AGENT = yes ...
ifeq ($(USE_SSH_AGENT), yes)
SSH_AGENT:=ssh-agent
else
SSH_AGENT:=
endif

init: $(ORIGDIR)

$(ORIGDIR):
        [ -d $@ ] || svn co $(SVN_en) $(ORIGDIR)/

# When updating, check that we still want to follow the checked-out branch.
# If not, remove it and check out the new branch.
svnup: init
        v=$$(svn info $(ORIGDIR) | grep ^URL | sed 's|^[^s]*||') ;\
        if [ "$$v" != "$(SVN_en)" ]; then \
                echo $$v ;\
                rm -rf $(ORIGDIR);\
                svn co $(SVN_en) $(ORIGDIR)/ >/dev/null;\
        else \
                if [ "$$(svn status -u $(ORIGDIR) | wc -l)" != "1" ]; then \
                        LANG=en_US.UTF-8 svn update $(ORIGDIR);\
                fi ;\
        fi

clean: clean-gen clean-product
        rm -rf $(ORIGDIR) include.mk

# include.mk contains most of the logic of the Makefile.
# We generate lists of XML files to translated, PO files that contain translations,
# images and stylesheet files, and the list of files to copy from the english repo.
#
# It also contains targets to build different html versions, to refresh the PO
# files and to generate the translated XML files. We need to use this target
# because the language in the name of the target and the file name are both
# wildcards, which cannot be used.
include.mk: include.in $(ORIGDIR) Makefile
        echo '# This file is generated by Makefile, please do not modify it directly.' > $@.tmp
        echo 'PO :=' >> $@.tmp
        for lang in $(LANGUAGES); do \
                sed -e "s|MLANG|$$lang|g" include.in >> $@.tmp;\
        done
        mv $@.tmp $@

clean-gen: $(addprefix clean-gen-,$(LANGUAGES))
clean-product: $(addprefix clean-product-,$(LANGUAGES))

ifeq ($(L),all)
L=$(LANGUAGES)
UPL=$(UPLOAD_LANGUAGES)
else
UPL=$(L)
endif

HTMLDEPS=
ifeq ($(SYSV),1)
HTMLDEPS+=$(addsuffix -sysv,$(addprefix genhtml-,$(L)))
endif
ifeq ($(SYSD),1)
HTMLDEPS+=$(addsuffix -sysd,$(addprefix genhtml-,$(L)))
endif

PDFDEPS=
ifeq ($(SYSV),1)
PDFDEPS+=$(addsuffix -sysv,$(addprefix genpdf-,$(L)))
endif
ifeq ($(SYSD),1)
PDFDEPS+=$(addsuffix -sysd,$(addprefix genpdf-,$(L)))
endif

TARDEPS=
ifeq ($(SYSV),1)
TARDEPS+=$(addsuffix -sysv,$(addprefix gentar-,$(L)))
endif
ifeq ($(SYSD),1)
TARDEPS+=$(addsuffix -sysd,$(addprefix gentar-,$(L)))
endif

EPUBDEPS=
ifeq ($(SYSV),1)
EPUBDEPS+=$(addsuffix -sysv,$(addprefix genepub-,$(L)))
endif
ifeq ($(SYSD),1)
EPUBDEPS+=$(addsuffix -sysd,$(addprefix genepub-,$(L)))
endif

UPDEPS=
ifeq ($(SYSV),1)
UPDEPS+=$(addsuffix -sysv,$(addprefix upload-,$(UPL)))
endif
ifeq ($(SYSD),1)
UPDEPS+=$(addsuffix -sysd,$(addprefix upload-,$(UPL)))
endif

genhtml: $(HTMLDEPS)
genpdf: $(PDFDEPS)
genepub: $(EPUBDEPS)
gentar: $(TARDEPS)

update: $(PO)
        $(ECHO) 'Done updating for $(TAG) \n'

pootle:
        pootle sync_stores --project=lfs
        $(MAKE) svnup
        $(MAKE) update
        python3 changelogtranslator.py $(L)
        pootle update_stores --project=lfs

ssh-agent:
        (ssh-add -l | grep $(PRIVKEY)) || \
        ssh-add $(PRIVKEY)

upload: $(UPDEPS)

release: $(SSH_AGENT) genhtml genpdf gentar genepub
        for lang in $(L); do \
                cd html-$$lang-systemd ;\
                rsync --progress --recursive * $(USER)@www.linuxfromscratch.org:/srv/www/www.$$lang.linuxfromscratch.org/view/lfs-$(MILESTONE)-systemd-$$lang/ ;\
                cd ../html-$$lang-sysv ;\
                rsync --progress --recursive * $(USER)@www.linuxfromscratch.org:/srv/www/www.$$lang.linuxfromscratch.org/view/lfs-$(MILESTONE)-$$lang/ ;\
                cd .. ;\
                rsync --progress LFS-$(MILESTONE)-$$lang.pdf $(USER)@www.linuxfromscratch.org:/srv/www/www.$$lang.linuxfromscratch.org/archives/LFS-$(MILESTONE)/ ;\
                rsync --progress LFS-$(MILESTONE)-$$lang-systemd.pdf $(USER)@www.linuxfromscratch.org:/srv/www/www.$$lang.linuxfromscratch.org/archives/LFS-$(MILESTONE)-systemd/ ;\
                rsync --progress LFS-$(MILESTONE)-$$lang-HTML.tar.bz2 $(USER)@www.linuxfromscratch.org:/srv/www/www.$$lang.linuxfromscratch.org/archives/LFS-$(MILESTONE)/ ;\
                rsync --progress LFS-$(MILESTONE)-systemd-$$lang-HTML.tar.bz2 $(USER)@www.linuxfromscratch.org:/srv/www/www.$$lang.linuxfromscratch.org/archives/LFS-$(MILESTONE)-systemd/ ;\
                rsync --progress LFS-$(MILESTONE)-$$lang.epub $(USER)@www.linuxfromscratch.org:/srv/www/www.$$lang.linuxfromscratch.org/archives/LFS-$(MILESTONE)/ ;\
                rsync --progress LFS-$(MILESTONE)-systemd-$$lang.epub $(USER)@www.linuxfromscratch.org:/srv/www/www.$$lang.linuxfromscratch.org/archives/LFS-$(MILESTONE)-systemd/ ;\
        done

commit: pootle
        svn commit -m 'Automatic LFS commit based on r$(REVISION)'

###############################################################################
# These files are not translated using po files. We use sed to modify them    #
# directly.                                                                   #
###############################################################################

##
## French translation of non po files
##

lfsgen-fr/general.ent: $(ORIGDIR)/general.ent
        mkdir -p lfsgen-fr
        sysv_date=$$(grep " version " $< | sed 's/.*"\([^"]\+\)".*/\1/');\
        sysd_date=$$(grep " versiond " $< | sed 's/.*"\([^"]\+\)".*/\1/');\
        date=$$(grep "releasedate" $< | sed 's/.*"\([^"]\+\)".*/\1/');\
        frdate=$$(LANG=$(LANG_fr) date -d "$$(echo $${date} | sed 's|1st|1|')" "+%d %B %Y");\
        sed -e "s/$$date/$$frdate/g"\
            -e "s/Approximate build time/Temps de construction approximatif/g"\
            -e "s/Required disk space/Espace disque requis/g"\
            -e "s/Installation depends on/L'installation dépend de/g"\
            -e "s/Test suite depends on/La suite de tests dépend de/g"\
            -e "s/Must be installed before/Doit être installé avant/g"\
            -e "s/Optional dependencies/Dépendances facultatives/g"\
            -e "s|&lfs-root;blfs/|http://fr.linuxfromscratch.org/blfs|g"\
            -e "s|&lfs-root;faq/|http://fr.linuxfromscratch.org/faq|g"\
            -e "s|&blfs-root;view/|\&blfs-root;/../view/blfs-|g"\
            -e "s|&lfs-root;hints/downloads/files/|http://fr.linuxfromscratch.org/view/astuces/|g"\
            $< > $@

lfsgen-fr/packages.ent: $(ORIGDIR)/packages.ent
        mkdir -p lfsgen-fr
        sed -e "s/KB/Ko/g" -e "s/MB/Mo/g" -e "s/GB/Go/g"\
            -e "s/less than/moins de/g"\
            -e "s/typically about/en général environ/g"\
            -e "s/about/environ/g"\
            -e "s/with tests/avec les tests/g"\
            $< > $@

lfsgen-fr/patches.ent: $(ORIGDIR)/patches.ent
        mkdir -p lfsgen-fr
        sed -e "s/KB/Ko/g" \
            $< > $@

lfsgen-fr/tidy.conf: $(ORIGDIR)/tidy.conf
        mkdir -p lfsgen-fr
        sed -e "s/latin1/UTF8/g" \
            $< > $@

lfsgen-fr/Makefile: $(ORIGDIR)/Makefile lfsgen-fr/epub.mk
        mkdir -p lfsgen-fr
        sed -e '/&copy;/d' -e 's|book:|include epub.mk\nbook:|' $< > $@

lfsgen-fr/epub.mk: epub.mk
        mkdir -p lfsgen-fr
        cp $< $@