am 32ea9fe5
: Merge "Put all the tzdata in one file."
* commit '32ea9fe5783e3cc9756205c0ac46482afc700a3d': Put all the tzdata in one file.
This commit is contained in:
commit
c2e4c310ff
3 changed files with 98 additions and 0 deletions
77
libc/tools/zoneinfo/generate-single-file
Executable file
77
libc/tools/zoneinfo/generate-single-file
Executable file
|
@ -0,0 +1,77 @@
|
|||
#!/usr/bin/python
|
||||
# Run with no arguments from any directory, with no special setup required.
|
||||
|
||||
import ftplib
|
||||
import hashlib
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import string
|
||||
import struct
|
||||
import subprocess
|
||||
import sys
|
||||
import tarfile
|
||||
import tempfile
|
||||
|
||||
# Find the bionic directory, searching upward from this script.
|
||||
bionic_libc_tools_zoneinfo_dir = os.path.realpath(os.path.dirname(sys.argv[0]))
|
||||
bionic_libc_tools_dir = os.path.dirname(bionic_libc_tools_zoneinfo_dir)
|
||||
bionic_libc_dir = os.path.dirname(bionic_libc_tools_dir)
|
||||
bionic_dir = os.path.dirname(bionic_libc_dir)
|
||||
bionic_libc_zoneinfo_dir = '%s/libc/zoneinfo' % bionic_dir
|
||||
if not os.path.isdir(bionic_libc_tools_zoneinfo_dir) or not os.path.isdir(bionic_libc_zoneinfo_dir):
|
||||
print "Couldn't find bionic/libc/tools/zoneinfo!"
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
|
||||
|
||||
def current_tzdata_version():
|
||||
return open('%s/zoneinfo.version' % bionic_libc_zoneinfo_dir).readline().rstrip('\n')
|
||||
|
||||
|
||||
# TODO: make the regular "generate" script just output this format directly.
|
||||
|
||||
# Open the output file.
|
||||
f = open('%s/tzdata' % bionic_libc_zoneinfo_dir, 'wb+')
|
||||
|
||||
# -- header
|
||||
# char[12] tzdata_version -- 'tzdata2012f\0'
|
||||
# u32 file_format_version -- probably won't need this, but just in case
|
||||
# u32 index_offset -- likewise
|
||||
# u32 data_offset
|
||||
# u32 zonetab_offset
|
||||
header_format = "! 12s i i i i"
|
||||
header_size = struct.calcsize(header_format)
|
||||
|
||||
index_offset = header_size
|
||||
index_bytes = open('%s/zoneinfo.idx' % bionic_libc_zoneinfo_dir, "rb").read()
|
||||
index_size = len(index_bytes)
|
||||
|
||||
data_offset = index_offset + index_size
|
||||
data_bytes = open('%s/zoneinfo.dat' % bionic_libc_zoneinfo_dir).read()
|
||||
data_size = len(data_bytes)
|
||||
|
||||
zonetab_offset = 0 # TODO: data_offset + data_size
|
||||
|
||||
tzdata_version = current_tzdata_version()
|
||||
file_format_version = 1
|
||||
|
||||
header = struct.pack(header_format, 'tzdata%s' % tzdata_version, file_format_version, index_offset, data_offset, zonetab_offset)
|
||||
f.write(header)
|
||||
|
||||
# -- index (@index_offset)
|
||||
# u8* index_bytes
|
||||
f.write(index_bytes)
|
||||
|
||||
# -- data (@data_offset)
|
||||
# u8* data_bytes
|
||||
f.write(data_bytes)
|
||||
|
||||
# TODO: zonetab
|
||||
# -- zonetab (@zonetab_offset)
|
||||
# u8* zonetab_bytes
|
||||
|
||||
f.close()
|
||||
|
||||
sys.exit(0)
|
|
@ -30,6 +30,15 @@ LOCAL_MODULE_TAGS := optional
|
|||
LOCAL_MODULE_PATH := $(TARGET_OUT)/usr/share/zoneinfo
|
||||
include $(BUILD_PREBUILT)
|
||||
|
||||
############################################
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := tzdata
|
||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
|
||||
LOCAL_SRC_FILES := $(LOCAL_MODULE)
|
||||
LOCAL_MODULE_CLASS := ETC
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_MODULE_PATH := $(TARGET_OUT)/usr/share/zoneinfo
|
||||
include $(BUILD_PREBUILT)
|
||||
|
||||
# The host build doesn't use bionic, but it does use bionic's zoneinfo data
|
||||
ifeq ($(WITH_HOST_DALVIK),true)
|
||||
|
@ -70,4 +79,16 @@ LOCAL_MODULE_STEM := $(LOCAL_SRC_FILES)
|
|||
LOCAL_MODULE_PATH := $(HOST_OUT)/usr/share/zoneinfo
|
||||
include $(BUILD_PREBUILT)
|
||||
|
||||
############################################
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := tzdata-host
|
||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
|
||||
LOCAL_IS_HOST_MODULE := true
|
||||
LOCAL_SRC_FILES := tzdata
|
||||
LOCAL_MODULE_CLASS := ETC
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_MODULE_STEM := $(LOCAL_SRC_FILES)
|
||||
LOCAL_MODULE_PATH := $(HOST_OUT)/usr/share/zoneinfo
|
||||
include $(BUILD_PREBUILT)
|
||||
|
||||
endif
|
||||
|
|
BIN
libc/zoneinfo/tzdata
Normal file
BIN
libc/zoneinfo/tzdata
Normal file
Binary file not shown.
Loading…
Reference in a new issue