OSDN Git Service

Add issue number tracking within published package lists.
authorKeith Marshall <keithmarshall@users.sourceforge.net>
Wed, 17 Apr 2013 12:38:13 +0000 (13:38 +0100)
committerKeith Marshall <keithmarshall@users.sourceforge.net>
Wed, 17 Apr 2013 12:38:13 +0000 (13:38 +0100)
ChangeLog
Makefile.comm.in
Makefile.in
Makefile.stub.in
configure.ac
makeopts.m4 [new file with mode: 0644]

index 6840791..1e524a7 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,36 @@
+2013-04-16  Keith Marshall  <keithmarshall@users.sourceforge.net>
+
+       Add issue number tracking within published package lists.
+
+       * makeopts.m4: New file; copy it from MinGW.org's build-aux package.
+
+       * configure.ac (AC_INIT): Bump version number to 2.0
+       (makeopts.m4): m4_include it; it is required to provide support for...
+       (MINGW_AC_MAKE_NO_PRINT_DIRECTORY): ...this additional feature test.
+
+       * Makefile.in (all): Require...
+       (update-references): ...this new build goal; implement it, using...
+       (update-local-references): ...this new recursively invoked rule, and...
+       (issue.sed): ...this new call-back rule.
+
+       * Makefile.stub.in (top_builddir): Define it as a macro.
+
+       * Makefile.comm.in (update_issue_number): New macro; define it.
+       (store_issue_number): Likewise; both are required to implement...
+       (generate_catalogue): ...this new sed script defining macro.
+       (sha1hash): Redefined macro; it now depends on substitution of...
+       ($catalogue): ...this local shell variable, in place of $<.
+       (extract_log_file_header, extract_log_file_footer): New macros.
+       (update-references, issue.sed): New build goals; they facilitate...
+       (update-local-references): ...this recursively invoked top-down build
+       goal; implement it in terms of refactored commands, abstracted from...
+       (%.xml.lzma: %.xml): ...this original goal, to create...
+       (generate-catalogue, generate-reference, select-for-publication):
+       (update-issue-log, issue.chk, issue.new, issue.tmp): ...these new
+       intermediate goals; they are invoked recursively, by use of...
+       (SET_MAKE): ...this autoconf defined and AC_SUBSTed hook, with...
+       (RMAKE): ...this new macro; define it.
+
 2013-04-10  Earnie Boyd  <earnie@users.sourceforge.net>
 
        * mingw32/mingw32-wsl-candidate.xml: Add the 4.0-rc-2 release.
index 1eae7da..f299cb5 100644 (file)
@@ -3,7 +3,7 @@
 # $Id$
 #
 # Written by Keith Marshall <keithmarshall@users.sourceforge.net>
-# Copyright (C) 2010, 2011, MinGW Project
+# Copyright (C) 2010, 2011, 2013, MinGW.org Project
 #
 #
 # Makefile template for generating mingw-get distribution manifests.
