Merge "Do all the zoneinfo.* file generation in Java."
This commit is contained in:
commit
551ca77e35
@ -5,7 +5,7 @@ import java.util.*;
|
|||||||
import libcore.io.BufferIterator;
|
import libcore.io.BufferIterator;
|
||||||
import libcore.util.ZoneInfo;
|
import libcore.util.ZoneInfo;
|
||||||
|
|
||||||
// usage: java ZoneCompiler <setup file> <top-level directory>
|
// usage: java ZoneCompiler <setup file> <data directory> <output directory> <tzdata version>
|
||||||
//
|
//
|
||||||
// Compile a set of tzfile-formatted files into a single file plus
|
// Compile a set of tzfile-formatted files into a single file plus
|
||||||
// an index file.
|
// an index file.
|
||||||
@ -121,12 +121,12 @@ public class ZoneCompactor {
|
|||||||
os.write( x & 0xff);
|
os.write( x & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZoneCompactor(String setupFilename, String dirName) throws Exception {
|
public ZoneCompactor(String setupFile, String dataDirectory, String outputDirectory, String version) throws Exception {
|
||||||
File zoneInfoFile = new File("zoneinfo.dat");
|
File zoneInfoFile = new File(outputDirectory, "zoneinfo.dat");
|
||||||
zoneInfoFile.delete();
|
zoneInfoFile.delete();
|
||||||
OutputStream zoneInfo = new FileOutputStream(zoneInfoFile);
|
OutputStream zoneInfo = new FileOutputStream(zoneInfoFile);
|
||||||
|
|
||||||
BufferedReader rdr = new BufferedReader(new FileReader(setupFilename));
|
BufferedReader rdr = new BufferedReader(new FileReader(setupFile));
|
||||||
|
|
||||||
String s;
|
String s;
|
||||||
while ((s = rdr.readLine()) != null) {
|
while ((s = rdr.readLine()) != null) {
|
||||||
@ -140,7 +140,7 @@ public class ZoneCompactor {
|
|||||||
} else {
|
} else {
|
||||||
String link = links.get(s);
|
String link = links.get(s);
|
||||||
if (link == null) {
|
if (link == null) {
|
||||||
File f = new File(dirName, s);
|
File f = new File(dataDirectory, s);
|
||||||
long length = f.length();
|
long length = f.length();
|
||||||
starts.put(s, new Integer(start));
|
starts.put(s, new Integer(start));
|
||||||
lengths.put(s, new Integer((int)length));
|
lengths.put(s, new Integer((int)length));
|
||||||
@ -168,7 +168,7 @@ public class ZoneCompactor {
|
|||||||
offsets.put(from, offsets.get(to));
|
offsets.put(from, offsets.get(to));
|
||||||
}
|
}
|
||||||
|
|
||||||
File idxFile = new File("zoneinfo.idx");
|
File idxFile = new File(outputDirectory, "zoneinfo.idx");
|
||||||
idxFile.delete();
|
idxFile.delete();
|
||||||
FileOutputStream idx = new FileOutputStream(idxFile);
|
FileOutputStream idx = new FileOutputStream(idxFile);
|
||||||
|
|
||||||
@ -194,14 +194,19 @@ public class ZoneCompactor {
|
|||||||
}
|
}
|
||||||
idx.close();
|
idx.close();
|
||||||
|
|
||||||
|
OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(new File(outputDirectory, "zoneinfo.version")), "US-ASCII");
|
||||||
|
writer.write(version);
|
||||||
|
writer.write('\n');
|
||||||
|
writer.close();
|
||||||
|
|
||||||
// System.out.println("maxLength = " + maxLength);
|
// System.out.println("maxLength = " + maxLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
if (args.length != 2) {
|
if (args.length != 4) {
|
||||||
System.err.println("usage: java ZoneCompactor <setup> <data dir>");
|
System.err.println("usage: java ZoneCompactor <setup file> <data directory> <output directory> <tzdata version>");
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
new ZoneCompactor(args[0], args[1]);
|
new ZoneCompactor(args[0], args[1], args[2], args[3]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,24 +88,13 @@ def upgrade_to(ftp, filename):
|
|||||||
setup.write('%s\n' % zone)
|
setup.write('%s\n' % zone)
|
||||||
setup.close()
|
setup.close()
|
||||||
|
|
||||||
print 'Calling ZoneCompactor...'
|
print 'Calling ZoneCompactor to update bionic from %s to %s...' % (current_tzdata_version(), version)
|
||||||
libcore_src_dir = '%s/../libcore/luni/src/main/java/' % bionic_dir
|
libcore_src_dir = '%s/../libcore/luni/src/main/java/' % bionic_dir
|
||||||
subprocess.check_call(['javac', '-d', '.',
|
subprocess.check_call(['javac', '-d', '.',
|
||||||
'%s/ZoneCompactor.java' % bionic_libc_tools_zoneinfo_dir,
|
'%s/ZoneCompactor.java' % bionic_libc_tools_zoneinfo_dir,
|
||||||
'%s/libcore/util/ZoneInfo.java' % libcore_src_dir,
|
'%s/libcore/util/ZoneInfo.java' % libcore_src_dir,
|
||||||
'%s/libcore/io/BufferIterator.java' % libcore_src_dir])
|
'%s/libcore/io/BufferIterator.java' % libcore_src_dir])
|
||||||
subprocess.check_call(['java', 'ZoneCompactor', 'setup', 'data'])
|
subprocess.check_call(['java', 'ZoneCompactor', 'setup', 'data', bionic_libc_zoneinfo_dir, version])
|
||||||
|
|
||||||
print 'Updating bionic from %s to %s...' % (current_tzdata_version(), version)
|
|
||||||
# Move the .dat and .idx files...
|
|
||||||
os.remove('%s/zoneinfo.dat' % bionic_libc_zoneinfo_dir)
|
|
||||||
shutil.move('zoneinfo.dat', bionic_libc_zoneinfo_dir)
|
|
||||||
os.remove('%s/zoneinfo.idx' % bionic_libc_zoneinfo_dir)
|
|
||||||
shutil.move('zoneinfo.idx', bionic_libc_zoneinfo_dir)
|
|
||||||
# Write the .version file...
|
|
||||||
zoneinfo_version = open('%s/zoneinfo.version' % bionic_libc_zoneinfo_dir, 'wb+')
|
|
||||||
zoneinfo_version.write('%s\n' % version)
|
|
||||||
zoneinfo_version.close()
|
|
||||||
|
|
||||||
|
|
||||||
# URL from "Sources for Time Zone and Daylight Saving Time Data"
|
# URL from "Sources for Time Zone and Daylight Saving Time Data"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user