Skip to contentSkip to conversation

how to set time zone

DISCUSSION Ni Qingliang 7 participants 15 messages Oct 28, 2011 – Nov 3, 2011

lore
Share & tools
lore
#0 lore raw

Hello All:

what is the right way to set timezone?

I have added tzdata into my image, and can find some variables in the etc, e.g. 'TZ'.

on my archlinux, I can set TIMEZONE in the rc.conf, which is used in rc.sysvinit (which will link the /etc/localtime using TIMEZONE).

what is the right place to locate similar setting code (e.g. link the /etc/localtime) in the yocto?

thanks!

Signature · 3 lines
Yi Qingliang
[email protected]
http://niqingliang2003.wordpress.com
#1 lore raw

2011/10/28 Ni Qingliang <[email protected]>:

Quoted 24 lines

Hello All:

what is the right way to set timezone?

I have added tzdata into my image, and can find some variables in the etc, e.g. 'TZ'.

on my archlinux, I can set TIMEZONE in the rc.conf, which is used in rc.sysvinit (which will link the /etc/localtime using TIMEZONE).

what is the right place to locate similar setting code (e.g. link the /etc/localtime) in the yocto?

thanks!

--
Yi Qingliang
[email protected]
http://niqingliang2003.wordpress.com

Quoted 5 lines

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

Hi,

you could try the following:
http://www.rwhitby.net/blog/nslu2-linux/setting-the-openmoko-timezone.html

Well this is the first entry when using google with "openembedded time zone", so please consider using search engines first next time.

Also this is the very same process like it is done on a desktop computer, googling for "set time zone linux command line" gives this result:
http://www.cyberciti.biz/faq/howto-linux-unix-change-setup-timezone-tz-variable/
Which shows more precise steps at the headline "Set timezone using /etc/localtime configuration file [any Linux distro]".

(Sorry for cross posting, but this was carried over to the OE-Core list)

Signature · 2 lines
Regards
Samuel
#2 lore raw

THANKS!

I still want the native support by oe-core/yocto:-). If no, I will try by myself.

Quoted 52 lines · Samuel Stirtzel

2011/10/28 Ni Qingliang <[email protected]>:

Quoted 24 lines

Hello All:

what is the right way to set timezone?

I have added tzdata into my image, and can find some variables in the etc, e.g. 'TZ'.

on my archlinux, I can set TIMEZONE in the rc.conf, which is used in rc.sysvinit (which will link the /etc/localtime using TIMEZONE).

what is the right place to locate similar setting code (e.g. link the /etc/localtime) in the yocto?

thanks!

--
Yi Qingliang
[email protected]
http://niqingliang2003.wordpress.com

Quoted 5 lines

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

Hi,

you could try the following:
http://www.rwhitby.net/blog/nslu2-linux/setting-the-openmoko-timezone.html

Well this is the first entry when using google with "openembedded time zone", so please consider using search engines first next time.

Also this is the very same process like it is done on a desktop computer, googling for "set time zone linux command line" gives this result:
http://www.cyberciti.biz/faq/howto-linux-unix-change-setup-timezone-tz-variable/
Which shows more precise steps at the headline "Set timezone using /etc/localtime configuration file [any Linux distro]".

(Sorry for cross posting, but this was carried over to the OE-Core list)

--
Regards
Samuel

Signature · 3 lines
Yi Qingliang
[email protected]
http://niqingliang2003.wordpress.com
#3 lore raw
Quoted 6 lines · Ni Qingliang

THANKS!

I still want the native support by oe-core/yocto:-). If no, I will try by myself.

I've asked three or four time the oe-core crow to improve the recipe...last one:

Quoted 10 lines · Joshua Lock

Per mailing requests, here are updates to the tzdata and gst-plugins-good recipes.

Joshua

The following changes since commit
95d0ff5e070c690314ab87665200099a52d37ebf:

tzdata: updated SRC_URI and update to 2011k (2011-10-18 11:16:58 -0700)

