]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Avoid race with parallel builds using same source directory in
authorDave Hart <hart@ntp.org>
Tue, 20 Jul 2010 18:02:12 +0000 (18:02 +0000)
committerDave Hart <hart@ntp.org>
Tue, 20 Jul 2010 18:02:12 +0000 (18:02 +0000)
  scripts/genver by using build directory for temporary files.

bk: 4c45e4a4ovP-LNjqlN7lc6pHRLrSjw

ChangeLog
Makefile.am
scripts/genver

index c121a8661a1c5a2b8f29e41f015f83824489b5d2..ec3c7bad93c0ff48193d7ccde03fcb6a3334ada2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,6 @@
 * [Bug 1586] ntpd 4.2.7p40 doesn't write to syslog after fork on QNX.
+* Avoid race with parallel builds using same source directory in
+  scripts/genver by using build directory for temporary files.
 (4.2.7p40) 2010/07/12 Released by Harlan Stenn <stenn@ntp.org>
 * [Bug 1395] ease ntpdate elimination with ntpd -w/--wait-sync
 * [Bug 1396] allow servers on ntpd command line like ntpdate
index 8b1b224097ec1e1097074afc73e640f7bdad96be..2106ce177443530e15995b3d7061a58f101b911e 100644 (file)
@@ -135,15 +135,15 @@ $(srcdir)/version: FRC.version
            case "$$x" in ''|$$y) ;; *) echo $$x > version ;; esac
 
 $(srcdir)/version.m4: $(srcdir)/packageinfo.sh
-       cd $(srcdir) && \
+       TEMPDIR=`pwd` && export TEMPDIR && cd $(srcdir) && \
        ./scripts/genver version.m4
 
 $(srcdir)/include/version.def: $(srcdir)/packageinfo.sh
-       cd $(srcdir) && \
+       TEMPDIR=`pwd` && export TEMPDIR && cd $(srcdir) && \
        ./scripts/genver include/version.def
 
 $(srcdir)/include/version.texi: $(srcdir)/packageinfo.sh
-       cd $(srcdir) && \
+       TEMPDIR=`pwd` && export TEMPDIR && cd $(srcdir) && \
        ./scripts/genver include/version.texi
 
 libtool: $(LIBTOOL_DEPS)
index ddf25cd415365bc5c1a7a1fb9ccc0c6dda628111..b41ce8c2657fb86364da9a4ef85b65a34f4d4f94 100755 (executable)
@@ -9,7 +9,9 @@ outputs=
 for i in $*
 do
     case "$i" in
-     -f) force=1 ;;
+     -f) 
+       force=1 
+       ;;
      version.m4)
        outputs="version.m4 $outputs"
        ;;
@@ -37,17 +39,23 @@ dversion=`scripts/VersionName`
 
 set +e
 
+# Create intermediate files in $TEMPDIR defaulting it to /tmp
+# if not set.  This avoids races when multiple builds run in
+# parallel on shared source.
+
+TEMPDIR=${TEMPDIR=/tmp}
+
 case "$outputs" in
  *version.m4*)
-    echo "m4_define([VERSION_NUMBER],[${dversion}])" > /tmp/version.m4+
-    cmp -s /tmp/version.m4+ version.m4
+    echo "m4_define([VERSION_NUMBER],[${dversion}])" > "${TEMPDIR}/version.m4+"
+    cmp -s "${TEMPDIR}/version.m4+" version.m4
     rc=$?
     case "$force$rc" in
      00)
-       rm -f /tmp/version.m4+
+       rm -f "${TEMPDIR}/version.m4+"
        ;;
      *)
-       mv /tmp/version.m4+ version.m4
+       mv "${TEMPDIR}/version.m4+" version.m4
        ;;
     esac
     ;;
@@ -55,15 +63,15 @@ esac
 
 case "$outputs" in
  *version.def*)
-    echo "version = '${dversion}';" > /tmp/version.def+
-    cmp -s /tmp/version.def+ include/version.def
+    echo "version = '${dversion}';" > "${TEMPDIR}/version.def+"
+    cmp -s "${TEMPDIR}/version.def+" include/version.def
     rc=$?
     case "$force$rc" in
      00)
-       rm -f /tmp/version.def+
+       rm -f "${TEMPDIR}/version.def+"
        ;;
      *)
-       mv /tmp/version.def+ include/version.def
+       mv "${TEMPDIR}/version.def+" include/version.def
        ;;
     esac
     ;;
@@ -71,17 +79,17 @@ esac
 
 case "$outputs" in
  *version.texi*)
-    echo "@set UPDATED `date +'%d %B %Y'`"     >  /tmp/version.texi+
-    echo "@set EDITION $dversion"              >> /tmp/version.texi+
-    echo "@set VERSION $dversion"              >> /tmp/version.texi+
-    cmp -s /tmp/version.texi+ include/version.texi
+    echo "@set UPDATED `date +'%d %B %Y'`"     >  "${TEMPDIR}/version.texi+"
+    echo "@set EDITION $dversion"              >> "${TEMPDIR}/version.texi+"
+    echo "@set VERSION $dversion"              >> "${TEMPDIR}/version.texi+"
+    cmp -s "${TEMPDIR}/version.texi+" include/version.texi
     rc=$?
     case "$force$rc" in
      00)
-       rm -f /tmp/version.texi+
+       rm -f "${TEMPDIR}/version.texi+"
        ;;
      *)
-       mv /tmp/version.texi+ include/version.texi
+       mv "${TEMPDIR}/version.texi+" include/version.texi
        ;;
     esac
     ;;