Skip to contentSkip to conversation

Include timezone information in build

RFC PATCH New Chris Packham 3 participants 8 messages Apr 30, 2015 – May 28, 2015 Kbuild

lore
Share & tools
lore
#0 lore raw

cover Include timezone information in build

Hi,

Recently an eagle-eyed tester pointed out to me that the build time reported in my u-boot build did not match the file timestamp on the server it was stored on. This is because at $dayjob we have a build farm with times set to UTC while the storage server was displaying the local time. In reality the times were the same but the timezones were not and there is no indication in the u-boot version about how to interpret the time.

This is my attempt to address the issue by defining U_BOOT_TZ along side U_BOOT_TIME and U_BOOT_DATE. I've kept the TZ portion separate because I thought there might some push pack on changing the version string. For my purposes I can display the TZ separately as long as it is defined by the build process. I've also elected to use %Z instead of %z as I feel that the timezone name is more friendly but that's just a personal preference so I wouldn't object to switching to the numeric representation if others feel strongly.

Chris Packham (1):
Makefile: Add U_BOOT_TZ and include in version

 Makefile          | 3 ++-
 include/version.h | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
Signature · 1 line
2.3.5
#1 lore raw

RFC PATCH 1/1 Makefile: Add U_BOOT_TZ and include in version

Define U_BOOT_TZ alongside U_BOOT_TIME and U_BOOT_DATE and use it to include the timezone in the version output.

---

 Makefile          | 3 ++-
 include/version.h | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
Makefile +2 -1
index 1e52008..c6b8d3f 100644
@@ -1230,7 +1230,8 @@ endef
 
 define filechk_timestamp.h
 	(LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"'; \
-	LC_ALL=C date +'#define U_BOOT_TIME "%T"')
+	LC_ALL=C date +'#define U_BOOT_TIME "%T"'; \
+	LC_ALL=C date +'#define U_BOOT_TZ "%Z"')
 endef
 
 $(version_h): include/config/uboot.release FORCE
include/version.h +1 -1
index d6c7cf2..777e9f6 100644
@@ -19,7 +19,7 @@
 #endif
 
 #define U_BOOT_VERSION_STRING U_BOOT_VERSION " (" U_BOOT_DATE " - " \
-	U_BOOT_TIME ")" CONFIG_IDENT_STRING
+	U_BOOT_TIME " " U_BOOT_TZ ")" CONFIG_IDENT_STRING
 
 #ifndef __ASSEMBLY__
 extern const char version_string[];
Signature · 1 line
2.3.5
#2 lore raw

RFC PATCH 1/1 Makefile: Add U_BOOT_TZ and include in version

Hi,

Quoted 38 lines · Chris Packham

Define U_BOOT_TZ alongside U_BOOT_TIME and U_BOOT_DATE and use it to include the timezone in the version output.

---

 Makefile          | 3 ++-
 include/version.h | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
Makefile +2 -1
index 1e52008..c6b8d3f 100644
@@ -1230,7 +1230,8 @@ endef
 
 define filechk_timestamp.h
        (LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"'; \
-       LC_ALL=C date +'#define U_BOOT_TIME "%T"')
+       LC_ALL=C date +'#define U_BOOT_TIME "%T"'; \
+       LC_ALL=C date +'#define U_BOOT_TZ "%Z"')
 endef
 
 $(version_h): include/config/uboot.release FORCE
include/version.h +1 -2
index d6c7cf2..777e9f6 100644
@@ -19,7 +19,7 @@
 #endif
 
 #define U_BOOT_VERSION_STRING U_BOOT_VERSION " (" U_BOOT_DATE " - " \
-       U_BOOT_TIME ")" CONFIG_IDENT_STRING
+       U_BOOT_TIME " " U_BOOT_TZ ")" CONFIG_IDENT_STRING
 
 #ifndef __ASSEMBLY__
 extern const char version_string[];
--
Quoted 2 lines

2.3.5

Any feedback? I see I've now missed the merge window (sending the patch as RFC on the day before it closed didn't help, sorry about that). But is the general idea OK for when I re-submit when the next merge window opens?

Thanks,
Chris

#3 lore raw

RFC PATCH 1/1 Makefile: Add U_BOOT_TZ and include in version

Hi Chris,

Quoted 38 lines · Chris Packham

Hi,

Quoted 35 lines · Chris Packham

Define U_BOOT_TZ alongside U_BOOT_TIME and U_BOOT_DATE and use it to include the timezone in the version output.

---

 Makefile          | 3 ++-
 include/version.h | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
Makefile +2 -1
index 1e52008..c6b8d3f 100644
@@ -1230,7 +1230,8 @@ endef
 
 define filechk_timestamp.h
        (LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"'; \
-       LC_ALL=C date +'#define U_BOOT_TIME "%T"')
+       LC_ALL=C date +'#define U_BOOT_TIME "%T"'; \
+       LC_ALL=C date +'#define U_BOOT_TZ "%Z"')
 endef
 
 $(version_h): include/config/uboot.release FORCE
include/version.h +1 -1
index d6c7cf2..777e9f6 100644
@@ -19,7 +19,7 @@
 #endif
 
 #define U_BOOT_VERSION_STRING U_BOOT_VERSION " (" U_BOOT_DATE " - " \
