[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[www-el-commits] www-el GNUmakefile __make__/help __make__/vcs.m...
From: |
Georgios Zarkadas |
Subject: |
[www-el-commits] www-el GNUmakefile __make__/help __make__/vcs.m... |
Date: |
Mon, 20 Apr 2015 19:10:54 +0000 |
CVSROOT: /cvsroot/www-el
Module name: www-el
Changes by: Georgios Zarkadas <gzarkadas> 15/04/20 19:10:54
Modified files:
. : GNUmakefile
Added files:
__make__ : help vcs.mk obsolete-remove
Log message:
reshaping makefile; alpha versions (beware)
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/www-el/GNUmakefile?cvsroot=www-el&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/www-el/__make__/help?cvsroot=www-el&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/www-el/__make__/vcs.mk?cvsroot=www-el&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/www-el/__make__/obsolete-remove?cvsroot=www-el&rev=1.1
Patches:
Index: GNUmakefile
===================================================================
RCS file: /cvsroot/www-el/www-el/GNUmakefile,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- GNUmakefile 27 Jan 2012 00:28:56 -0000 1.26
+++ GNUmakefile 20 Apr 2015 19:10:53 -0000 1.27
@@ -16,6 +16,15 @@
# You should have received a copy of the GNU General Public License
# along with GNUnited Nations. If not, see <http://www.gnu.org/licenses/>.
+#### NOTE: ############
+# Changes to the original GNUN release of this file are:
+# Copyright (C) 2012, 2015 Georgios M. Zarkadas <gz at member.fsf.org>
+#
+# Changes are provided under the same licence: GNU GPL, version 3 of the
+# Licence, or (at your option) any later version. However, at the moment
+# no transfer of copyright to FSF has been made; beware, if considering
+# for inclusion to official GNU packages.
+
########################################################################
### TRANSLATORS: Rename this file as GNUmakefile and install it in the #
### root of your project's *Sources* repository. For details, see the #
@@ -28,8 +37,10 @@
# CVS
# Subversion (if the www-LANG repository is SVN)
# GNU Bzr (if the www-LANG repository is Bzr)
+# Git (if the www-LANG repository is Git)
# Mercurial (if the www-LANG repository is Hg)
# GNU Arch (if the www-LANG repository is Arch)
+# The tools and makefiles inside __make__ subdirectory
SHELL = /bin/bash
@@ -50,13 +61,6 @@
MSGCAT := msgcat
MSGATTRIB := msgattrib
MSGUNIQ := msguniq
-CVS := cvs
-SVN := svn
-GIT := git
-BZR := bzr
-HG := hg
-# Baz can be used alternatively; its commands are compatible.
-TLA := tla
VIEWFUZZY := view-fuzzy -h b -g8 --merge
# Put as a variable to ease those preferring trash.
# Better use it only for files inside the repository; use rm for temp files.
@@ -65,168 +69,96 @@
## Paths and Files
-# Paths to exclude from search (for example tools or test sub-directories).
-# Space separated list of {-not -path <path wildcard>} items.
+# Paths to exclude from search: expands to a space separated list of
+# {-not -path <path wildcard>} items. Currently, those paths are:
#
-excluded := -not -path './__tools__/*' -not -path './incoming/*'
-
-# Retrieve all translations
-translations := $(shell find -name '*.$(TEAM).po' $(excluded) | sort)
-
-# Retrieve all translations templates
-templates := $(join $(join $(join $(wwwdir),$(dir
$(translations))),po/),$(patsubst %.$(TEAM).po,%.pot,$(notdir $(translations))))
-
-# Obsolete translations storage catalog.
-obcatalog := __tools__/deleted.el.po
-
-## Messages
-
-# Warning message for the `publish' rule.
-pubwmsg := "Warning (%s): %s\n does not exist; (either obsolete or \`cvs\
-update\' in $(wwwdir) needed).\n"
-
-# Vcs auto-commit log message
-log := "Automatic merge from the master repository."
-
-# no-commit info message
-noupdmsg := 'Repositories were not updated, you might want "make VCS=yes".'
-
-## VCS-related staff
-
-# We record UTC time with second accuracy to allow correct operation of tags
-# even when multiple syncs per day are performed from multiple users.
-
-lastrun := $(shell date --rfc-3339=seconds | tr ' +' '__' | tr -d ':')
-runtag := $(join status_,$(lastrun))
+# 1. GNUN compendia (they have both a different path convention and
+# different update rules; update those manually).
+# 2. Team-specific tools subdirectories (named __<name>__ for easy
+# visual differentiation).
+# 3. Team-specific subdirectory for processing incoming translations
+# during the review process.
+#
+# If your team uses different subdirectories, adjust the list accordingly.
+#
+excluded := $(addprefix -not -path ,\
+ './server/gnun/compendia/*' './__*__/*' './incoming/*' \
+ )
-# Determine the VCS and relevant update/commit commands.
+# 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)) ))
-repo := $(shell (test -d CVS && echo CVS) || (test -d .svn && echo SVN) \
- || (test -d .bzr && echo Bzr) || (test -d .hg && echo Hg) \
- || (test -d .git && echo Git) || (test -d \{arch\} && echo Arch))
-ifndef repo
-$(error Unsupported Version Control System)
-endif
+# 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.
+#
+team_podirs := $(sort $(dir $(translations)))
+www_podirs := $(addprefix $(wwwdir),$(addsuffix /po,$(team_podirs)))
+all_podirs := $(shell find $(wwwdir) -type d -name 'po')
+miss_podirs := $(filter-out $(www_podirs),$(all_podirs))
-# For those who love details.
+# 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))) \
+ )
+unref_translations := $(filter-out $(team_translations),$(all_translations))
+unref_templates := $(filter-out $(existing_templates),$(all_templates))
+new_translations := $(filter-out $(all_translations),$(team_translations))
+
+## Messages and defines
+
+# For those who love details. Note that __make__/vcs.mk outputs also
+# messages if VERBOSE is defined, so it is better to keep this block
+# close to the related include command.
+#
ifdef VERBOSE
-$(info Repository: $(repo))
$(info translations = $(translations))
+$(info templates = $(templates))
+$(info existing templates = $(existing_templates))
+$(info missing templates = $(missing_templates))
mmverbose := --verbose
echofile := echo $$file: ;
-cvsquiet :=
-# Also applicable for Hg and Git.
-bzrquiet := --verbose
else
-cvsquiet := -q
-bzrquiet := --quiet
+mmverbose :=
+echofile :=
endif
-# The commands to update/commit/tag the CVS repository.
-
-define cvs-update
-$(CVS) $(cvsquiet) update -d -P
-endef
-
-define cvs-commit
-$(CVS) commit -m $(log)
-endef
-
-define cvs-tag
-$(CVS) $(cvsquiet) tag $(runtag)
-endef
-
-# The commands to update/commit/tag the Subversion repository.
-
-define svn-update
-$(SVN) $(cvsquiet) update
-endef
-
-define svn-commit
-$(SVN) commit -m $(log)
-endef
-
-define svn-tag
-[ -d tags ] || $(SVN) mkdir tags ; \
-$(SVN) $(cvsquiet) copy trunk tags/$(runtag) -m $(runtag)
-endef
-
-# The commands to update/commit/tag the Git repository.
-
-define git-update
-$(GIT) pull $(bzrquiet)
-endef
-
-define git-commit
-$(GIT) commit $(bzrquiet) --all -m $(log)
-endef
-
-define git-tag
-$(GIT) tag -m $(runtag)
-endef
-
-# The commands to update/commit/tag the Bazaar repository.
+# Import vcs-related stuff here.
+include __make__/vcs.mk
-define bzr-update
-$(BZR) pull $(bzrquiet)
-endef
-
-# The behavior of `bzr commit' is not very script-friendly: it will
-# exit with an error if there are no changes to commit.
-define bzr-commit
-if $(BZR) status --versioned --short | grep --quiet '^ M'; then \
- $(BZR) commit $(bzrquiet) -m $(log) && $(BZR) push $(bzrquiet); \
-else \
- true; \
-fi
-endef
-
-define bzr-tag
-$(BZR) tag $(runtag) $(bzrquiet)
-endef
-
-# The commands to update/commit/tag the Mercurial repository.
-
-# Note that the "fetch" extension is not guaranteed
-# to be available, and/or enabled in user's ~/.hgrc.
-define hg-update
-$(HG) pull --update $(bzrquiet)
-endef
-
-define hg-commit
-$(HG) commit $(bzrquiet) -m $(log) && $(HG) push $(bzrquiet)
-endef
-
-define hg-tag
-$(HG) tag -m $(runtag) $(runtag)
-endef
-
-# The commands to update/commit/tag the Arch repository.
-
-define tla-update
-$(TLA) update
-endef
-
-# Arch is so dumb that it will do a bogus commit (adding another absolutely
-# useless revision) even if there are no changes. Fortunately, the exit status
-# of `tla changes' is sane.
-define tla-commit
-$(TLA) changes >/dev/null || $(TLA) commit -s $(log)
-endef
-
-define tla-tag
-$(TLA) tag $(runtag)
-endef
-
-# To find prefix, make repo lowercase and substitute arch by tla
-repoprefix := $(subst arch,tla,$(shell echo $(repo) | tr A-Z a-z))
-
-# Dynamic repository commands
-repoupdate := $($(repoprefix)-update)
-repocommit := $($(repoprefix)-commit)
-repotag := $($(repoprefix)-tag)
-
-## Target-specific additions
+# Warning message for the `publish' rule.
+pubwmsg := "Warning (%s): %s\n does not exist; (either obsolete or \`cvs\
+update\' in $(wwwdir) needed).\n"
# Script to be created by publish target (commits all published .po files).
commitfile := $(wwwdir)commit-pub
@@ -260,7 +192,7 @@
# Update the master and the team repositories.
.PHONY: update
update:
-ifeq ($(VCS),yes)
+ifeq ($(strip $(VCS)),yes)
@echo Updating the repositories...
cd $(wwwdir) && $(cvs-update)
$(repoupdate)
@@ -274,16 +206,14 @@
.PHONY: sync
sync: update
@for file in $(translations); do \
- if [ ! -f $(wwwdir)`dirname $$file`/po/`basename \
- $${file/.$(TEAM).po/.pot}` ]; then \
- echo "Warning: $(notdir $$file) has no equivalent .pot in www."; \
+ if [ ! -f $(call www_pot_path,$$file) ]; then \
+ echo "Warning: $$file has no equivalent .pot in www."; \
else \
$(echofile) $(MSGMERGE) $(mmverbose) --quiet --update \
- --previous $$file \
- $(wwwdir)`dirname $$file`/po/`basename $${file/.$(TEAM).po/.pot}`; \
+ --previous $$file $(call www_pot_path,$$file); \
fi; \
done
-ifeq ($(VCS),yes)
+ifeq ($(strip $(VCS)),yes)
@echo Tagging repository with tag: \'$(runtag)\'
$(repotag)
@echo Commiting changes to repository...
@@ -314,11 +244,10 @@
.PHONY: format
format:
@echo Formatting .po files with msgcat:
- @for file in $(translations); do \
- if [ `LC_ALL=C <$$file wc --max-line-length` -gt 80 ]; then \
- $(MSGCAT) -o $$file $$file && echo " $${file#./}"; \
- fi; \
- done
+ @LC_ALL=C wc --max-line-length $(translations) \
+ | awk '$$1>80 {print $$2}' | grep -v total \
+ | xargs --max-args=1 --no-run-if-empty \
+ sh -c '$(MSGCAT) -o $$1 $$1 ; echo " "$$1' msgcat
# Helper target to mark changes (at word level) in fuzzy messages
.PHONY: fuzdiff
@@ -333,11 +262,8 @@
# Code of awk scripts used in next two targets
#
-chtime := $(shell date '+%Y-%m-%d %R%:z')
rulebg := BEGIN{ RS=""; FS="\n"; ORS="\n\n"; OFS=FS }
rulepr := NR > 1 { $$1=$$1; print }
-rulerm := NR > 1 { for (i=1; i<=NF; ++i) sub(/^\#~ /,"",$$i); print }
-rulen1 := NR == 1 { $$1=$$1; for (i=1; i<=NF; ++i){ if
($$i~/PO-Revision-Date:/){ $$i="\"PO-Revision-Date: $(chtime)\\n\""; break } }
print }
# Helper target to report obsolete messages
.PHONY: obreport
@@ -356,25 +282,9 @@
# Helper target to remove obsolete messages and store them in a catalog
.PHONY: obremove
obremove:
- @export tmpfile='' # protect previously set from rm
- @echo Removing obsolete messages to $(obcatalog) ...
- @[ "`tail --lines=1 $(obcatalog)`" = "" ] || echo >> $(obcatalog)
- @for file in $(translations); do \
- if [ `LC_ALL=C $(MSGATTRIB) --only-obsolete $$file \
- | wc --lines` -gt 0 ]; then \
- $(MSGATTRIB) --only-obsolete $$file \
- | awk '$(rulebg) $(rulerm)' >> $(obcatalog); \
- tmpfile=`tempfile`; \
- $(MSGATTRIB) --no-obsolete $$file > $$tmpfile; \
- mv --backup $$tmpfile $$file; \
- fi; \
- done
- @for dummy in 1; do \
- tmpfile=`tempfile`; \
- < $(obcatalog) awk '$(rulebg) $(rulen1) $(rulepr)' > $$tmpfile; \
- $(MSGUNIQ) $$tmpfile > $(obcatalog); \
- rm --force $$tmpfile; \
- done
+ @__make__/obsolete-remove \
+ --store=__tools__/deleted.$(TEAM).po \
+ $(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
@@ -385,35 +295,26 @@
# Files are compared regarding content only, since file date may change
# as a result of applying our tool-chain.
.PHONY: publish
-publish: format
+publish: obremove format
@echo Copying edited .po files back to $(wwwdir):
@cat <<< '$(commit_header)' | tr "._" "$$'" \
| sed -e 's/\^ /\n/g' -e 's/\\`/`/g' > $(commitfile)
@for file in $(translations); do \
- wwwfdir=$(wwwdir)`dirname $$file`/po; \
- wwwfpot=$${wwwfdir}/`basename $${file/.$(TEAM).po/.pot}`; \
- wwwfile=$${wwwfdir}/`basename $$file`; \
+ wwwfpot=$(call www_pot_path,$$file); \
+ wwwfdir=$(dir $$wwwfpot); \
+ wwwfile=$(call www_po_path,$$file); \
if [ ! -d $$wwwfdir ]; then \
- printf $(pubwmsg) "$${file#./}" "directory $$wwwfdir"; \
+ printf $(pubwmsg) "$$file" "directory $$wwwfdir"; \
continue; \
fi; \
if [ ! -f $$wwwfpot ]; then \
- printf $(pubwmsg) "$${file#./}" "template $$wwwfpot"; \
+ printf $(pubwmsg) "$$file" "template $$wwwfpot"; \
continue; \
fi; \
- if [ -f $$wwwfile ] ; then \
- if [ `LC_ALL=C diff -u $$file $$wwwfile | wc --lines` -gt 0 ]; then
\
- if cp $$file $$wwwfile; then \
- echo " $${file#./}"; \
- echo $${wwwfile/"$(wwwdir)"} >> $(commitfile) ; \
- else \
- echo "ERROR: could not copy $$file to $$wwwfile"; \
- fi; \
- fi; \
- elif [ "$(NEWPUB)" = "yes" ] ; then \
- if cp $$file $$wwwfile; then \
- echo " $${file#./}"; \
- echo $${wwwfile/"$(wwwdir)"} >> $(commitfile) ; \
+ if [ -f $$wwwfile ] || [ "$(NEWPUB)" = "yes" ]; then \
+ if cp --archive --update $$file $$wwwfile; then \
+ echo " $$file"; \
+ echo $(subst $(wwwdir),,$$file) >>$(commitfile) ; \
else \
echo "ERROR: could not copy $$file to $$wwwfile"; \
fi; \
@@ -424,56 +325,19 @@
@chmod u+x $(commitfile)
# Helper target to delete common auto-generated files.
+# Note that unlike rm, trash will choke with error if the argument
+# file list is empty; thus the xargs --non-run-if-empty safequard.
.PHONY: clean
clean:
@echo Deleting unnecessary auto-generated files...
- @for file in $(translations); do \
- $(RM) $$file~ $$file.bak $${file/.po/.mo} 2>/dev/null; \
- done
+ @echo $(strip $(wildcard \
+ $(addsuffix ~,$(translations)) \
+ $(addsuffix .bak,$(translations)) \
+ $(patsubst %.po,%.mo,$(translations)) \
+ )) | xargs --no-run-if-empty $(RM) 2>/dev/null
@echo "done."
# Helper target to display accepted targets and parameters.
.PHONY: help
help:
- @echo 'Usage: make TARGET [PARAMS]'
- @echo 'Process PO files and/or execute actions according to TARGET
specs.'
- @echo ''
- @echo 'Accepted values of TARGET are (only one target is allowed):'
- @echo ''
- @echo 'all (or empty) default target; invokes update and sync
targets, as well'
- @echo ' as report obreport fuzdiff and obremove
targets'
- @echo 'clean delete common auto-generated files (.mo and
backups)'
- @echo 'format format all PO files to standard (80 columns)
width'
- @echo 'fuzdiff edit in-place PO files with the view-fuzzy
script to mark'
- @echo ' changes of fuzzy translations (modify the #|
comments);'
- @echo ' invokes format target'
- @echo 'publish copy modified PO files to the www master
repository and'
- @echo ' create a commit script there; invokes format
target; by'
- @echo ' default only files that exist in www master
repository '
- @echo ' are published; supply NEWPUB=yes parameter to
override it;'
- @echo ' to commit all changes cd to www and run
./commit-pub'
- @echo 'obremove remove obsolete translations from PO files;
store them in'
- @echo ' a backup catalog'
- @echo 'obreport report obsolete translations inside PO files'
- @echo 'report check which articles have to be updated and
display '
- @echo ' a report'
- @echo 'sync synchronize (update) the PO files from the
master POTs;'
- @echo ' if the VCS=yes parameter is supplied,
automatically'
- @echo ' commit the changes to the team repository
(tags it just'
- @echo ' before the commit to allow easy rollback if
desired)'
- @echo 'tag tag the team repository with the same type of
tags as the'
- @echo ' sync target creates; useful for
intermediately tagging the'
- @echo ' state of large changes operations'
- @echo 'update update the team repository; if the VCS=yes
parameter'
- @echo ' is supplied, update the master repository
also'
- @echo 'help display GNUmakefile usage (this message)'
- @echo ''
- @echo 'Accepted values of PARAMS are:'
- @echo ''
- @echo 'VCS=yes update master and team repositories; valid
with all,'
- @echo ' update, sync targets'
- @echo 'NEWPUB=yes publish also PO files that do not exist in
www master'
- @echo ' repository; valid with publish target; use
with caution'
- @echo ' since this means translations that may not be
ready yet'
- @echo ' will be published'
-
+ @cat __make__/help
Index: __make__/help
===================================================================
RCS file: __make__/help
diff -N __make__/help
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ __make__/help 20 Apr 2015 19:10:53 -0000 1.1
@@ -0,0 +1,41 @@
+Usage: make TARGET [PARAMS]
+Process PO files and/or execute actions according to TARGET specs.
+
+Accepted values of TARGET are (only one target is allowed):
+
+all (or empty) default target; invokes update and sync targets, as well
+ as report obreport fuzdiff and obremove targets
+clean delete common auto-generated files (.mo and backups)
+format format all PO files to standard (80 columns) width
+fuzdiff edit in-place PO files with the view-fuzzy script to mark
+ changes of fuzzy translations (modify the #| comments);
+ invokes format target
+publish copy modified PO files to the www master repository and
+ create a commit script there; invokes format target; by
+ default only files that exist in www master repository
+ are published; supply NEWPUB=yes parameter to override it;
+ to commit all changes cd to www and run ./commit-pub
+obremove remove obsolete translations from PO files; store them in
+ a backup catalog
+obreport report obsolete translations inside PO files
+report check which articles have to be updated and display
+ a report
+sync synchronize (update) the PO files from the master POTs;
+ if the VCS=yes parameter is supplied, automatically
+ commit the changes to the team repository (tags it just
+ before the commit to allow easy rollback if desired)
+tag tag the team repository with the same type of tags as the
+ sync target creates; useful for intermediately tagging the
+ state of large changes operations
+update update the team repository; if the VCS=yes parameter
+ is supplied, update the master repository also
+help display GNUmakefile usage (this message)
+
+Accepted values of PARAMS are:
+
+VCS=yes update master and team repositories; valid with all,
+ update, sync targets
+NEWPUB=yes publish also PO files that do not exist in www master
+ repository; valid with publish target; use with caution
+ since this means translations that may not be ready yet
+ will be published
Index: __make__/vcs.mk
===================================================================
RCS file: __make__/vcs.mk
diff -N __make__/vcs.mk
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ __make__/vcs.mk 20 Apr 2015 19:10:53 -0000 1.1
@@ -0,0 +1,169 @@
+# VCS handling declarations of team's GNUmakefile.
+# Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
+
+# This file is part of GNUnited Nations.
+
+# GNUnited Nations is free software: you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+
+# GNUnited Nations is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with GNUnited Nations. If not, see <http://www.gnu.org/licenses/>.
+
+## VCS-related staff
+
+# Adjust these variables if you don't have the programs in your PATH.
+CVS := cvs
+SVN := svn
+GIT := git
+BZR := bzr
+HG := hg
+# Baz can be used alternatively; its commands are compatible.
+TLA := tla
+
+# Vcs auto-commit log message
+log := "Automatic merge from the master repository."
+
+# no-commit info message
+noupdmsg := 'Repositories were not updated, you might want "make VCS=yes".'
+
+# We record UTC time with second accuracy to allow correct operation of tags
+# even when multiple syncs per day are performed from multiple users.
+
+lastrun := $(shell date --rfc-3339=seconds | tr ' +' '__' | tr -d ':')
+runtag := $(join status_,$(lastrun))
+
+# Determine the VCS and relevant update/commit commands.
+
+repo := $(shell \
+ (test -d CVS && echo CVS) \
+ || (test -d .svn && echo SVN) \
+ || (test -d .git && echo Git) \
+ || (test -d .bzr && echo Bzr) \
+ || (test -d .hg && echo Hg) \
+ || (test -d \{arch\} && echo Arch) \
+ )
+ifndef repo
+$(error Unsupported Version Control System)
+endif
+
+# For those who love details.
+ifdef VERBOSE
+$(info Repository: $(repo))
+cvsquiet :=
+# Also applicable for Hg and Git.
+bzrquiet := --verbose
+else
+cvsquiet := -q
+bzrquiet := --quiet
+endif
+
+# The commands to update/commit/tag the CVS repository.
+
+define cvs-update
+$(CVS) $(cvsquiet) update -d -P
+endef
+
+define cvs-commit
+$(CVS) commit -m $(log)
+endef
+
+define cvs-tag
+$(CVS) $(cvsquiet) tag $(runtag)
+endef
+
+# The commands to update/commit/tag the Subversion repository.
+
+define svn-update
+$(SVN) $(cvsquiet) update
+endef
+
+define svn-commit
+$(SVN) commit -m $(log)
+endef
+
+define svn-tag
+[ -d tags ] || $(SVN) mkdir tags ; \
+$(SVN) $(cvsquiet) copy trunk tags/$(runtag) -m $(runtag)
+endef
+
+# The commands to update/commit/tag the Git repository.
+
+define git-update
+$(GIT) pull $(bzrquiet)
+endef
+
+define git-commit
+$(GIT) commit $(bzrquiet) --all -m $(log)
+endef
+
+define git-tag
+$(GIT) tag -m $(runtag)
+endef
+
+# The commands to update/commit/tag the Bazaar repository.
+
+define bzr-update
+$(BZR) pull $(bzrquiet)
+endef
+
+# The behavior of `bzr commit' is not very script-friendly: it will
+# exit with an error if there are no changes to commit.
+define bzr-commit
+if $(BZR) status --versioned --short | grep --quiet '^ M'; then \
+ $(BZR) commit $(bzrquiet) -m $(log) && $(BZR) push $(bzrquiet); \
+else \
+ true; \
+fi
+endef
+
+define bzr-tag
+$(BZR) tag $(runtag) $(bzrquiet)
+endef
+
+# The commands to update/commit/tag the Mercurial repository.
+
+# Note that the "fetch" extension is not guaranteed
+# to be available, and/or enabled in user's ~/.hgrc.
+define hg-update
+$(HG) pull --update $(bzrquiet)
+endef
+
+define hg-commit
+$(HG) commit $(bzrquiet) -m $(log) && $(HG) push $(bzrquiet)
+endef
+
+define hg-tag
+$(HG) tag -m $(runtag) $(runtag)
+endef
+
+# The commands to update/commit/tag the Arch repository.
+
+define tla-update
+$(TLA) update
+endef
+
+# Arch is so dumb that it will do a bogus commit (adding another absolutely
+# useless revision) even if there are no changes. Fortunately, the exit status
+# of `tla changes' is sane.
+define tla-commit
+$(TLA) changes >/dev/null || $(TLA) commit -s $(log)
+endef
+
+define tla-tag
+$(TLA) tag $(runtag)
+endef
+
+# To find prefix, make repo lowercase and substitute arch by tla
+repoprefix := $(subst arch,tla,$(shell echo $(repo) | tr A-Z a-z))
+
+# Dynamic repository commands
+repoupdate := $($(repoprefix)-update)
+repocommit := $($(repoprefix)-commit)
+repotag := $($(repoprefix)-tag)
Index: __make__/obsolete-remove
===================================================================
RCS file: __make__/obsolete-remove
diff -N __make__/obsolete-remove
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ __make__/obsolete-remove 20 Apr 2015 19:10:54 -0000 1.1
@@ -0,0 +1,496 @@
+#!/bin/sh
+
+# Clean po files from obsolete translations.
+# Copyright (C) 2012, 2015 Georgios M. Zarkadas <address@hidden>
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the Free
+# Software Foundation; either version 3 of the License, or (at your option)
+# any later version.
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the "Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA"
+
+#### Variables ####
+
+PROGRAM='obsolete-remove'
+VERSION='0.1.0'
+SHORTDESC='Clean po files from obsolete translations.'
+CR_YEARS='2012, 2015'
+CR_NAME='Georgios M. Zarkadas'
+CR_MAIL='<gz at member.fsf.org>'
+
+ARGSDESC='[options] FILE1 [FILE2 [...]]
+Remove obsolete translations from FILE1 FILE2 ... optionally appending them,
+after restoring to no-obsolete status, to a file store.'
+
+# always keep the 1st line empty in the strings below
+
+OPTSDESC='
+ -q, --quiet suppress progress output
+ -s, --store=FILE append obsolete translations to file FILE; FILE must
+ either exist and be a valid po file, on not exist at
+ all; in the later case it is created
+ --help display this help screen and exit
+ --version output version information and exit'
+
+OPTSFOOTER='
+Duplicate translations are merged at the store; you can manually review them
+later. Thus, the store remains a valid po file to be used as a compendium.'
+
+LICENSE='
+License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
+This is free software: you are free to change and redistribute it.
+There is NO WARRANTY, to the extent permitted by law.'
+
+# Show help screen.
+#
+show_help ()
+{
+ cat <<- EOF
+ usage: ${PROGRAM} ${ARGSDESC}
+ ${OPTSDESC}
+ ${OPTSFOOTER}
+ Report ${PROGRAM} bugs to ${CR_MAIL}.
+ EOF
+ exit 0
+}
+
+# Show version information.
+#
+show_version ()
+{
+ cat <<- EOF
+ ${PROGRAM} ver. ${VERSION} - ${SHORTDESC}
+ Copyright (C) ${CR_YEARS} ${CR_NAME} ${CR_MAIL}.${LICENSE}
+ EOF
+ exit 0
+}
+
+# Note on error codes: getopt may return 1-4 and 5 is reserved by us for
+# internal errors in options/arguments handling. Thus calls to error inside
+# the code should start from 6.
+
+EMSG_INT_OPTION=\
+"Internal error: not recognized option"
+EMSG_INT_ARGNUM=\
+"Internal error: wrong number of arguments"
+
+EMSG_CHK_ALOS=\
+"check disk space, quotas and permissions."
+EMSG_CHK_FULL=\
+"check disk space, quotas, permissions and source file format."
+EMSG_CHK_AWKFILE=\
+"check awk install and source file format."
+EMSG_CHK_AWKFULL=\
+"check awk install, disk space, quotas, permissions and source file format."
+EMSG_CHK_STRFULL=\
+"check disk space, quotas, permissions and store's file format."
+
+EMSG_STR_NOPATH=\
+'Error: wrong path of store file, or intermediate directories do not exist;
+check the path and create missing directories.'
+EMSG_STR_ISADIR=\
+'Error: the specified store exists and is a directory; please use a regular
+file for this option.'
+EMSG_STR_NOFILE=\
+"Error: only regular files are allowed to be used as stores."
+EMSG_STR_UNREAD=\
+'Error: the specified store exists and is not readable; please either change
+its permissions or use another one and retry.'
+EMSG_STR_UNWRIT=\
+'Error: the specified store exists and is not writable; please either change
+its permissions or use another one and retry.'
+
+# Print an error message to stderr and exit with error code.
+# Args: #1={errcode|-}, #2,[#3,[...]]=message
+#
+error ()
+{
+ if [ "X${2}" = "X" ]
+ then
+ echo "Undocumented error; please" \
+ "file a bug report to ${CR_MAIL}." >&2
+ exit 100
+ fi
+ local errcode=${1}
+ shift
+ if [ "X${errcode}" = "X-" ]
+ then
+ errcode=1
+ fi
+ cat <<- EOF >&2
+ address@hidden
+ EOF
+ exit ${errcode}
+}
+
+# Create a temporary file or exit with an error.
+# Args: what tempfile accepts
+#
+tempfile_or_die ()
+{
+ tempfile "$@" || error 6 \
+ "Error at creating temporary file; ${EMSG_CHK_ALOS}"
+}
+
+# Initialises a po catalog (putting the 1st entry).
+# Args: #1=catalog-to-init
+#
+init_store()
+{
+ [ $# -eq 1 ] || error 7 "${EMSG_INT_ARGNUM} to init_store"
+ local store="${1}"
+
+ cat <<- EOF >"${store}"
+ # LANGUAGE store of obsolete translations
+ # Copyright (C) YEAR COPYRIGHT HOLDER
+ # This file is distributed under the same license as the translations.
+ # FIRST AUTHOR <address@hidden>, YEAR.
+ #
+ #, fuzzy
+ msgid ""
+ msgstr ""
+ "Project-Id-Version: obsolete\n"
+ "POT-Creation-Date: 2015-04-20 10:50+0000\n"
+ "PO-Revision-Date: 2015-04-20 10:50+0000\n"
+ "Last-Translator: FULL NAME <address@hidden>\n"
+ "Language-Team: LANGUAGE <address@hidden>\n"
+ "MIME-Version: 1.0\n"
+ "Content-Type: text/plain; charset=UTF-8\n"
+ "Content-Transfer-Encoding: 8bit\n"
+ EOF
+}
+
+# Appends all translations of a po catalog (except the 1st one) to another.
+# Args: #1=source-catalog, #2=destination-catalog
+#
+append_to_store ()
+{
+ [ $# -eq 2 ] || error 7 "${EMSG_INT_ARGNUM} to append_to_store"
+
+ local source="${1}"
+ local store="${2}"
+
+ if [ $(tail --lines=1 "${store}" | wc --bytes) -gt 1 ]
+ then
+ echo >>"${store}" || return 8
+ fi
+ if ! awk '
+ BEGIN{RS="";FS="\n";ORS="\n\n";OFS=FS}
+ NR>1 {print}
+ ' 2>/dev/null <"${source}" >>"${store}"
+ then
+ return 9
+ fi
+}
+
+QUIET=0
+STORE=''
+NEW_STORE=0
+HAVEOBS=0
+DELAYED_MSG=''
+
+# Print a message to stdout, if not in quiet mode.
+# Args: [#1,[#2,[#3,[...]]]]=message
+#
+print_msg ()
+{
+ if [ ${QUIET} -eq 0 ]
+ then
+ echo "$@"
+ fi
+}
+
+# Print the delayed message to stdout, if not in quiet mode, and reset it.
+# Args: none
+#
+print_delayed_msg ()
+{
+ if [ ${QUIET} -eq 0 ] && [ "X${DELAYED_MSG}" != "X" ]
+ then
+ echo "${DELAYED_MSG}"
+ DELAYED_MSG=''
+ fi
+}
+
+#### MAIN ####
+
+CMDLINE=$(getopt \
+ -o 'qs:' \
+ -l 'quiet,store:' \
+ -l help,version -n "${PROGRAM}" -- "$@")
+ERRCODE=$?
+if [ ${ERRCODE} -ne 0 ]
+then
+ exit ${ERRCODE}
+fi
+eval set -- "${CMDLINE}"
+
+# process options
+
+while true
+do
+ case ${1} in
+ -q|--quiet)
+ QUIET=1
+ shift
+ ;;
+ -s|--store)
+ if ! STORE=$(realpath "${2}" 2>/dev/null)
+ then
+ error 5 "${EMSG_STR_NOPATH}"
+ fi
+ if [ -e "${STORE}" ]
+ then
+ [ -d "${STORE}" ] && error 5 "${EMSG_STR_ISADIR}"
+ [ -f "${STORE}" ] || error 5 "${EMSG_STR_NOFILE}"
+ [ -r "${STORE}" ] || error 5 "${EMSG_STR_UNREAD}"
+ [ -w "${STORE}" ] || error 5 "${EMSG_STR_UNWRIT}"
+ else
+ NEW_STORE=1
+ fi
+ shift 2
+ ;;
+ --)
+ shift
+ break
+ ;;
+ *)
+ error 5 "${EMSG_INT_OPTION} '${1}'."
+ ;;
+ esac
+done
+
+# process arguments
+
+if [ "X${STORE}" = "X" ]
+then
+ print_msg "Removing obsolete messages..."
+else
+ print_msg "Removing obsolete messages to '${STORE}'..."
+fi
+
+# Make a backup of STORE at the beggining, only if there are obsolete messages.
+# Obsolete messages are cleared and appended to STORE. If the process fails
later
+# (for example, at the msguniq step), then new obsolete messages are preserved
at
+# STORE or STORE~ while there is also a backup of the old file as STORE.bak.
+
+for file in "$@"
+do
+ # Clean source file from obsolete messages and store them to a temp file.
+ # This is needed in any case, to output progress information.
+
+ outfile=$(tempfile_or_die)
+ tmpfile=$(tempfile_or_die)
+ msgattrib --no-obsolete --output-file="${outfile}" "${file}" 2>/dev/null
+ ERRCODE=$?
+ msgattrib --obsolete --output-file="${tmpfile}" "${file}" 2>/dev/null
+ ERRCODE="${ERRCODE}$?"
+ case ${ERRCODE} in
+ 10|11)
+ rm --force "${tmpfile}" "${outfile}"
+ error 10 \
+ "Error at removing obsolete translations of '${file}';" \
+ "${EMSG_CHK_FULL}"
+ ;;
+ 01)
+ rm --force "${tmpfile}" "${outfile}"
+ error 10 \
+ "Error at extracting obsolete translations from '${file}';" \
+ "${EMSG_CHK_FULL}"
+ ;;
+ *)
+ ;;
+ esac
+ if ! mv --backup "${outfile}" "${file}"
+ then
+ rm --force "${tmpfile}" "${outfile}"
+ error 11 \
+ "Error at replacing '${file}' with its obsolete-free version;" \
+ "${EMSG_CHK_ALOS}"
+ fi
+
+ # If errors happen during this stage keep the tempfile; obsolete
+ # translations have already been wiped from $file.
+
+ if ! NOBS=$(awk 'BEGIN{RS="";FS="\n"} END{print NR-1}' \
+ <"${tmpfile}" 2>/dev/null)
+ then
+ error 12 \
+ "Error at counting obsolete translations of '${file}';" \
+ "${EMSG_CHK_AWKFILE} Obsolete translations have been kept" \
+ "at '${tmpfile}'."
+ fi
+
+ # If for any reason NOBS does not contain an integer, ensure that the
+ # rest of this loop will be skipped (ie skip at the else clause).
+ # To preserve obsolete translations, use the fact that msgattrib does
+ # not output anything if no obsolete translations exist.
+
+ if [ ${NOBS} -gt 0 ]
+ then
+ # Delay print for first file with obsolete, so that message
+ # of store backup creation comes first.
+
+ newmsg=" '${file}': ${NOBS} obsolete translations removed"
+ if [ ${HAVEOBS} -eq 0 ]
+ then
+ if [ "X${DELAYED_MSG}" = "X" ]
+ then
+ DELAYED_MSG="${newmsg}"
+ else
+ DELAYED_MSG="${DELAYED_MSG}\n${newmsg}"
+ fi
+ else
+ print_msg "${newmsg}"
+ DELAYED_MSG=''
+ fi
+ else
+ if [ $(stat --format="%s" "${tmpfile}") -gt 0 ]
+ then
+ echo "Warning: possible error of skipping obsolete translations" \
+ "of '${file}'; they have been kept at '${tmpfile}'."
+ else
+ rm --force "${tmpfile}"
+ fi
+ continue
+ fi
+
+ # If a store was not provided as option, skip the related part of the loop.
+
+ if [ "X${STORE}" = "X" ]
+ then
+ print_delayed_msg
+ continue
+ fi
+
+ if [ ${HAVEOBS} -eq 0 ]
+ then
+ HAVEOBS=1
+ if [ ${NEW_STORE} -eq 0 ]
+ then
+ if ! cp --force --backup --suffix=.bak "${STORE}" "${STORE}"
+ then
+ error 11 \
+ "Error at creating backup of store file '${STORE}';" \
+ "${EMSG_CHK_ALOS} Obsolete translations have been kept" \
+ "at '${tmpfile}'."
+ fi
+ print_msg "creating backup of store file at '${STORE}.bak'"
+ else
+ if ! init_store "${STORE}"
+ then
+ error 11 \
+ "Error at creating new store file '${STORE}';" \
+ "${EMSG_CHK_ALOS} Obsolete translations have been kept" \
+ "at '${tmpfile}'."
+ fi
+ print_msg "creating new store file at '${STORE}'"
+ fi
+ print_delayed_msg
+ fi
+ if ! append_to_store "${tmpfile}" "${STORE}"
+ then
+ error 13 \
+ "Error at storing obsolete translations of '${file}';" \
+ "${EMSG_CHK_AWKFULL} Obsolete translations have been kept" \
+ "at '${tmpfile}'."
+ fi
+ rm --force "${tmpfile}"
+done
+
+# If a store was not provided as option, skip the rest of the program.
+# The same holds true if a store was provided, but no obsolete translations
+# were found inside the files passed as arguments.
+
+if [ "X${STORE}" = "X" ] || [ ${HAVEOBS} -eq 0 ]
+then
+ if [ ${HAVEOBS} -eq 0 ]
+ then
+ print_msg " none found"
+ fi
+ print_msg "done."
+ exit 0
+fi
+
+# STORE has now all obsolete translations (and they are > 0).
+# Set STORE's PO-Revision-Date to now.
+
+tmpfile=$(tempfile_or_die)
+print_msg "setting current date as revision-date for '${STORE}'"
+if ! awk '
+ BEGIN {RS="";FS="\n";ORS="\n\n";OFS=FS}
+ NR==1 {
+ $1=$1
+ for (i = 1;i <= NF;++i) {
+ if ($i ~ /PO-Revision-Date:/) {
+ datecmd = "date \"+%Y-%m-%d %R%:z\""
+ datecmd | getline chtime
+ close(datecmd)
+ $i="\"PO-Revision-Date: " chtime "\\n\""
+ break
+ }
+ }
+ print
+ }
+ NR>1 {
+ $1=$1
+ print
+ }' 2>/dev/null <"${STORE}" >"${tmpfile}"
+then
+ rm --force "${tmpfile}"
+ error 13 \
+ "Error at changing revision date of '${STORE}';"
+ "${EMSG_CHK_AWKFULL}"
+fi
+if ! mv "${tmpfile}" "${STORE}"
+then
+ rm --force "${tmpfile}"
+ error 11 \
+ "Error at changing revision date of '${STORE}';"
+ "${EMSG_CHK_ALOS}"
+fi
+
+# Remove duplicate translations from STORE.
+# We do not want to use --use-first because this means that newer versions
+# of the msgid translations will be discarded in favor of old ones.
+# We believe that the general case is that later in time translations tend
+# to be better than older ones.
+# Thus we merge the duplicate translations and let the user to review them
+# later and chose the better version.
+
+print_msg "merging duplicate translations of '${STORE}'"
+outfile=$(tempfile_or_die)
+tmpfile=$(tempfile_or_die)
+msguniq --unique --output-file="${outfile}" "${STORE}" 2>/dev/null
+ERRCODE=$?
+msguniq --repeated --output-file="${tmpfile}" "${STORE}" 2>/dev/null
+ERRCODE="${ERRCODE}$?"
+if [ "${ERRCODE}" != "00" ]
+then
+ rm --force "${outfile}" "${tmpfile}"
+ error 14 \
+ "Error at extracting unique and repeated translations of '${STORE}';" \
+ "${EMSG_CHK_STRFULL}"
+fi
+newfile=$(tempfile_or_die)
+if ! msgcat --output-file="${newfile}" "${outfile}" "${tmpfile}" 2>/dev/null
+then
+ rm --force "${outfile}" "${tmpfile}" "${newfile}"
+ error 14 \
+ "Error at merging unique and repeated translations back to '${STORE}';" \
+ "${EMSG_CHK_STRFULL}"
+fi
+rm --force "${outfile}" "${tmpfile}"
+if ! mv --backup "${newfile}" "${STORE}"
+then
+ rm --force "${newfile}"
+ error 11 \
+ "Error at replacing '${STORE}' with its new version;" \
+ "${EMSG_CHK_ALOS}"
+fi
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [www-el-commits] www-el GNUmakefile __make__/help __make__/vcs.m...,
Georgios Zarkadas <=