@@ -50,7 +50,8 @@ Makefile.sub: ${srcdir}/*.xml
        echo '  $$(EXTRA_DISTFILES)' >> $@
 
 include Makefile.sub
-all-distfiles: unpublished $(DISTFILES) $(auto-distfiles)
+all-distfiles: unpublished issue.sed $(DISTFILES) $(auto-distfiles)
+@SET_MAKE@
 
 # Distributed manifests are serialised by incorporating a date-stamped
 # issue number, of the form YYYYMMDDNN; we track issue numbers using the
@@ -61,13 +62,20 @@ issue_number = YYYYMMDDNN
 issue_key = awk '$$3 == "$*.xml" { print $$1 }' issue.new
 issue_log = ${srcdir}/issue.log
 
+update_issue_number = \
+  test -n "$$issue" || issue=0; \
+  test $$issue -lt $${mark="`date -u +%Y%m%d`00"} && \
+    issue=$$mark || issue=`expr $$issue + 1`
+generate_catalogue = -f ${top_builddir}/issue.sed -e $(store_issue_number)
+store_issue_number = "s/@$(issue_number)@/$(issue)/"
+
 # We use SHA1 hashes to determine when source files have been changed
 # from the last published version, as recorded in `issue.log'; the hash
 # is computed by openssl, after filtering the source through awk; (this
 # ensures that the computed hash is not influenced by any unintentional
 # pollution due to accidental insertion of CRLF line endings).
 #
-sha1hash = awk '{ sub( "\r$$", "" ); print }' $< | $(sha1sum)
+sha1hash = awk '{ sub( "\r$$", "" ); print }' $$catalogue | $(sha1sum)
 sha1sum = openssl sha1 | awk '{print $$NF}'
 
 # Formatting within issue.log is controlled by PAD and TAB settings.
@@ -87,25 +95,20 @@ PAD = "  "
 # any updated manifest is uploaded to the repository server.
 #
 %.xml.lzma: %.xml
+       @echo
        >> $(issue_log)
        rm -f issue.new issue.tmp
+       test -f ${top_builddir}/issue.sed || $(MAKE) issue.sed
        sed '/^$(TAB)*$$/d;/^$(TAB)*#/d' $(issue_log) > issue.new
-       issue=`awk '$$3 == "$*.xml" { print $$2 }' issue.new`; \
-       if test x$${hash="`$(sha1hash)`"} != x"`$(issue_key)`"; then \
-         test -n "$$issue" || issue=0; \
-         test $$issue -lt $${mark="`date -u +%Y%m%d`00"} && \
-           issue=$$mark || issue=`expr $$issue + 1`; \
-         awk '$$3 != "$*.xml"' issue.new > issue.tmp; \
-         echo $(PAD)$$hash $$issue $*.xml >> issue.tmp; \
-         fi; \
-       sed "s/@$(issue_number)@/$$issue/" $< | lzma -c > $@
-       if test -f issue.tmp; then \
-         sed -n '/^$(TAB)*$$/q;/^$(TAB)*[^#]/q;p' $(issue_log) > issue.new; \
-         LC_COLLATE=POSIX sort -k3 issue.tmp >> issue.new; \
-         sed -n 's/^$(TAB)*$$/break/;1,/^$(TAB)*[^#]/d;/^$(TAB)*#/p' \
-           $(issue_log) >> issue.new; \
-         rm -f $(issue_log) && mv issue.new $(issue_log); \
-         cd unpublished && $(LN_S) -f ../$@ .; \
+       @catalogue="$<" issue=`awk '$$3 == "$*.xml" { print $$2 }' issue.new`; \
+         if test x$${hash="`$(sha1hash)`"} != x"`$(issue_key)`"; then \
+           $(update_issue_number); \
+           $(RMAKE) refname=$*.xml issue=$$issue hash=$$hash issue.tmp; \
+           fi; \
+         $(RMAKE) catalogue=$@ source=$< issue=$$issue generate-catalogue
+       @if test -f issue.tmp; then \
+         $(RMAKE) refname=$@ select-for-publication; \
+         $(RMAKE) update-issue-log; \
          fi
        rm -f issue.new issue.tmp
 
@@ -120,7 +123,94 @@ FORCE:
 # processed, even on explicit file-by-file request).
 #
 ${srcdir}/*.xml: unpublished
-unpublished: FORCE
-       test -d unpublished || mkdir unpublished
+unpublished:
+       test -d $@ || mkdir $@
+
+# Package lists are dynamically updated, to record the latest issues of each
+# referenced package catalogue; the "sed" script used to accomplish this must
+# be generated, and driven from, within the top build directory.
+#
+update-references issue.sed: FORCE
+       cd ${top_builddir}; $(MAKE) $@
+
+# Requests to update references will be redirected back to each sub-directory
+# in turn, to be processed by the following recursive make rule.
+#
+update-local-references: unpublished issue.sed
+       rm -rf tmp; mkdir tmp; rm -f issue.tmp
+       sed '/^$(TAB)*$$/d;/^$(TAB)*#/d' $(issue_log) > issue.new
+       @for catalogue in `grep -l 'catalogue=' ${srcdir}/*.xml`; \
+         do refname=`echo $$catalogue | sed 's,^${srcdir}/,,'` \
+            issue=`awk '$$3 == "'$$refname'" { print $$2 }' issue.new`; \
+            $(RMAKE) refname=$$refname issue=$$issue generate-reference; \
+            lzma -dc $$refname.lzma | cmp -s - tmp/$$refname || \
+              { $(update_issue_number); \
+                $(RMAKE) dir=${top_builddir} issue.chk; \
+                $(RMAKE) refname=$$refname issue=$$issue \
+                  hash=`$(sha1hash)` issue.tmp; \
+                $(RMAKE) catalogue=$$refname.lzma source=$$catalogue \
+                  issue=$$issue generate-catalogue; \
+                $(RMAKE) refname=$$refname.lzma select-for-publication; \
+              }; \
+         done
+       @test -f issue.tmp && $(RMAKE) update-issue-log || true
+       rm -f ${top_builddir}/issue.sed issue.new issue.tmp
+       rm -rf tmp
+
+# The preceding rules for compiling catalogues for publication, and resolving
+# "package-list" references, use several recursive make hooks to perform common
+# sub-tasks.  GNU make tends to be very verbose about entering and leaving the
+# directories in which these sub-tasks are performed, even when there is no
+# change of directory involved; to make it quieter, we prefer this form of
+# recursive invocation for local sub-tasks.
+#
+RMAKE = $(MAKE)@NO_PRINT_DIRECTORY@
+
+# The following sub-task rule creates a tentative "publication-ready" version
+# of each catalogue.
+#
+generate-catalogue: FORCE
+       sed $(generate_catalogue) $(source) \
+         | lzma -c > $(catalogue)
+
+# The following sub-task rule creates a reference copy of each catalogue, for
+# comparison with the tentative "publication-ready" version, when checking for
+# changes introduced by resolution of "package-list" references.
+#
+generate-reference: FORCE
+       sed $(generate_catalogue) ${srcdir}/$(refname) \
+         > tmp/$(refname)
+
+# When any generated catalogue has been found to differ from its previously
+# published version, (if any), the following rule adds it to the schedule of
+# catalogues which should be republished, (or published for the first time).
+#
+select-for-publication: FORCE
+       cd unpublished && $(LN_S) -f ../$(refname) .
+
+# The remaining macros and rules define the sub-tasks for management of the
+# temporary files used to control the iterative resolution of "package-list"
+# references, and to capture modifications to be recorded in the issue log...
+#
+extract_log_file_header = '/^$(TAB)*$$/q;/^$(TAB)*[^\#]/q;p'
+extract_log_file_footer = 's/^$(TAB)*$$/break/;1,/^$(TAB)*[^\#]/d;/^$(TAB)*\#/p'
+
+issue.chk: FORCE
+       test -f issue.tmp && mv -f issue.tmp issue.new || true
+       test -f ${dir}/$@ && echo check > ${dir}/$@ || true
+
+issue.new: FORCE
+issue.tmp: issue.new
+       awk '$$3 != "$(refname)"' $^ > $@
+       echo $(PAD)$(hash) $(issue) $(refname) >> $@
+
+# ...with this final rule completing the recording of the current state of
+# publication, in the permanent issue log files.
+#
+update-issue-log: FORCE
+       sed -n $(extract_log_file_header) $(issue_log) > issue.new
+       LC_COLLATE=POSIX sort -k3 issue.tmp >> issue.new;
+       sed -n $(extract_log_file_footer) $(issue_log) >> issue.new;
+       rm -f $(issue_log) && mv issue.new $(issue_log)
 
 # $RCSfile$: end of file
index 6e7342f..c1363e9 100644 (file)
@@ -3,7 +3,7 @@
 # $Id$
 #
 # Written by Keith Marshall <keithmarshall@users.sourceforge.net>
-# Copyright (C) 2010, 2011, MinGW Project
+# Copyright (C) 2010, 2011, 2013, MinGW.org Project
 #
 #
 # Makefile template for generating mingw-get distribution manifests.
@@ -25,8 +25,9 @@
 # MinGW Project, accept liability for any damages, however caused,
 # arising from the use of this software.
 #
-all: @mingw_ac_subdirs@
+all: @mingw_ac_subdirs@ update-references
 
+@SET_MAKE@
 @mingw_ac_subdirs@: FORCE
        @if test -r $@/Makefile; then \
          cd $@; $(MAKE) $(MAKECMDGOALS); \
@@ -42,4 +43,35 @@ FORCE:
 #
 all-distfiles: all
 
+# To support optimised "mingw-get update", the package lists must be
+# dynamically updated, to correctly identify the latest issue of each
+# individual package catalogue file; the following rule, (which MUST
+# be invoked at top level), creates a "sed" script which may then be
+# paste the appropriate tags into the package list files.
+#
+ref = @top_srcdir@/*/
+issue.sed: FORCE
+       echo 's/issue=.*\(catalogue=\)/\\1/' > $@
+       for tag in `sed -n '/.*catalogue="/{s///;s/".*//p;}' ${ref}*.xml`; \
+         do awk /$$tag'.xml$$/{ \
+              print "s/catalogue=\"'$$tag'\"/issue=\"" $$2 "\" &/" \
+            }' ${ref}issue.log; \
+         done >> $@
+
+# The generated "sed" script must be applied iteratively, to each of
+# the catalogue files which contains "package-list" references, until
+# all cross references have been fully resolved...
+#
+update-references: FORCE
+       echo check > issue.chk
+       @while test x"`cat issue.chk`" != xclean; \
+         do echo clean > issue.chk; \
+            $(MAKE) update-local-references; \
+         done
+       rm -f issue.chk
+
+# ...considering all catalogues, in all registered sub-directories.
+#
+update-local-references: @mingw_ac_subdirs@
+
 # $RCSfile$: end of file
