土耳其时区更新

一、 更新tzdata文件

mtk平台

以土耳其伊斯坦布尔由+2变为+3为例

首先在external/icu/icu4c/source/data/misc/zoneinfo64.txt查找tzdata版本// tz version:  2015f

其次根据以上版本信息在网址ftp://ftp.iana.org/tz/releases/下载tzdata*.tar.gz找到对应的版本tzdata2015f.tar.gz和最新的tzdata2016h.tar.gz(需要改变的时区信息必须包含)

对比找到需要改的europe(土耳其伊斯坦布尔)文件中

Zone    Europe/Istanbul    1:55:52 -    LMT    1880
            1:56:56    -    IMT    1910 Oct # Istanbul Mean Time?
            2:00    Turkey    EE%sT    1978 Oct 15
            3:00    Turkey    TR%sT    1985 Apr 20 # Turkey Time
            2:00    Turkey    EE%sT    2007
            2:00    EU    EE%sT    2011 Mar 27  1:00u
            2:00    -    EET    2011 Mar 28  1:00u
            2:00    EU    EE%sT    2014 Mar 30  1:00u
            2:00    -    EET    2014 Mar 31  1:00u
            2:00    EU    EE%sT    2015 Oct 25  1:00u
            2:00    1:00    EEST    2015 Nov  8  1:00u
            2:00    EU    EE%sT    2016 Sep  7
            3:00    -    +03
Link    Europe/Istanbul    Asia/Istanbul    # Istanbul is in both continents.

把以上信息覆盖tzdata2015f.tar.gz中的europe部分即可

把修改后的tzdata2015f.tar.gz拷贝到路径\bionic\libc\tools\zoneinfo下
在bionic\libc\tools\zoneinfo\新建py文件,名字为update_tzdata_local.py

#Android L M

#!/usr/bin/python

"""Updates the timezone data held in bionic and ICU."""

import ftplib
import glob
import httplib
import os
import re
import shutil
import subprocess
import sys
import tarfile
import tempfile

regions = ['africa', 'antarctica', 'asia', 'australasia',
           'etcetera', 'europe', 'northamerica', 'southamerica',
           # These two deliberately come last so they override what came
           # before (and each other).
           'backward', 'backzone' ]

def CheckDirExists(dir, dirname):
  if not os.path.isdir(dir):
    print "Couldn't find %s (%s)!" % (dirname, dir)
    sys.exit(1)

bionic_libc_tools_zoneinfo_dir = os.path.realpath(os.path.dirname(sys.argv[0]))

# Find the bionic directory, searching upward from this script.
bionic_dir = os.path.realpath('%s/../../..' % bionic_libc_tools_zoneinfo_dir)
bionic_libc_zoneinfo_dir = '%s/libc/zoneinfo' % bionic_dir
CheckDirExists(bionic_libc_zoneinfo_dir, 'bionic/libc/zoneinfo')
CheckDirExists(bionic_libc_tools_zoneinfo_dir, 'bionic/libc/tools/zoneinfo')
print 'Found bionic in %s ...' % bionic_dir

# Find the icu4c directory.
icu_dir = os.path.realpath('%s/../external/icu/icu4c/source' % bionic_dir)
CheckDirExists(icu_dir, 'external/icu/icu4c/source')
print 'Found icu in %s ...' % icu_dir


def GetCurrentTzDataVersion():
  return open('%s/tzdata' % bionic_libc_zoneinfo_dir).read().split('\x00', 1)[0]


def WriteSetupFile():
  """Writes the list of zones that ZoneCompactor should process."""
  links = []
  zones = []
  for region in regions:
    for line in open('extracted/%s' % region):
      fields = line.split()
      if fields:
        if fields[0] == 'Link':
          links.append('%s %s %s' % (fields[0], fields[1], fields[2]))
          zones.append(fields[2])
        elif fields[0] == 'Zone':
          zones.append(fields[1])
  zones.sort()

  setup = open('setup', 'w')
  for link in sorted(set(links)):
    setup.write('%s\n' % link)
  for zone in sorted(set(zones)):
    setup.write('%s\n' % zone)
  setup.close()


def SwitchToNewTemporaryDirectory():
  tmp_dir = tempfile.mkdtemp('-tzdata')
  os.chdir(tmp_dir)
  print 'Created temporary directory "%s"...' % tmp_dir


def FtpRetrieveFile(ftp, filename):
  ftp.retrbinary('RETR %s' % filename, open(filename, 'wb').write)