Thanks for the tzdata fix.
Now, we have the same recipes in meta-oe with a slightly different do_install and packaging: I'm referring to /etc/localtime and /etc/timezone:
which package do provide those in oe-core?

(We'll remove the tzdata/tzcodes from meta-oe once the recipes are matching)

Regards

Andrea

#4 lore raw

Setting the default TZ for the image is something that should be done in a post install script for the tzdata package or something similar.

Since the /etc/localtime is usually a copy/hardlink or symlink to the timezone data we don't want to package it up. Instead we want to perform the actions that a program running on the target system itself would use to change the timezone.

So I think the easiest approach is to add a system level configuration variable (set the default).

Then use this variable to populate the configuration file that specifies the system timezone... and then use the post install process to check the contents of a text file.

Alternatively do this via an initscript -- but for folks w/ read-only filesystems I'm not sure that will work.

--Mark

Quoted 42 lines · Andrea Adami

On Fri, Oct 28, 2011 at 9:05 AM, Ni Qingliang <[email protected] <mailto:[email protected]>> wrote:

THANKS!

I still want the native support by oe-core/yocto:-). If no, I will try by myself.

I've asked three or four time the oe-core crow to improve the recipe...last one:

On Wed, Oct 19, 2011 at 12:24 AM, Joshua Lock <[email protected] <mailto:[email protected]>> wrote:

    Per mailing requests, here are updates to the tzdata and gst-plugins-good
    recipes.

    Joshua

    The following changes since commit 95d0ff5e070c690314ab87665200099a52d37ebf:

     tzdata: updated SRC_URI and update to 2011k (2011-10-18 11:16:58 -0700)

Thanks for the tzdata fix.
Now, we have the same recipes in meta-oe with a slightly different do_install and packaging: I'm referring to /etc/localtime and /etc/timezone: which package do provide those in oe-core?

(We'll remove the tzdata/tzcodes from meta-oe once the recipes are matching)

Regards

Andrea

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

#5 lore raw

I'd like the 'system level configuration' solution.

the /etc/localtime/ link can be done when packaging rootfs (using the system level configuration).

Quoted 68 lines · Mark Hatle

Setting the default TZ for the image is something that should be done in a post install script for the tzdata package or something similar.

Since the /etc/localtime is usually a copy/hardlink or symlink to the timezone data we don't want to package it up. Instead we want to perform the actions that a program running on the target system itself would use to change the timezone.

So I think the easiest approach is to add a system level configuration variable (set the default).

Then use this variable to populate the configuration file that specifies the system timezone... and then use the post install process to check the contents of a text file.

Alternatively do this via an initscript -- but for folks w/ read-only filesystems I'm not sure that will work.

--Mark

Quoted 35 lines · Andrea Adami

On Fri, Oct 28, 2011 at 9:05 AM, Ni Qingliang <[email protected] <mailto:[email protected]>> wrote:

THANKS!

I still want the native support by oe-core/yocto:-). If no, I will try by myself.

I've asked three or four time the oe-core crow to improve the recipe...last one:

On Wed, Oct 19, 2011 at 12:24 AM, Joshua Lock <[email protected] <mailto:[email protected]>> wrote:

    Per mailing requests, here are updates to the tzdata and gst-plugins-good
    recipes.

    Joshua

    The following changes since commit 95d0ff5e070c690314ab87665200099a52d37ebf:

     tzdata: updated SRC_URI and update to 2011k (2011-10-18 11:16:58 -0700)

Thanks for the tzdata fix.
Now, we have the same recipes in meta-oe with a slightly different do_install and packaging: I'm referring to /etc/localtime and /etc/timezone: which package do provide those in oe-core?