index 4b216f7..b296645 100644 (file)
@@ -7,7 +7,7 @@
 # $Id$
 #
 # Written by Keith Marshall <keithmarshall@users.sourceforge.net>
-# Copyright (C) 2010, MinGW Project
+# Copyright (C) 2010, 2013, MinGW.org Project
 #
 #
 # Makefile template for generating mingw-get distribution manifests.
@@ -30,6 +30,7 @@
 # arising from the use of this software.
 #
   srcdir = @srcdir@
-  include @top_builddir@/Makefile.comm
+  top_builddir = @top_builddir@
+  include ${top_builddir}/Makefile.comm
 #
 # $RCSfile$: end of file
index a7cc651..d94d46c 100644 (file)
@@ -3,7 +3,7 @@
 # $Id$
 #
 # Written by Keith Marshall  <keithmarshall@users.sourceforge.net>
-# Copyright (C) 2010, 2011, MinGW Project
+# Copyright (C) 2010, 2011, 2013, MinGW.org Project
 #
 #
 # Configuration script for mingw-dist
 # MinGW Project, accept liability for any damages, however caused,
 # arising from the use of this software.
 #
-  AC_INIT([mingw-dist],[1.0],[http://mingw.org/reporting_bugs])
+  AC_INIT([mingw-dist],[2.0],[http://mingw.org/reporting_bugs])
 
 # Check for required tools.
 #
+  m4_include([makeopts.m4])
+  MINGW_AC_MAKE_NO_PRINT_DIRECTORY
   AC_PROG_LN_S
 
 # Specify all makefiles which are to be created
diff --git a/makeopts.m4 b/makeopts.m4
new file mode 100644 (file)
index 0000000..2696646
--- /dev/null
@@ -0,0 +1,59 @@
+## makeopts.m4 -*- autoconf -*- vim: filetype=config
+##
+## $Id$
+##
+## Written by Keith Marshall <keithmarshall@users.sourceforge.net>
+## Copyright (C) 2013, MinGW.org Project
+##
+##
+## Autoconf macros to check for options supported by 'make'.
+##
+##
+## This is free software.  Permission is hereby granted to copy
+## and redistribute this software, either as is or in modified form,
+## subject only to the restrictions that the original author's notice
+## of copyright and disclaimers of warranty and of liability shall be
+## preserved without change in EVERY copy, and that modified copies
+## shall be clearly identified as such.
+##
+## This software is provided "as is", in the hope that it may prove
+## useful, but there is NO WARRANTY OF ANY KIND; not even an implied
+## WARRANTY OF MERCHANTABILITY, nor of FITNESS FOR A PARTICULAR PURPOSE.
+## Under no circumstances will the author, or the MinGW Project, accept
+## liability for any damages, however caused, arising from the use of
+## this software.
+
+
+# MINGW_AC_MAKE_OPTION_SUPPORTED( VARNAME, OPTION )
+# -------------------------------------------------
+# If OPTION is supported by make, set VARNAME=' OPTION', otherwise
+# set VARNAME to nothing; in either case, call AC_SUBST for VARNAME.
+#
+AC_DEFUN([MINGW_AC_MAKE_OPTION_SUPPORTED],
+[AC_REQUIRE([AC_PROG_MAKE_SET])dnl
+ AC_MSG_CHECKING([whether make supports the $2 option])
+ TAB=' ' $1=; mkdir conftest.dir
+ cat <<-EOF> conftest.dir/Makefile
+       conftest:
+       ${TAB}@\$(MAKE) $2 conftest-recursive
+
+       conftest-recursive:
+       ${TAB}@true
+       EOF
+ ( cd conftest.dir; make >/dev/null 2>&1 ) && ac_val=yes $1=' $2' || ac_val=no
+ rm -rf conftest.dir
+ AC_MSG_RESULT([$ac_val])dnl
+ AC_SUBST([$1])dnl
+])# MINGW_AC_MAKE_OPTION_SUPPORTED
+
+# MINGW_AC_MAKE_NO_PRINT_DIRECTORY
+# --------------------------------
+# Assign NO_PRINT_DIRECTORY=" --no-print-directory", if make supports
+# the --no-print-directory option, otherwise leave NO_PRINT_DIRECTORY
+# unassigned; in either case, call AC_SUBST for NO_PRINT_DIRECTORY.
+#
+AC_DEFUN([MINGW_AC_MAKE_NO_PRINT_DIRECTORY],
+[MINGW_AC_MAKE_OPTION_SUPPORTED([NO_PRINT_DIRECTORY],[--no-print-directory])dnl
+])# MINGW_AC_MAKE_NO_PRINT_DIRECTORY
+
+# $RCSfile$: end of file