From: Dave Hart Date: Tue, 20 Jul 2010 18:02:12 +0000 (+0000) Subject: Avoid race with parallel builds using same source directory in X-Git-Tag: NTP_4_2_7P41~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=81f3c36e67d6e90f6516ed04ecdd3ae42063fc89;p=thirdparty%2Fntp.git Avoid race with parallel builds using same source directory in scripts/genver by using build directory for temporary files. bk: 4c45e4a4ovP-LNjqlN7lc6pHRLrSjw --- diff --git a/ChangeLog b/ChangeLog index c121a8661..ec3c7bad9 100644 --- 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 * [Bug 1395] ease ntpdate elimination with ntpd -w/--wait-sync * [Bug 1396] allow servers on ntpd command line like ntpdate diff --git a/Makefile.am b/Makefile.am index 8b1b22409..2106ce177 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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) diff --git a/scripts/genver b/scripts/genver index ddf25cd41..b41ce8c26 100755 --- a/scripts/genver +++ b/scripts/genver @@ -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 ;;