release: automate uploading of web manuals in CVS
authorStefano Lattarini <stefano.lattarini@gmail.com>
Thu, 13 Dec 2012 10:02:59 +0000 (11:02 +0100)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Thu, 13 Dec 2012 19:18:09 +0000 (20:18 +0100)
This is partly inspired to the 'gnu-web-doc-update' script from
gnulib.  Unfortunately, we can't use that script directly, because
as of now it assumes a build system integrated with gnulib.

* Makefile.am (upload-web-manuals): New .PHONY rule.
(RSYNC, CVS, CVSU, CVS_USER, WEBCVS_ROOT): New variables, used by
the new rule.

Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
Makefile.am

index 22a8fbd..a573ff2 100644 (file)
@@ -993,9 +993,9 @@ fetch:
        $(AM_V_at)rm -rf Fetchdir
 .PHONY: fetch
 
-## --------------------------------------------------------------------- ##
-##  Generate manuals in several formats, for upload on the GNU website.  ##
-## --------------------------------------------------------------------- ##
+## ---------------------------------------------------------------------- ##
+##  Generate and upload manuals in several formats, for the GNU website.  ##
+## ---------------------------------------------------------------------- ##
 
 # The gendocs.sh script sadly leaves TeX and Texinfo auxiliary files
 # in the directory where it's invoked.
@@ -1026,6 +1026,45 @@ web-manuals:
        $(AM_V_at)if $(AM_V_P); then ls -l doc/web-manuals; else :; fi
 .PHONY: web-manuals
 
+RSYNC = rsync
+CVS = cvs
+CVSU = cvsu
+CVS_USER = $${USER}
+WEBCVS_ROOT = cvs.savannah.gnu.org:/web
+
+upload-web-manuals:
+       $(AM_V_at)fatal () { echo "$@: $$*" >&2; exit 1; }; \
+       $(determine_release_type); \
+       case $$release_type in \
+         [Mm]ajor\ release|[Mm]inor\ release);; \
+         *) echo "Cannot upload manuals from a \"$$release_type\"" >&2; \
+            exit 1;; \
+       esac
+       $(AM_V_at)test -f $(srcdir)/doc/web-manuals/$(PACKAGE).html || { \
+         echo 'You have to run "$(MAKE) web-manuals" before' \
+              'invoking "$(MAKE) $@"' >&2; \
+         exit 1; \
+       }
+       $(AM_V_GEN): \
+         && CVS_RSH=ssh && export CVS_RSH=ssh \
+         && tmp=$@.dir \
+         && rm -rf $$tmp \
+         && mkdir $$tmp \
+         && $(am__cd) $$tmp \
+         && $(CVS) -z3 -d :ext:$(CVS_USER)@$(WEBCVS_ROOT)/$(PACKAGE) \
+                   co $(PACKAGE) \
+         && cd .. \
+         && $(RSYNC) -avP $(srcdir)/doc/web-manuals/ $$tmp/$(PACKAGE)/manual \
+         && ( \
+           cd $$tmp/$(PACKAGE)/manual \
+             && new_files=`$(CVSU) --types='?'` \
+             && new_files=`echo "$$new_files" | sed s/^..//` \
+             && { test -z "$$new_files" || $(CVS) add -ko $$new_files; } \
+             && $(CVS) ci -m $(VERSION) \
+           ) \
+         && rm -rf $$tmp
+.PHONY: upload-web-manuals
+
 EXTRA_DIST += lib/gendocs.sh lib/gendocs_template
 
 ## ------------------------------------------------ ##