def FtpRetrieveFileAndSignature(ftp, data_filename):
  """Downloads and repackages the given data from the given FTP server."""
  print 'Downloading data...'
  FtpRetrieveFile(ftp, data_filename)

  print 'Downloading signature...'
  signature_filename = '%s.asc' % data_filename
  FtpRetrieveFile(ftp, signature_filename)


def HttpRetrieveFile(http, path, output_filename):
  http.request("GET", path)
  f = open(output_filename, 'wb')
  f.write(http.getresponse().read())
  f.close()


def HttpRetrieveFileAndSignature(http, data_filename):
  """Downloads and repackages the given data from the given HTTP server."""
  path = "/time-zones/repository/releases/%s" % data_filename

  print 'Downloading data...'
  HttpRetrieveFile(http, path, data_filename)

  print 'Downloading signature...'
  signature_filename = '%s.asc' % data_filename
  HttpRetrievefile(http, "%s.asc" % path, signature_filename)


def BuildIcuToolsAndData(data_filename):
  # Keep track of the original cwd so we can go back to it at the end.
  original_working_dir = os.getcwd()

  # Create a directory to run 'make' from.
  icu_working_dir = '%s/icu' % original_working_dir
  os.mkdir(icu_working_dir)
  os.chdir(icu_working_dir)

  # Build the ICU tools.
  print 'Configuring ICU tools...'
  subprocess.check_call(['%s/runConfigureICU' % icu_dir, 'Linux'])

  # Run the ICU tools.
  os.chdir('tools/tzcode')

  # The tz2icu tool only picks up icuregions and icuzones in they are in the CWD
  for icu_data_file in [ 'icuregions', 'icuzones']:
    icu_data_file_source = '%s/tools/tzcode/%s' % (icu_dir, icu_data_file)
    icu_data_file_symlink = './%s' % icu_data_file
    os.symlink(icu_data_file_source, icu_data_file_symlink)

  shutil.copyfile('%s/%s' % (original_working_dir, data_filename), data_filename)
  print 'Making ICU data...'
  # The Makefile assumes the existence of the bin directory.
  os.mkdir('%s/bin' % icu_working_dir)
  subprocess.check_call(['make'])

  # Copy the source file to its ultimate destination.
  icu_txt_data_dir = '%s/data/misc' % icu_dir
  print 'Copying zoneinfo64.txt to %s ...' % icu_txt_data_dir
  shutil.copy('zoneinfo64.txt', icu_txt_data_dir)

  # Regenerate the .dat file.
  os.chdir(icu_working_dir)
  subprocess.check_call(['make', '-j32'])

  # Copy the .dat file to its ultimate destination.
  icu_dat_data_dir = '%s/stubdata' % icu_dir
  datfiles = glob.glob('data/out/tmp/icudt??l.dat')
  if len(datfiles) != 1:
    print 'ERROR: Unexpectedly found %d .dat files (%s). Halting.' % (len(datfiles), datfiles)
    sys.exit(1)
  datfile = datfiles[0]
  print 'Copying %s to %s ...' % (datfile, icu_dat_data_dir)
  shutil.copy(datfile, icu_dat_data_dir)

  # Switch back to the original working cwd.
  os.chdir(original_working_dir)


def CheckSignature(data_filename):
  signature_filename = '%s.asc' % data_filename
  print 'Verifying signature...'
  # If this fails for you, you probably need to import Paul Eggert's public key:
  # gpg --recv-keys ED97E90E62AA7E34
  subprocess.check_call(['gpg', '--trusted-key=ED97E90E62AA7E34', '--verify',
                         signature_filename, data_filename])


def BuildBionicToolsAndData(data_filename):
  new_version = re.search('(tzdata.+)\\.tar\\.gz', data_filename).group(1)

  print 'Extracting...'
  os.mkdir('extracted')
  tar = tarfile.open(data_filename, 'r')
  tar.extractall('extracted')

  print 'Calling zic(1)...'
  os.mkdir('data')
  zic_inputs = [ 'extracted/%s' % x for x in regions ]
  zic_cmd = ['zic', '-d', 'data' ]
  zic_cmd.extend(zic_inputs)
  subprocess.check_call(zic_cmd)

  WriteSetupFile()

  print 'Calling ZoneCompactor to update bionic to %s...' % new_version
  subprocess.check_call(['javac', '-d', '.',
                         '%s/ZoneCompactor.java' % bionic_libc_tools_zoneinfo_dir])
  subprocess.check_call(['java', 'ZoneCompactor',
                         'setup', 'data', 'extracted/zone.tab',
                         bionic_libc_zoneinfo_dir, new_version])


