Skip to content

Commit 07f90f8

Browse files
committed
Initial development.
1 parent 2c59ebd commit 07f90f8

File tree

9 files changed

+453
-0
lines changed

9 files changed

+453
-0
lines changed

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
# don't modify the line endings of generated zoneinfo files (they use CRLF according to the specification).
3+
/zoneinfo/** text eol=crlf

.github/workflows/build.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Build and run on GitHub Actions
2+
3+
on:
4+
push:
5+
branches: [ "*" ]
6+
7+
jobs:
8+
build:
9+
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v3
14+
15+
- uses: actions/checkout@v3
16+
with:
17+
repository: libical/vzic
18+
ref: 7d8cd6a9307853da86998a8c42d88f38c525a894
19+
path: build/vzic
20+
21+
- name: Get settings into GitHub Actions
22+
run: |
23+
. ./settings.config
24+
echo "VZIC_RELEASE_NAME=$VZIC_RELEASE_NAME" >> $GITHUB_ENV
25+
26+
- name: Run build script
27+
run: ./build.sh
28+
29+
- name: Commit and push changes
30+
run: |
31+
git config --global user.name 'GitHub Actions'
32+
git config --global user.email '[email protected]'
33+
git add .
34+
git commit -am "Update tzdata and zoneinfo to version $VZIC_RELEASE_NAME."
35+
git push
36+
37+
- name: Archive artifacts
38+
uses: actions/upload-artifact@v3
39+
with:
40+
name: tzdbics_${{ env.VZIC_RELEASE_NAME }}
41+
path: build/out/

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

Makefile

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
2+
#
3+
# You will need to set this to the directory that the Olson timezone data
4+
# files are in.
5+
#
6+
OLSON_DIR ?= tzdata2021a
7+
8+
9+
# This is used as the PRODID property on the iCalendar files output.
10+
# It identifies the product which created the iCalendar objects.
11+
# So you need to substitute your own organization name and product.
12+
PRODUCT_ID ?= -//citadel.org//NONSGML Citadel calendar//EN
13+
14+
# This is what libical-evolution uses.
15+
#PRODUCT_ID = -//Ximian//NONSGML Evolution Olson-VTIMEZONE Converter//EN
16+
17+
18+
# This is used to create unique IDs for each VTIMEZONE component.
19+
# The prefix is put before each timezone city name. It should start and end
20+
# with a '/'. The first part, i.e. 'myorganization.org' below, should be
21+
# a unique vendor ID, e.g. use a hostname. The part after that can be
22+
# anything you want. We use a date and version number for libical. The %D
23+
# gets expanded to today's date. There is also a vzic-merge.pl which can be
24+
# used to merge changes into a master set of VTIMEZONEs. If a VTIMEZONE has
25+
# changed, it bumps the version number on the end of this prefix. */
26+
TZID_PREFIX ?= /citadel.org/%D_1/
27+
28+
# This is what libical-evolution uses.
29+
#TZID_PREFIX = /softwarestudio.org/Olson_%D_1/
30+
31+
# This is used to indicate how timezone aliases (indicated by a Link line
32+
# in Olson files) should be generated: The default is to symbolically link
33+
# the Link zone file to its authorative zone. Alternatively, if set to 0,
34+
# a VTIMEZONE file is generated for each Link.
35+
CREATE_SYMLINK ?= 1
36+
37+
# This indicates if top-level timezone aliases (a timezone name without
38+
# any '/' such as "EST5EDT") should be ignored. If 0, a VTIMEZONE is
39+
# generated also for top-level aliases. This option only has
40+
# an effect if CREATE_SYMLINK is 0, and mainly is useful for backward
41+
# compatibility with previous vzic versions.
42+
IGNORE_TOP_LEVEL_LINK ?= 1
43+
44+
# Set any -I include directories to find the libical header files, and the
45+
# libical library to link with. You only need these if you want to run the
46+
# tests. You may need to change the '#include <ical.h>' line at the top of
47+
# test-vzic.c as well.
48+
LIBICAL_CFLAGS = -I/usr/local/include/libical -L/usr/local/lib64
49+
#LIBICAL_LDADD = -lical-evolution
50+
LIBICAL_LDADD = -lical -lpthread
51+
52+
53+
#
54+
# You shouldn't need to change the rest of the file.
55+
#
56+
57+
GLIB_CFLAGS = `pkg-config --cflags glib-2.0`
58+
GLIB_LDADD = `pkg-config --libs glib-2.0`
59+
60+
CFLAGS = -g -DOLSON_DIR=\"$(OLSON_DIR)\" -DPRODUCT_ID='"$(PRODUCT_ID)"'
61+
CFLAGS += -DTZID_PREFIX='"$(TZID_PREFIX)"'
62+
CFLAGS += -DCREATE_SYMLINK=$(CREATE_SYMLINK)
63+
CFLAGS += -DIGNORE_TOP_LEVEL_LINK=$(IGNORE_TOP_LEVEL_LINK)
64+
CFLAGS += $(GLIB_CFLAGS) $(LIBICAL_CFLAGS)
65+
66+
OBJECTS = vzic.o vzic-parse.o vzic-dump.o vzic-output.o
67+
68+
all: vzic
69+
70+
vzic: $(OBJECTS)
71+
$(CC) $(OBJECTS) $(GLIB_LDADD) -o vzic
72+
73+
test-vzic: test-vzic.o
74+
$(CC) test-vzic.o $(LIBICAL_LDADD) -o test-vzic
75+
76+
# Dependencies.
77+
$(OBJECTS): vzic.h
78+
vzic.o vzic-parse.o: vzic-parse.h
79+
vzic.o vzic-dump.o: vzic-dump.h
80+
vzic.o vzic-output.o: vzic-output.h
81+
82+
test-parse: vzic
83+
./vzic-dump.pl $(OLSON_DIR)
84+
./vzic --dump --pure
85+
@echo
86+
@echo "#"
87+
@echo "# If either of these diff commands outputs anything there may be a problem."
88+
@echo "#"
89+
diff -ru zoneinfo/ZonesPerl zoneinfo/ZonesVzic
90+
diff -ru zoneinfo/RulesPerl zoneinfo/RulesVzic
91+
92+
test-changes: vzic test-vzic
93+
./test-vzic --dump-changes
94+
./vzic --dump-changes --pure
95+
@echo
96+
@echo "#"
97+
@echo "# If this diff command outputs anything there may be a problem."
98+
@echo "#"
99+
diff -ru zoneinfo/ChangesVzic test-output
100+
101+
clean:
102+
-rm -rf vzic $(OBJECTS) *~ ChangesVzic RulesVzic ZonesVzic RulesPerl ZonesPerl test-vzic test-vzic.o
103+
104+
.PHONY: clean perl-dump test-parse
105+
106+

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# IANA Time Zone Database to iCalendar Translation Database
2+
3+
This repo tracks releases of the [IANA Time Zone Database](https://www.iana.org/time-zones) together with the corresponding translations to the iCalendar format (as defined in RFC 5545).
4+
5+
The translation is performed using [libical's VZIC utility](https://github.com/libical/vzic).
6+
7+
## Usage
8+
9+
The intended usage is as follows:
10+
* Upon a new release of the IANA Time Zone Database update `settings.config`. Update `VZIC_RELEASE_NAME` to match the name of the new release (e.g. `2022a`).
11+
* Commit and push the change to GitHub.
12+
13+
This will trigger a GitHub Workflow that does the following
14+
* Download the specified version of the IANA Time Zone DB.
15+
* Checkout, build and run vzic
16+
* Merge the newly generated zoneinfo with the previous version, in order to keep TZIDs of unchanged time zones.
17+
* Commit and push the updated tzdata and zoneinfo back to the repo on GitHub.

build.sh

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/bin/bash
2+
3+
4+
# This script does
5+
#
6+
# * download the specified tzdata archive
7+
# * download the specified master zoneinfo archive
8+
# * build vzic
9+
# * run vzic on the downloaded tzdata
10+
# * merge the new zoneinfo into the master zoneinfo
11+
# * archive the result and copy it to the specified output dir
12+
#
13+
# The URLS for the master zoneinfo and new tzdata are read from settings.config file.
14+
#
15+
16+
set -e
17+
18+
# read settings file
19+
. ./settings.config
20+
21+
echo "Building $VZIC_RELEASE_NAME"
22+
23+
mkdir -p build/out
24+
25+
if [[ ${VZIC_TZDATA_ARCHIVE_URL} ]]; then
26+
echo "Downloading tzdata from $VZIC_TZDATA_ARCHIVE_URL"
27+
wget -q -O build/tzdata$VZIC_RELEASE_NAME.tar.gz $VZIC_TZDATA_ARCHIVE_URL
28+
export VZIC_TZDATA_ARCHIVE_PATH=build/tzdata$VZIC_RELEASE_NAME.tar.gz
29+
fi
30+
31+
if [[ ${VZIC_TZDATA_ARCHIVE_PATH} ]]; then
32+
echo "Extracting new tzdata"
33+
if [ -d tzdata ]; then rm -rf tzdata; fi
34+
mkdir -p tzdata
35+
tar -xzf $VZIC_TZDATA_ARCHIVE_PATH -C tzdata
36+
37+
cp $VZIC_TZDATA_ARCHIVE_PATH build/out
38+
fi
39+
40+
echo "Building vzic"
41+
make -C `pwd`/build/vzic -B OLSON_DIR=tzdata PRODUCT_ID="$VZIC_PRODID" TZID_PREFIX="$VZIC_TZID_PREFIX"
42+
43+
echo "Running vzic"
44+
if [ -d build/zoneinfo ]; then rm -r build/zoneinfo; fi
45+
mkdir -p build/zoneinfo
46+
./build/vzic/vzic --olson-dir tzdata --output-dir build/zoneinfo --pure
47+
48+
if [[ ${VZIC_MASTER_ZONEINFO_ARCHIVE_URL} ]]; then
49+
echo "Downloading master zoneinfo from $VZIC_MASTER_ZONEINFO_ARCHIVE_URL"
50+
wget -q -O build/zoneinfo_master.tar.gz $VZIC_MASTER_ZONEINFO_ARCHIVE_URL
51+
52+
export VZIC_MASTER_ZONEINFO_ARCHIVE_PATH=build/zoneinfo_master.tar.gz
53+
fi
54+
55+
export VZIC_ZONEINFO_NEW=`pwd`/build/zoneinfo
56+
57+
if [[ ${VZIC_MASTER_ZONEINFO_ARCHIVE_PATH} ]]; then
58+
echo "Extracting master zoneinfo $VZIC_MASTER_ZONEINFO_ARCHIVE_PATH"
59+
mkdir -p build/zoneinfo_master
60+
tar -xzf $VZIC_MASTER_ZONEINFO_ARCHIVE_PATH -C build/zoneinfo_master
61+
62+
# define variables used in vzic-merge.pl
63+
export VZIC_ZONEINFO_MASTER=`pwd`/build/zoneinfo_master
64+
elif [[ -d zoneinfo ]]; then
65+
echo "Using existing zoneinfo as master."
66+
export VZIC_ZONEINFO_MASTER=`pwd`/zoneinfo
67+
fi
68+
69+
if [[ ${VZIC_ZONEINFO_MASTER} ]]; then
70+
71+
echo "Merging"
72+
./vzic-merge.pl
73+
74+
# copy updated zones
75+
cp -r $VZIC_ZONEINFO_NEW/zones.* $VZIC_ZONEINFO_MASTER
76+
77+
if [ "$VZIC_ZONEINFO_MASTER" != "`pwd`/zoneinfo" ]; then
78+
if [ -d zoneinfo ]; then rm -r zoneinfo; fi
79+
mkdir -p zoneinfo
80+
cp -r $VZIC_ZONEINFO_MASTER zoneinfo
81+
fi
82+
else
83+
cp -r "$VZIC_ZONEINFO_NEW" zoneinfo
84+
export VZIC_ZONEINFO_MASTER=`pwd`/zoneinfo
85+
echo "No master zoneinfo configured. The new zoneinfo will not be merged and kept as is."
86+
fi
87+
88+
echo "Creating output archive"
89+
VZIC_OUT_TAR="`pwd`/build/out/zoneinfo-$VZIC_RELEASE_NAME.tar.gz"
90+
pushd $VZIC_ZONEINFO_MASTER
91+
tar -czf "$VZIC_OUT_TAR" *
92+
popd

dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# escape=`
2+
3+
FROM ubuntu
4+
5+
RUN apt-get update
6+
7+
# build tools
8+
RUN apt-get -y install make
9+
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install pkg-config
10+
RUN apt-get -y install build-essential
11+
RUN apt-get -y install libglib2.0-dev
12+
13+
# wget used to download tzdata and previous zoneinfo
14+
RUN apt-get -y install wget
15+
16+
# perl used to merge new zoneinfo with previous version
17+
RUN apt-get -y install perl

settings.config

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
VZIC_RELEASE_NAME=
3+
VZIC_BASE_RELEASE_NAME=
4+
5+
# The source tzdata is downloaded from this URL.
6+
VZIC_TZDATA_ARCHIVE_URL="https://data.iana.org/time-zones/releases/tzdata$VZIC_RELEASE_NAME.tar.gz"
7+
8+
# If VZIC_MASTER_ZONEINFO_ARCHIVE_URL is set, the script tries to download a an output from a previous
9+
# version and merge the new output with the previous one using vzic-merge.pl.
10+
# VZIC_MASTER_ZONEINFO_ARCHIVE_PATH can point to a local file and be used instead of VZIC_MASTER_ZONEINFO_ARCHIVE_URL.
11+
# If neither of them is set, then the newly generated zoneinfo is kept as is.
12+
13+
# VZIC_MASTER_ZONEINFO_ARCHIVE_URL=""
14+
# VZIC_MASTER_ZONEINFO_ARCHIVE_PATH=""
15+
16+
VZIC_PRODID="-//github.com/libical/vzic//NONSGML ICS//EN"
17+
VZIC_TZID_PREFIX="/github.com/libical/tzdbics/%D_$VZIC_RELEASE_NAME/"

0 commit comments

Comments
 (0)