Bug 6544

Summary: Rewrite eglibc-utils/usr/bin/tzselect as a posix sh
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Hongxu Jia <hongxu.jia>
Component: coreAssignee: Hongxu Jia <hongxu.jia>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: Medium CC: liezhi.yang, mark.hatle, meta.mr.watcher, meta.watcher
Version: 1.7   
Target Milestone: 1.7 M2   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Don't know

Description Hongxu Jia 2014-07-17 02:26:44 UTC
Found that eglibc-utils/usr/bin/tzselect is a bash script

The problem is that this would cause bash installed to meta-toolchain,
the dependencies chain is:

meta-toolchain -> eglibc-utils -> bash

We should eliminate bash dependencies in anything core to a tiny system.

The eglibc-utils also provides eglibc-utils/usr/bin/zdump,
eglibc-utils/usr/bin/zic which all of them belonged to tzcode,
so we should split the three utils as tzcode package.
Comment 1 Hongxu Jia 2014-07-17 05:28:02 UTC
If we want to let tzselect work, we have to do:

1. Modify busybox defconfig to enable math functions of awk, 
it was required by tzselect.
...
CONFIG_FEATURE_AWK_LIBM=y
...

Here is the error if we not enable that:
...
root@qemuarm:~# tzselect -c +4852+00220
awk: cmd. line:39: Math support is not compiled in
...

2. Rewrite eglibc-utils/usr/bin/tzselect as a posix sh
Comment 3 Hongxu Jia 2014-07-21 01:16:45 UTC
Test Steps:

1. Vim local.conf
The tzdata supplyed timezone info.
...
MACHINE ?= "qemuarm"
IMAGE_FEATURES += "ssh-server-dropbear"
IMAGE_INSTALL_append = " tzcode tzdata"
...

2. bitbake core-image-minimal

3. start qemu and ssh target

4. Use busybox as default shell(bash not installed any more)
root@qemuarm:~# ls /bin/sh -al
lrwxrwxrwx    1 root     root            19 Jul 17 03:45 /bin/sh -> /bin/busybox.nosuid

5. Use busybox's awk by default
root@qemuarm:~# which awk
/usr/bin/awk
root@qemuarm:~# ls -al /usr/bin/awk
lrwxrwxrwx    1 root     root            19 Jul 17 03:45 /usr/bin/awk -> /bin/busybox.nosuid

6. test case 1: set timezone directly
...
root@qemuarm:~# tzselect -c +4852+00220
Please identify a location so that time zone rules can be set correctly.
Please select one of the following time zone regions,
listed roughly in increasing order of distance from +4852+00220.
 1) France
 2) Belgium
 3) Luxembourg
 4) Jersey
 5) Britain (UK)
 6) Guernsey
 7) Netherlands
 8) Germany - Busingen
 9) Switzerland
10) Liechtenstein
#? 1

The following information has been given:

	coord +4852+00220
	France

Therefore TZ='Europe/Paris' will be used.
Local time is now:	Wed Jul 16 13:42:29 CEST 2014.
Universal Time is now:	Wed Jul 16 11:42:29 UTC 2014.
Is the above information OK?
1) Yes
2) No
#? 
1) Yes
2) No
#? 1

You can make this change permanent for yourself by appending the line
	TZ='Europe/Paris'; export TZ
to the file '.profile' in your home directory; then log out and log in again.

Here is that TZ value again, this time on standard output so that you
can use the /usr/bin/tzselect command in shell scripts:
Europe/Paris
....

7. test case 2: set timezone interactively
...
root@qemuarm:~# tzselect 
Please identify a location so that time zone rules can be set correctly.
Please select a continent, ocean, "coord", or "TZ".
 1) Africa
 2) Americas
 3) Antarctica
 4) Arctic Ocean
 5) Asia
 6) Atlantic Ocean
 7) Australia
 8) Europe
 9) Indian Ocean
10) Pacific Ocean
11) coord - I want to use geographical coordinates.
12) TZ - I want to specify the time zone using the Posix TZ format.
#? 2
Please select a country whose clocks agree with yours.
 1) Anguilla
 2) Antigua & Barbuda
 3) Argentina
 4) Aruba
 5) Bahamas
 6) Barbados
 7) Belize
 8) Bolivia
 9) Brazil
10) Canada
11) Caribbean Netherlands
12) Cayman Islands
13) Chile
14) Colombia
15) Costa Rica
16) Cuba
17) Curacao
18) Dominica
19) Dominican Republic
20) Ecuador
21) El Salvador
22) French Guiana
23) Greenland
24) Grenada
25) Guadeloupe
26) Guatemala
27) Guyana
28) Haiti
29) Honduras
30) Jamaica
31) Martinique
32) Mexico
33) Montserrat
34) Nicaragua
35) Panama
36) Paraguay
37) Peru
38) Puerto Rico
39) St Barthelemy
40) St Kitts & Nevis
41) St Lucia
42) St Maarten (Dutch part)
43) St Martin (French part)
44) St Pierre & Miquelon
45) St Vincent
46) Suriname
47) Trinidad & Tobago
48) Turks & Caicos Is
49) United States
50) Uruguay
51) Venezuela
52) Virgin Islands (UK)
53) Virgin Islands (US)
#? 49
Please select one of the following time zone regions.
 1) Eastern Time
 2) Eastern Time - Michigan - most locations
 3) Eastern Time - Kentucky - Louisville area
 4) Eastern Time - Kentucky - Wayne County
 5) Eastern Time - Indiana - most locations
 6) Eastern Time - Indiana - Daviess, Dubois, Knox & Martin Counties
 7) Eastern Time - Indiana - Pulaski County
 8) Eastern Time - Indiana - Crawford County
 9) Eastern Time - Indiana - Pike County
10) Eastern Time - Indiana - Switzerland County
11) Central Time
12) Central Time - Indiana - Perry County
13) Central Time - Indiana - Starke County
14) Central Time - Michigan - Dickinson, Gogebic, Iron & Menominee Counties
15) Central Time - North Dakota - Oliver County
16) Central Time - North Dakota - Morton County (except Mandan area)
17) Central Time - North Dakota - Mercer County
18) Mountain Time
19) Mountain Time - south Idaho & east Oregon
20) Mountain Standard Time - Arizona (except Navajo)
21) Pacific Time
22) Alaska Time
23) Alaska Time - Alaska panhandle
24) Alaska Time - southeast Alaska panhandle
25) Alaska Time - Alaska panhandle neck
26) Alaska Time - west Alaska
27) Aleutian Islands
28) Metlakatla Time - Annette Island
29) Hawaii
#? 1

The following information has been given:

	United States
	Eastern Time

Therefore TZ='America/New_York' will be used.
Local time is now:	Thu Jul 17 00:33:16 EDT 2014.
Universal Time is now:	Thu Jul 17 04:33:16 UTC 2014.
Is the above information OK?
1) Yes
2) No
#? 1

You can make this change permanent for yourself by appending the line
	TZ='America/New_York'; export TZ
to the file '.profile' in your home directory; then log out and log in again.

Here is that TZ value again, this time on standard output so that you
can use the /usr/bin/tzselect command in shell scripts:
America/New_York
...

//Hongxu