-       U_BOOT_TIME ")" CONFIG_IDENT_STRING
+       U_BOOT_TIME " " U_BOOT_TZ ")" CONFIG_IDENT_STRING
 
Quoted 10 lines
Quoted 5 lines
include/version.h +0 -1
 #ifndef __ASSEMBLY__
 extern const char version_string[];
--

2.3.5

Any feedback? I see I've now missed the merge window (sending the patch as RFC on the day before it closed didn't help, sorry about that). But is the general idea OK for when I re-submit when the next merge window opens?

Seems like a reasonable idea to me.

Regards,
Simon

#4 lore raw

PATCH v2 1/1 Makefile: Add U_BOOT_TZ and include in version

In reply to Chris Packham

Define U_BOOT_TZ alongside U_BOOT_TIME and U_BOOT_DATE and use it to include the timezone in the version output.

---
As per feedback from Tom I've switched to '%z' so that any size increase as a result of the timezone information is constant.

Changes in v2:
- Switched to '%z'
- Rebased against 2017.07-rc1

 Makefile          | 3 ++-
 include/version.h | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
Makefile +2 -1
index 24503ac..1f488aa 100644
@@ -1230,7 +1230,8 @@ endef
 
 define filechk_timestamp.h
 	(LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"'; \
-	LC_ALL=C date +'#define U_BOOT_TIME "%T"')
+	LC_ALL=C date +'#define U_BOOT_TIME "%T"'; \
+	LC_ALL=C date +'#define U_BOOT_TZ "%z"')
 endef
 
 $(version_h): include/config/uboot.release FORCE
include/version.h +1 -1
index d6c7cf2..777e9f6 100644
@@ -19,7 +19,7 @@
 #endif
 
 #define U_BOOT_VERSION_STRING U_BOOT_VERSION " (" U_BOOT_DATE " - " \
-	U_BOOT_TIME ")" CONFIG_IDENT_STRING
+	U_BOOT_TIME " " U_BOOT_TZ ")" CONFIG_IDENT_STRING
 
 #ifndef __ASSEMBLY__
 extern const char version_string[];
Signature · 1 line
2.3.5
#5 lore raw

PATCH v2 1/1 Makefile: Add U_BOOT_TZ and include in version

Quoted 5 lines · Chris Packham

Define U_BOOT_TZ alongside U_BOOT_TIME and U_BOOT_DATE and use it to include the timezone in the version output.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150528/4147a183/attachment.sig>
#6 lore raw

cover Include timezone information in build

In reply to Chris Packham
Quoted 11 lines · Chris Packham

Hi,

Recently an eagle-eyed tester pointed out to me that the build time reported in my u-boot build did not match the file timestamp on the server it was stored on. This is because at $dayjob we have a build farm with times set to UTC while the storage server was displaying the local time. In reality the times were the same but the timezones were not and there is no indication in the u-boot version about how to interpret the time.

Quoted 8 lines

This is my attempt to address the issue by defining U_BOOT_TZ along side U_BOOT_TIME and U_BOOT_DATE. I've kept the TZ portion separate because I thought there might some push pack on changing the version string. For my purposes I can display the TZ separately as long as it is defined by the build process. I've also elected to use %Z instead of %z as I feel that the timezone name is more friendly but that's just a personal preference so I wouldn't object to switching to the numeric representation if others feel strongly.

Concept is fine, I'd actually prefer %z so that the size increase is constant at least. Please do that in a non-RFC v2 and I'll pick it up, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150508/b8c86d16/attachment.sig>
#7 lore raw

cover Include timezone information in build

Hi Tom,

Quoted 21 lines · Tom Rini
Quoted 11 lines · Chris Packham

Hi,

Recently an eagle-eyed tester pointed out to me that the build time reported in my u-boot build did not match the file timestamp on the server it was stored on. This is because at $dayjob we have a build farm with times set to UTC while the storage server was displaying the local time. In reality the times were the same but the timezones were not and there is no indication in the u-boot version about how to interpret the time.

Quoted 8 lines

This is my attempt to address the issue by defining U_BOOT_TZ along side U_BOOT_TIME and U_BOOT_DATE. I've kept the TZ portion separate because I thought there might some push pack on changing the version string. For my purposes I can display the TZ separately as long as it is defined by the build process. I've also elected to use %Z instead of %z as I feel that the timezone name is more friendly but that's just a personal preference so I wouldn't object to switching to the numeric representation if others feel strongly.

Quoted 3 lines

Concept is fine, I'd actually prefer %z so that the size increase is constant at least. Please do that in a non-RFC v2 and I'll pick it up, thanks!

v2 has been sent. After I sent it out of curiosity, I looked up the POSIX definition of date[1] and it looks as though '%z' is not part of the spec ('%Z' is). However '%z' is part of the POSIX definition of strfttime[2]. In practice I'm not sure how much it matters. I know the GNU date command supports it and it looks like the freebsd one also does.

I'm not sure which other environments people are using to build u-boot, hopefully any other environments pass the format string to strftime(). Just thought I'd bring it up in case someone reports an issue down the line.

Thanks,
Chris
--
[1] - http://pubs.opengroup.org/onlinepubs/9699919799/utilities/date.html
[2] - http://pubs.opengroup.org/onlinepubs/9699919799/functions/strftime.html