aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Baylis <charles.baylis@linaro.org>2017-03-20 17:28:48 +0000
committerCharles Baylis <charles.baylis@linaro.org>2017-03-21 17:28:00 +0000
commitad27d6559c4c5e72fc865a200c8fc4a4e437fe9d (patch)
treeb8f8622d14b184309b16c71ad5b4a99c9080753c
parent47fec7c56e1f36ac6baa10ba1924b895b85e252d (diff)
Read date only once.
Instead of reading the date multiple times, read the date once at startup, and then use that date as a reference for all subsequent uses of $(date) so that file and directory names use a consistent value for the date. Change-Id: I44a51c314df53a5d9b1cd14b66f31d10132e3090
-rw-r--r--lib/common.sh4
-rwxr-xr-xlib/configure.sh2
-rw-r--r--lib/globals.sh5
-rw-r--r--lib/package.sh6
-rwxr-xr-xlib/release.sh2
5 files changed, 11 insertions, 8 deletions
diff --git a/lib/common.sh b/lib/common.sh
index 5db305e0..56dcfb33 100644
--- a/lib/common.sh
+++ b/lib/common.sh
@@ -195,7 +195,7 @@ create_release_version()
local revision="@$(git -C ${srcdir} log --oneline | head -1 | cut -d ' ' -f 1)"
fi
- local date="$(date +%Y%m%d)"
+ local date="$(date --date="@${timestamp}" +%Y%m%d)"
# return the version string array
local rtag="${branch}${revision}-${date}"
@@ -253,7 +253,7 @@ create_release_tag()
# Only expand ${version} if it exists, so we don't get a spurious '-'.
local rtag="${component}-linaro${version:+-${version}}"
if test x"${release}" = x; then
- local date="$(date +%Y%m%d)"
+ local date="$(date --date="@${timestamp}" +%Y%m%d)"
if test x"${component}" = x"glibc"; then
local branch="$(echo ${branch} | tr '/' '-')"
fi
diff --git a/lib/configure.sh b/lib/configure.sh
index 631af51c..8c925b0a 100755
--- a/lib/configure.sh
+++ b/lib/configure.sh
@@ -93,7 +93,7 @@ configure_build()
# The release string is usually the date as well, but in YYYY.MM format.
# For snapshots we add the day field as well.
if test x"${release}" = x; then
- local date="$(date "+%Y.%m")"
+ local date="$(date --date="@${timestamp}" "+%Y.%m")"
else
local date="${release}"
fi
diff --git a/lib/globals.sh b/lib/globals.sh
index b6669776..c29a6a74 100644
--- a/lib/globals.sh
+++ b/lib/globals.sh
@@ -24,7 +24,10 @@ build="${build}"
host="${host:-${build}}"
target="${host}"
-date="$(date "+%Y.%m.%d")"
+# we need to read the date once, so that we don't have
+# varying dates when midnight occurs during a build.
+timestamp=$(date +%s)
+date="$(date --date="@${timestamp}" "+%Y.%m.%d")"
gcc="$(which gcc)"
host_gcc_version="$(${gcc} -v 2>&1 | tail -1)"
binutils="default"
diff --git a/lib/package.sh b/lib/package.sh
index b485e2cd..f877ed89 100644
--- a/lib/package.sh
+++ b/lib/package.sh
@@ -157,7 +157,7 @@ binary_gdb()
# Produce a binary toolchain tarball
# For daily builds produced by Jenkins, we use
-# $(date +%Y%m%d)-${BUILD_NUMBER}-${GIT_REVISION}
+# $(date --date="@${timestamp}" +%Y%m%d)-${BUILD_NUMBER}-${GIT_REVISION}
# e.g artifact_20130906-12-245f0869.tar.xz
binary_toolchain()
{
@@ -526,7 +526,7 @@ binutils_src_tarball()
done
if test x"${release}" != x; then
- local date="$(date +%Y%m%d)"
+ local date="$(date --date="@${timestamp}" +%Y%m%d)"
if test "$(echo $1 | grep -c '@')" -gt 0; then
local revision="$(echo $1 | cut -d '@' -f 2)"
fi
@@ -537,7 +537,7 @@ binutils_src_tarball()
else
local binutils_version="$(echo ${binutils_version} | sed -e "s:-2.*:-${date}:")"
fi
- local date="$(date +%Y%m%d)"
+ local date="$(date --date="@${timestamp}" +%Y%m%d)"
local tag="${binutils_version}-linaro${revision}-${date}"
else
local tag="binutils-linaro-${version}-${release}"
diff --git a/lib/release.sh b/lib/release.sh
index d5fd3e99..6dc61cf7 100755
--- a/lib/release.sh
+++ b/lib/release.sh
@@ -234,7 +234,7 @@ edit_changelogs()
local email="${BUILD_USER_ID}"
fi
- local date="$(date +%Y-%m-%d)"
+ local date="$(date --date="@${timestamp}" +%Y-%m-%d)"
# Get all the ChangeLog files.
local clogs="$(find ${basedir}/ -name ChangeLog)"