# Run with no arguments from any directory, with no special setup required.
# See http://www.iana.org/time-zones/ for more about the source of this data.
def main():
  print 'Looking for new tzdata...'

 

  # If you're several releases behind, we'll walk you through the upgrades
  # one by one.
  current_version = GetCurrentTzDataVersion()
  current_filename = '%s.tar.gz' % current_version
  filename = "tzdata2015f.tar.gz"


  BuildIcuToolsAndData(filename)
  BuildBionicToolsAndData(filename)
  print 'Look in %s and %s for new data files' % (bionic_dir, icu_dir)
  sys.exit(0)

 
if __name__ == '__main__':
  main()
执行update_tzdata_local.py

如果bionic\libc\tools\zoneinfo\有 extracted、data 2个文件夹存在, 需要删除,否则会报错
出现下面的log说明执行ok
如果出现错误,比如g++等莫名的错误,建议换机子编译吧,其实还是环境有问题,我换了3台终于搞定了
bionic\libc\zoneinfo\tzdata有更新就ok

高通平台

执行编译这个更简单
在网址ftp://ftp.iana.org/tz/releases/下载tzdata*.tar.gz找到最新的tzdata2016h.tar.gz(需要改变的时区信息必须包含)
update-tzdata.py
bionic\libc\zoneinfo\tzdata有更新就ok

二、 更新zoneinfo64文件
1、 在http://site.icu-project.org/下载最新的icu资源。

           (1)打开网址选择左侧列表框的DownloadICU

          (2)选择“offcial Release”中最新版本的ICU4C如54.1

          (3)下载“ICU4C Source Code Download”框中第一个包如“icu4c-54_l-data.zip”

2、 参考最新的ICU资源修改external\icu\icu4c\data\misc\zoneinfo64.txt
如修改Istanbul时区部分使用下面部分替换掉:
 /* Europe/Isle_of_Man */ :int { 455 } //Z#448
  /* Europe/Istanbul */ :table {
    transPre32:intvector { -1, 1454819544 }
    trans:intvector { -1869875816, -1693706400, -1680490800, -1570413600, -1552186800, -1538359200, -1522551600, -1507514400, -1490583600, -1440208800, -1428030000, -1409709600, -1396494000, -931140000, -922762800, -917834400, -892436400, -875844000, -857358000, -781063200, -764737200, -744343200, -733806000, -716436000, -701924400, -684986400, -670474800, -654141600, -639025200, -621828000, -606970800, -590032800, -575434800, -235620000, -228279600, -177732000, -165726000, 10533600, 23835600, 41983200, 55285200, 74037600, 87339600, 107910000, 121219200, 133920000, 152676000, 165362400, 183502800, 202428000, 215557200, 228866400, 245797200, 260316000, 277246800, 308779200, 323827200, 340228800, 354672000, 371678400, 386121600, 403128000, 428446800, 433886400, 482792400, 496702800, 512521200, 528246000, 543970800, 559695600, 575420400, 591145200, 606870000, 622594800, 638319600, 654649200, 670374000, 686098800, 701823600, 717548400, 733273200, 748998000, 764118000, 780447600, 796172400, 811897200, 828226800, 846370800, 859676400, 877820400, 891126000, 909270000, 922575600, 941324400, 954025200, 972774000, 985474800, 1004223600, 1017529200, 1035673200, 1048978800, 1067122800, 1080428400, 1099177200, 1111878000, 1130626800, 1143327600, 1162076400, 1174784400, 1193533200, 1206838800, 1224982800, 1238288400, 1256432400, 1269738000, 1288486800, 1301274000, 1319936400, 1332637200, 1351386000, 1364691600, 1382835600, 1396227600, 1414285200, 1427590800, 1446944400, 1459040400, 1473195600 }
    typeOffsets:intvector { 6952, 0, 7016, 0, 7200, 0, 7200, 3600, 10800, 0, 10800, 3600 }
    typeMap:bin { "010203020302030203020302030203020302030203020302030203020302030203020302030203020302030203020302030203020302030504050405040504050403020302030203020302030203020302030203020302030203020302030203020302030203020302030203020302030203020302030203020302030203020304" }
    links:intvector { 272, 454, 608 }
  } //Z#454

icu资源编译
(Android M)无需建立临时目录
1.进入到$AOSP/external/icu/icu4c/source/目录下的

2.在该目录下执行 (sudo)./runConfigureICU Linux命令生成MAKE文件

3.执行(sudo)make INCLUDE_UNI_CORE_DATA=1

(M)将生成的icudt55l.dat 文件拷贝到对应目录下名利如下

cp external/icu/icu4c/source/data/out/tmp/icudt55l.dat   $AOSP/external/icu/icu4c/source/stubdata

最后要把日期改了比2016 Sep  7之后,否则时区修改不起左右
到此结束。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值