[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[www-el-commits] www-el GNUmakefile
From: |
Georgios Zarkadas |
Subject: |
[www-el-commits] www-el GNUmakefile |
Date: |
Sun, 26 Apr 2015 22:56:16 +0000 |
CVSROOT: /cvsroot/www-el
Module name: www-el
Changes by: Georgios Zarkadas <gzarkadas> 15/04/26 22:56:16
Modified files:
. : GNUmakefile
Log message:
added path translators; enhanced report target
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/www-el/GNUmakefile?cvsroot=www-el&r1=1.27&r2=1.28
Patches:
Index: GNUmakefile
===================================================================
RCS file: /cvsroot/www-el/www-el/GNUmakefile,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- GNUmakefile 20 Apr 2015 19:10:53 -0000 1.27
+++ GNUmakefile 26 Apr 2015 22:56:15 -0000 1.28
@@ -45,12 +45,12 @@
SHELL = /bin/bash
# Set this variable to your language code.
-#
+
TEAM := el
# The relative or absolute path to the working copy of the master
# "www" repository; must end with a trailing slash.
-#
+
wwwdir := ../www/
## Binaries
@@ -80,60 +80,97 @@
# during the review process.
#
# If your team uses different subdirectories, adjust the list accordingly.
-#
+
excluded := $(addprefix -not -path ,\
- './server/gnun/compendia/*' './__*__/*' './incoming/*' \
- )
+ './server/gnun/compendia/*' './__*__/*' './incoming/*')
-# Functions to translate paths between team and www repositories files.
-# Use $(call <function name>,<filename>) in expansions, to use them.
-#
-www_po_path = $(addprefix $(wwwdir),$(dir $(1))po/$(notdir $(1)))
-www_pot_path = $(addprefix $(wwwdir),$(patsubst %.$(TEAM).po,%.pot,\
- $(dir $(1))po/$(notdir $(1)) ))
-team_po_path = $(subst $(wwwdir),,$(subst /po/,/, \
- $(dir $(1)))/$(notdir $(1)) ))
+# Functions to translate paths between team and www repositories files
+# in expansions; use $(call <function name>,<filename>).
-# Retrieve all existing-translations (we remove the leading ./)
-#
-translations := $(sort $(subst ./,, \
- $(shell find -name '*.$(TEAM).po' $(excluded)) \
- ))
-
-# Retrieve all existing-translations templates. May contain some
-# non-existent .pot files, if the templates have been deleted at
-# the $(wwwdir) repository. Retrieve existing and missing also.
-#
-#templates := $(subst /./,/, $(join \
-# $(addsuffix po/,$(addprefix $(wwwdir),$(dir $(translations)))), \
-# $(patsubst %.$(TEAM).po,%.pot,$(notdir $(translations))) \
-# ))
-templates := $(subst /./,/, \
- $(foreach f,$(translations),$(call www_pot_path,$(f))) \
- )
-existing_templates := $(wildcard $(templates))
-missing_templates := $(filter-out $(existing_templates),$(templates))
-
-# Retrieve all paths that store translations and templates in both
-# repositories (team and master). Note that sort removes duplicates,
-# so path lists and file lists are not the same.
-#
+# master translation <== team translation
+www_po_path = $(subst\
+ /./,/,$(addprefix $(wwwdir),$(dir $(1))po/$(notdir $(1))))
+
+# master template <== team translation
+www_pot_path = $(subst\
+ /./,/,$(addprefix $(wwwdir),$(patsubst\
+ %.$(TEAM).po,%.pot,$(dir $(1))po/$(notdir $(1)))))
+
+# team translation <== master translation / template
+team_po_path = $(patsubst\
+ %.pot,%.$(TEAM).po,$(subst $(wwwdir),,$(subst /po/,/,$(1))))
+
+# Defines to translate paths between team and www repositories files
+# in recipes (call function does *not* work properly there).
+
+define www_po_recipy
+`echo $$file | sed \
+ -e 's_^._$(wwwdir)&_' \
+ -e 's_\(^.*/\)\([^/]*$$\)_\1po/\2_'`
+endef
+
+define www_pot_recipy
+`echo $$file | sed \
+ -e 's_^._$(wwwdir)&_' \
+ -e 's_\(^.*/\)\([^/]*$$\)_\1po/\2_' \
+ -e 's_\.$(TEAM)\.po$$_.pot_'`
+endef
+
+define team_po_recipy
+`echo $$file | sed \
+ -e 's_/po/_/_' \
+ -e 's_^$(wwwdir)__' \
+ -e 's_\.pot$$_.$(TEAM).po_'`
+endef
+
+# All existing translations in team repository (leading ./ removed).
+
+translations := $(sort $(subst ./,,$(shell\
+ find -name '*.$(TEAM).po' $(excluded))))
+
+# All templates corresponding to existing translations
+# Separate them to existing and missing templates.
+
+templates := $(foreach f,$(translations),$(call www_pot_path,$(f)))
+exist_templates := $(wildcard $(templates))
+miss_templates := $(filter-out $(exist_templates),$(templates))
+
+# All translations in master corresponding to existing translations.
+# Separate them to existing and missing (master) translations.
+
+team_translations := $(foreach f,$(translations),$(call www_po_path,$(f)))
+exist_translations := $(wildcard $(team_translations))
+miss_translations := $(filter-out $(exist_translations),$(team_translations))
+
+# Translations without a template in master repository.
+
+obsolete_translations := $(foreach\
+ f,$(miss_templates),$(call team_po_path,$(f)))
+
+# All paths that store translations and templates in team / master
+# repositories. Note that sort removes duplicates, so path lists and
+# file lists are not the same.
+
+# team po-dirs
team_podirs := $(sort $(dir $(translations)))
-www_podirs := $(addprefix $(wwwdir),$(addsuffix /po,$(team_podirs)))
+# all master po-dirs
all_podirs := $(shell find $(wwwdir) -type d -name 'po')
+# master po-dirs with at least one translation
+www_podirs := $(addprefix $(wwwdir),$(addsuffix /po,$(team_podirs)))
+# master po-dirs without translations
miss_podirs := $(filter-out $(www_podirs),$(all_podirs))
# Retrieve all templates and team translations in the master repository.
# Then compute various sets useful for reporting targets.
-#
+
all_templates := $(wildcard $(addsuffix /*.pot,$(all_podirs)))
all_translations := $(wildcard $(addsuffix /*.$(TEAM).po,$(all_podirs)))
-team_translations := $(subst /./,/, \
- $(foreach f,$(translations),$(call www_po_path,$(f))) \
- )
+
+# Translations in master repository that do not exist in team repository.
+
unref_translations := $(filter-out $(team_translations),$(all_translations))
-unref_templates := $(filter-out $(existing_templates),$(all_templates))
-new_translations := $(filter-out $(all_translations),$(team_translations))
+
+todo_templates := $(filter-out $(exist_templates),$(all_templates))
## Messages and defines
@@ -161,31 +198,22 @@
update\' in $(wwwdir) needed).\n"
# Script to be created by publish target (commits all published .po files).
-commitfile := $(wwwdir)commit-pub
-# FIXME: this is too hack-ish; please improve
-# Mappings: . -> $ | _ -> ' | {\`} -> ` | {^ } -> \n
+commitfile := $(wwwdir)commit-pub
define commit_header
-#!/bin/sh^\
-# Auto-generated by team GNUmakefile^\
-# Commits currently published team po files^\
-^\
-cvs commit -m ".@" \`cat <<< _
-endef
-
-define commit_footer
-_ | tr _\n_ _ _\`
+$(file > $(commitfile),#!/bin/sh)
+$(file >> $(commitfile),# Auto-generated by team GNUmakefile)
+$(file >> $(commitfile),# Commits currently published team po files)
+$(file >> $(commitfile),)
+$(file >> $(commitfile),cvs commit -m "$$@" \)
endef
## Targets
-# Putting fuzdiff, obremove *after* the sync, gives us the option to use
-# their features locally, without storing our specialised po formats in
-# the repository (good for others which do not use our tools).
-# The inclusion of report, obreport targets is a mere convenience to keep
-# an eye in what needs to be fixed and what has changed in the POT files.
-#
+# Note that the loop variable in recipes *must* be 'file' else the
+# ..._recipy defines will not work as intended.
+
.PHONY: all
all: update sync
@@ -206,11 +234,11 @@
.PHONY: sync
sync: update
@for file in $(translations); do \
- if [ ! -f $(call www_pot_path,$$file) ]; then \
+ if [ ! -f $(www_pot_recipy) ]; then \
echo "Warning: $$file has no equivalent .pot in www."; \
else \
$(echofile) $(MSGMERGE) $(mmverbose) --quiet --update \
- --previous $$file $(call www_pot_path,$$file); \
+ --previous $$file $(www_pot_recipy); \
fi; \
done
ifeq ($(strip $(VCS)),yes)
@@ -229,13 +257,22 @@
# Helper target to check which articles have to be updated.
.PHONY: report
report:
+ @echo "Translations in master repository that are *not*" \
+ "included at the team's repository:"
+ @for file in $(unref_translations); do \
+ printf " %s\n" $$file ; \
+ done
+ @echo "Obsolete translations (template removed at master repository):"
+ @for file in $(obsolete_translations); do \
+ printf " %s\n" $$file ; \
+ done
@export tmpfile='' # protect previously set from rm
@for file in $(translations) ; do \
[ "$$tmpfile" = "" ] && tmpfile=`tempfile`; \
LC_ALL=C $(MSGFMT) --statistics -o /dev/null $$file 2>&1 \
- | egrep '(fuzzy|untranslated)' > $$tmpfile; \
- [ `< $$tmpfile wc --bytes` -eq 0 ] || printf '%-36s : %s\n' \
- "$${file#./}" "`sed 's/ [a-z]\+\(\.\|,\)/\1/g' $$tmpfile`"; \
+ | egrep '(fuzzy|untranslated)' >$$tmpfile; \
+ [ `wc --bytes <$$tmpfile` -eq 0 ] || printf '%-36s : %s\n' \
+ $$file "`sed 's/ [a-z]\+\([.,]\)/\1/g' $$tmpfile`" ; \
rm --force $$tmpfile; \
done
@@ -254,18 +291,15 @@
fuzdiff: format
@echo The fuzdiff target is not ready for production. Skipping...
# @for file in $(translations); do \
-# if [ -f $(wwwdir)`dirname $$file`/po/`basename \
-# $${file/.$(TEAM).po/.pot}` ]; then \
+# if [ -f $(www_pot_recipy) ]; then \
# $(VIEWFUZZY) --output=$$file $$file; \
# fi; \
# done
-# Code of awk scripts used in next two targets
-#
-rulebg := BEGIN{ RS=""; FS="\n"; ORS="\n\n"; OFS=FS }
-rulepr := NR > 1 { $$1=$$1; print }
-
# Helper target to report obsolete messages
+
+skiphead := 'BEGIN{RS="";FS="\n";ORS="\n\n";OFS=FS} NR>1{$$1=$$1;print}'
+
.PHONY: obreport
obreport:
@for file in $(translations); do \
@@ -274,8 +308,7 @@
echo "#### File: $$file"; \
echo "########################################################"; \
echo ; \
- $(MSGATTRIB) --only-obsolete $$file \
- | awk '$(rulebg) $(rulepr)'; \
+ $(MSGATTRIB) --only-obsolete $$file | awk $(skiphead) ; \
fi; \
done
@@ -287,22 +320,16 @@
$(translations)
# Helper target to copy all modified files to the `www' master repository.
-# A warning is printed if the corresponding directory in `www' cannot be
-# found, or if the template is missing (which in almost all cases means that
-# the original article has been renamed or deleted).
# An autocommit script - $(commitfile) - is also created to ease commiting
# in a single step (good for those reviewing the commit message).
-# Files are compared regarding content only, since file date may change
-# as a result of applying our tool-chain.
.PHONY: publish
publish: obremove format
@echo Copying edited .po files back to $(wwwdir):
- @cat <<< '$(commit_header)' | tr "._" "$$'" \
- | sed -e 's/\^ /\n/g' -e 's/\\`/`/g' > $(commitfile)
+ @$(commit_header)
@for file in $(translations); do \
- wwwfpot=$(call www_pot_path,$$file); \
+ wwwfpot=$(www_pot_recipy); \
wwwfdir=$(dir $$wwwfpot); \
- wwwfile=$(call www_po_path,$$file); \
+ wwwfile=$(www_po_recipy); \
if [ ! -d $$wwwfdir ]; then \
printf $(pubwmsg) "$$file" "directory $$wwwfdir"; \
continue; \
@@ -314,14 +341,12 @@
if [ -f $$wwwfile ] || [ "$(NEWPUB)" = "yes" ]; then \
if cp --archive --update $$file $$wwwfile; then \
echo " $$file"; \
- echo $(subst $(wwwdir),,$$file) >>$(commitfile) ; \
+ echo $$wwwfile "\" >>$(commitfile) ; \
else \
echo "ERROR: could not copy $$file to $$wwwfile"; \
fi; \
fi; \
done
- @cat <<< '$(commit_footer)' | tr "._" "$$'" \
- | sed -e 's/\^ /\n/g' -e 's/\\`/`/g' >> $(commitfile)
@chmod u+x $(commitfile)
# Helper target to delete common auto-generated files.
- [www-el-commits] www-el GNUmakefile,
Georgios Zarkadas <=