(We'll remove the tzdata/tzcodes from meta-oe once the recipes are matching)

Regards

Quoted 7 lines

Andrea

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

Signature · 3 lines
Yi Qingliang
[email protected]
http://niqingliang2003.wordpress.com
#6 lore raw
Quoted 17 lines · Ni Qingliang

I'd like the 'system level configuration' solution.

the /etc/localtime/ link can be done when packaging rootfs (using the system level configuration).

Quoted 1 line · Mark Hatle

Setting the default TZ for the image is something that should be done in

a post

Quoted 3 lines

install script for the tzdata package or something similar.

Since the /etc/localtime is usually a copy/hardlink or symlink to the

timezone

Quoted 1 line

data we don't want to package it up. Instead we want to perform the

actions

Quoted 1 line

that a program running on the target system itself would use to change

the timezone.

Quoted 1 line
Quoted 15 lines
Quoted 1 line

So I think the easiest approach is to add a system level configuration

variable

Quoted 3 lines

(set the default).

Then use this variable to populate the configuration file that specifies

the

Quoted 1 line

system timezone... and then use the post install process to check the

contents

Quoted 6 lines

of a text file.

Alternatively do this via an initscript -- but for folks w/ read-only filesystems I'm not sure that will work.

--Mark

<cut>

Maybe I misunderstand "system level configuration" but in the meta-oe recipe we have

DEFAULT_TIMEZONE ?= "Europe/London"

Maybe UTC would be better?
Note how the variable is weak thus can be overridden in local.conf.

Secondly, why do it as post-install or at image do_rootfs stage when we have set the variable and are therefore able to provide sane defaults in do_install?

Other points before starting to write a patch:
-why is the recipe in oe-core doing chown -R root:root ${D} ?

-the logic around # libc is removing zoneinfo files from package
Is it only eglibc?

Regards

Andrea

#7 lore raw
Quoted 31 lines · Andrea Adami

On Mon, Oct 31, 2011 at 1:44 AM, Ni Qingliang <[email protected] <mailto:[email protected]>> wrote:

I'd like the 'system level configuration' solution.

the /etc/localtime/ link can be done when packaging rootfs (using the system level configuration).

On Fri, 2011-10-28 at 22:43 +0800, Mark Hatle wrote:
> Setting the default TZ for the image is something that should be done in a post
> install script for the tzdata package or something similar.
>
> Since the /etc/localtime is usually a copy/hardlink or symlink to the timezone > data we don't want to package it up. Instead we want to perform the actions > that a program running on the target system itself would use to change the timezone.
>
> So I think the easiest approach is to add a system level configuration variable
> (set the default).
>
> Then use this variable to populate the configuration file that specifies the > system timezone... and then use the post install process to check the contents > of a text file.
>
> Alternatively do this via an initscript -- but for folks w/ read-only > filesystems I'm not sure that will work.
>
> --Mark

Quoted 7 lines

<cut>

Maybe I misunderstand "system level configuration" but in the meta-oe recipe we have

DEFAULT_TIMEZONE ?= "Europe/London"

Maybe UTC would be better?

To me no timezone (which is UTC) is preferable as the system designer can then set the timezone, externally to the package(s).

Quoted 4 lines

Note how the variable is weak thus can be overridden in local.conf.

Secondly, why do it as post-install or at image do_rootfs stage when we have set the variable and are therefore able to provide sane defaults in do_install?

If it's done within a do_install, then the file (/etc/timezone) itself gets placed into the package. If it's in the package, then if/when someone upgrades the package from a feed the timezone gets reset to the previous value. That's a bug IMHO.

If it's done as a post-install script, then the timezone configuration can be evaluated and if one isn't set -- or there is no timezone file -- then we can set it to UTC or a similar default timezone.. (the value in the DEFAULT_TIMEZONE variable is reasonable in this approach.)

Quoted 2 lines

Other points before starting to write a patch:
-why is the recipe in oe-core doing chown -R root:root ${D} ?

There was an issue with the way the timezone data was extracted/constructed that it was have all of the build system's uid/gid preserved in the copy to the final install directory -- so when packaging incorrect usernames and groups were fed into the process causing issues.

A simple chown -R root:root ${D} ensured that all of the timezone data was owned by the root user (on the target).

Quoted 2 lines

-the logic around # libc is removing zoneinfo files from package
Is it only eglibc?

Timezone info is updated more often then the system libc. So the zoneinfo files are handled externally of the libc. This allows for easier updates over time.. (This is my guess, as I'm not familiar with exactly what this comment refers to.)

Quoted 12 lines

Regards

Andrea

|
|

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

#8 lore raw

maybe we can do the link in system booting, use the variable "TZ" to create the symlink /etc/localtime, just like archlinux. e.g. providing one script in /etc/rcS.d/ to create the symlink.

Quoted 94 lines · Mark Hatle
Quoted 31 lines · Andrea Adami

On Mon, Oct 31, 2011 at 1:44 AM, Ni Qingliang <[email protected] <mailto:[email protected]>> wrote:

I'd like the 'system level configuration' solution.

the /etc/localtime/ link can be done when packaging rootfs (using the system level configuration).

On Fri, 2011-10-28 at 22:43 +0800, Mark Hatle wrote:
> Setting the default TZ for the image is something that should be done in a post
> install script for the tzdata package or something similar.
>
> Since the /etc/localtime is usually a copy/hardlink or symlink to the timezone > data we don't want to package it up. Instead we want to perform the actions > that a program running on the target system itself would use to change the timezone.
>
> So I think the easiest approach is to add a system level configuration variable
> (set the default).
>
> Then use this variable to populate the configuration file that specifies the > system timezone... and then use the post install process to check the contents > of a text file.
>
> Alternatively do this via an initscript -- but for folks w/ read-only > filesystems I'm not sure that will work.
>
> --Mark

Quoted 7 lines

<cut>

Maybe I misunderstand "system level configuration" but in the meta-oe recipe we have

DEFAULT_TIMEZONE ?= "Europe/London"

Maybe UTC would be better?

To me no timezone (which is UTC) is preferable as the system designer can then set the timezone, externally to the package(s).

Quoted 4 lines

Note how the variable is weak thus can be overridden in local.conf.

Secondly, why do it as post-install or at image do_rootfs stage when we have set the variable and are therefore able to provide sane defaults in do_install?

If it's done within a do_install, then the file (/etc/timezone) itself gets placed into the package. If it's in the package, then if/when someone upgrades the package from a feed the timezone gets reset to the previous value. That's a bug IMHO.

If it's done as a post-install script, then the timezone configuration can be evaluated and if one isn't set -- or there is no timezone file -- then we can set it to UTC or a similar default timezone.. (the value in the DEFAULT_TIMEZONE variable is reasonable in this approach.)

Quoted 2 lines

Other points before starting to write a patch:
-why is the recipe in oe-core doing chown -R root:root ${D} ?

There was an issue with the way the timezone data was extracted/constructed that it was have all of the build system's uid/gid preserved in the copy to the final install directory -- so when packaging incorrect usernames and groups were fed into the process causing issues.

A simple chown -R root:root ${D} ensured that all of the timezone data was owned by the root user (on the target).

Quoted 2 lines

-the logic around # libc is removing zoneinfo files from package
Is it only eglibc?

Timezone info is updated more often then the system libc. So the zoneinfo files are handled externally of the libc. This allows for easier updates over time.. (This is my guess, as I'm not familiar with exactly what this comment refers to.)

Quoted 4 lines

Regards

Andrea

Quoted 8 lines

|
|

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

Signature · 3 lines
Yi Qingliang
[email protected]
https://niqingliang2003.wordpress.com
#9 lore raw
Quoted 3 lines · Ni Qingliang

maybe we can do the link in system booting, use the variable "TZ" to create the symlink /etc/localtime, just like archlinux. e.g. providing one script in /etc/rcS.d/ to create the symlink.

This ought to be done by image IMO; so a kind of post rootfs generation hook might be use allowing it to be set per-image.

I personally have this exactly use-case here at work.

Signature · 3 lines
Otavio Salvador                             O.S. Systems
E-mail: [email protected]  http://www.ossystems.com.br
Mobile: +55 53 9981-7854              http://projetos.ossystems.com.br
#10 lore raw

what is "IMO"?

Quoted 14 lines · Otavio Salvador
Quoted 3 lines · Ni Qingliang

maybe we can do the link in system booting, use the variable "TZ" to create the symlink /etc/localtime, just like archlinux. e.g. providing one script in /etc/rcS.d/ to create the symlink.

This ought to be done by image IMO; so a kind of post rootfs generation hook might be use allowing it to be set per-image.

I personally have this exactly use-case here at work.

--
Otavio Salvador O.S. Systems
E-mail: [email protected] http://www.ossystems.com.br
Mobile: +55 53 9981-7854 http://projetos.ossystems.com.br

Signature · 3 lines
Yi Qingliang
[email protected]
https://niqingliang2003.wordpress.com
#11 lore raw
Quoted 1 line · Ni Qingliang

what is "IMO"?

"In my opinion"

See http://www.internetslang.com/

I'm not suggesting reading the entire thing and using the slang in email though :)

Philip

Quoted 17 lines · Otavio Salvador
Quoted 14 lines · Ni Qingliang
Quoted 3 lines

maybe we can do the link in system booting, use the variable "TZ" to create the symlink /etc/localtime, just like archlinux. e.g. providing one script in /etc/rcS.d/ to create the symlink.

This ought to be done by image IMO; so a kind of post rootfs generation hook might be use allowing it to be set per-image.

I personally have this exactly use-case here at work.

--
Otavio Salvador O.S. Systems
E-mail: [email protected] http://www.ossystems.com.br
Mobile: +55 53 9981-7854 http://projetos.ossystems.com.br

#12 lore raw

thanks! :)

Quoted 30 lines · Philip Balister
Quoted 1 line · Ni Qingliang

what is "IMO"?

"In my opinion"

See http://www.internetslang.com/

I'm not suggesting reading the entire thing and using the slang in email though :)

Philip

Quoted 17 lines · Otavio Salvador
Quoted 14 lines · Ni Qingliang
Quoted 3 lines

maybe we can do the link in system booting, use the variable "TZ" to create the symlink /etc/localtime, just like archlinux. e.g. providing one script in /etc/rcS.d/ to create the symlink.

This ought to be done by image IMO; so a kind of post rootfs generation hook might be use allowing it to be set per-image.

I personally have this exactly use-case here at work.

--
Otavio Salvador O.S. Systems
E-mail: [email protected] http://www.ossystems.com.br
Mobile: +55 53 9981-7854 http://projetos.ossystems.com.br

Signature · 3 lines
Yi Qingliang
[email protected]
https://niqingliang2003.wordpress.com
#13 lore raw
In reply to Mark Hatle
Quoted 59 lines · Mark Hatle
Quoted 1 line · Andrea Adami

On Mon, Oct 31, 2011 at 1:44 AM, Ni Qingliang <

[email protected]

Quoted 9 lines

<mailto:[email protected]>> wrote:

I'd like the 'system level configuration' solution.

the /etc/localtime/ link can be done when packaging rootfs (using the system level configuration).

On Fri, 2011-10-28 at 22:43 +0800, Mark Hatle wrote:
> Setting the default TZ for the image is something that should be

done in a

Quoted 4 lines

post
> install script for the tzdata package or something similar. >
> Since the /etc/localtime is usually a copy/hardlink or symlink to

the timezone

Quoted 1 line
Quoted 1 line

data we don't want to package it up. Instead we want to perform

the actions

Quoted 1 line
Quoted 1 line

that a program running on the target system itself would use to

change the

Quoted 3 lines

timezone.
>
> So I think the easiest approach is to add a system level

configuration

Quoted 4 lines

variable
> (set the default).
>
> Then use this variable to populate the configuration file that

specifies the

Quoted 1 line
Quoted 1 line

system timezone... and then use the post install process to check

the contents

Quoted 3 lines
Quoted 3 lines

of a text file.

Alternatively do this via an initscript -- but for folks w/

read-only

Quoted 7 lines
Quoted 3 lines

filesystems I'm not sure that will work.

--Mark

<cut>

Maybe I misunderstand "system level configuration" but in the meta-oe

recipe we have

Quoted 4 lines

DEFAULT_TIMEZONE ?= "Europe/London"

Maybe UTC would be better?

To me no timezone (which is UTC) is preferable as the system designer can then
set the timezone, externally to the package(s).

Quoted 3 lines

Note how the variable is weak thus can be overridden in local.conf.

Secondly, why do it as post-install or at image do_rootfs stage when we

have set

Quoted 1 line

the variable and are therefore able to provide sane defaults in

Quoted 9 lines

do_install?

If it's done within a do_install, then the file (/etc/timezone) itself gets placed into the package. If it's in the package, then if/when someone upgrades
the package from a feed the timezone gets reset to the previous value.
That's a
bug IMHO.

Sure, I overlooked that!

Quoted 9 lines

If it's done as a post-install script, then the timezone configuration can be
evaluated and if one isn't set -- or there is no timezone file -- then we can
set it to UTC or a similar default timezone.. (the value in the DEFAULT_TIMEZONE
variable is reasonable in this approach.)

maybe "Factory" then?

See post-install script example:
http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/sys-libs/timezone-data/timezone-data-2011k.ebuild

Quoted 19 lines
Quoted 2 lines

Other points before starting to write a patch:
-why is the recipe in oe-core doing chown -R root:root ${D} ?

There was an issue with the way the timezone data was extracted/constructed that
it was have all of the build system's uid/gid preserved in the copy to the final
install directory -- so when packaging incorrect usernames and groups were fed
into the process causing issues.

A simple chown -R root:root ${D} ensured that all of the timezone data was owned
by the root user (on the target).

Quoted 2 lines

-the logic around # libc is removing zoneinfo files from package
Is it only eglibc?

Quoted 8 lines

Timezone info is updated more often then the system libc. So the zoneinfo files
are handled externally of the libc. This allows for easier updates over time..
(This is my guess, as I'm not familiar with exactly what this comment refers to.)

Comments in meta-oe recipe would suggest that apparently only eglibc is

removing zoneinfo file.

       # Only eglibc is removing zoneinfo files from package
        if [ "${LIBC}"x = "eglibc"x ] ; then
          cp -pP "${S}/zone.tab" ${D}${datadir}/zoneinfo
          cp -pP "${S}/iso3166.tab" ${D}${datadir}/zoneinfo
        fi

Being that we need the files on first boot, I'm not against providing 'Factory' settings during image do_rootfs or even in base-files. The settings of timezone and locale (and keyboard) are typically done by user on first boot, at least in graphical environments.

Thanks for your comments!

Regards

Andrea

#14 lore raw
In reply to Andrea Adami
Quoted 27 lines · Andrea Adami

On Fri, Oct 28, 2011 at 9:05 AM, Ni Qingliang <[email protected] <mailto:[email protected]>> wrote:

THANKS!

I still want the native support by oe-core/yocto:-). If no, I will try by myself.

I've asked three or four time the oe-core crow to improve the recipe...last one:

On Wed, Oct 19, 2011 at 12:24 AM, Joshua Lock <[email protected] <mailto:[email protected]>> wrote:

    Per mailing requests, here are updates to the tzdata and
    gst-plugins-good recipes.

    Joshua

    The following changes since commit
    95d0ff5e070c690314ab87665200099a52d37ebf:

      tzdata: updated SRC_URI and update to 2011k (2011-10-18 11:16:58
    -0700)
Quoted 7 lines

Thanks for the tzdata fix.
Now, we have the same recipes in meta-oe with a slightly different do_install and packaging: I'm referring to /etc/localtime and /etc/timezone: which package do provide those in oe-core?

(We'll remove the tzdata/tzcodes from meta-oe once the recipes are matching)

I would welcome such a patch.

Thanks
Sau!

Quoted 11 lines

Regards

Andrea

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core