md-arif-shaikh / tzc

Time Zone Converter for Emacs
GNU General Public License v3.0
18 stars 1 forks source link

Failure to load tzdata on Android under Termux #6

Open gnomon- opened 10 months ago

gnomon- commented 10 months ago

The tzc-main-dir customizable var attempts some good guesses for finding tzdata files but there is a gap when it is invoked under Termux on Android. Executing the following script demonstrates the issue with querying system-type alone:

#!/usr/bin/env -S emacs --script

(mapcar
 (lambda (sym)
   (princ (concat
       (symbol-name sym)
       ":\t"
       (let ((symv (symbol-value sym)))
         (if (stringp symv)
          symv
          (symbol-name symv)))
       "\n")))
 '(system-configuration system-type))

...which, under Termux, prints:

system-configuration:   aarch64-unknown-linux-android
system-type:    gnu/linux

The challenge is that Android does not follow Linux or macOS convention about splitting up timezone info into multiple files; rather, it offers a single concatenated file:

$ declare -p ANDROID_TZDATA_ROOT
declare -x ANDROID_TZDATA_ROOT="/apex/com.android.tzdata"
$ find "$ANDROID_TZDATA_ROOT" -type f -exec ls -sal --full-time '{}' '+'
find: ‘/apex/com.android.tzdata/lost+found’: Permission denied
  4 -rw-r--r-- 1 system system     26 1969-12-31 19:00:00.000000000 -0500 /apex/com.android.tzdata/apex_manifest.pb
236 -rw-r--r-- 1 system system 237600 1969-12-31 19:00:00.000000000 -0500 /apex/com.android.tzdata/etc/icu/icu_tzdata.dat
  4 -rw-r--r-- 1 system system    248 1969-12-31 19:00:00.000000000 -0500 /apex/com.android.tzdata/etc/tz/telephonylookup.xml
  4 -rw-r--r-- 1 system system     17 1969-12-31 19:00:00.000000000 -0500 /apex/com.android.tzdata/etc/tz/tz_version
440 -rw-r--r-- 1 system system 449437 1969-12-31 19:00:00.000000000 -0500 /apex/com.android.tzdata/etc/tz/tzdata
 36 -rw-r--r-- 1 system system  36717 1969-12-31 19:00:00.000000000 -0500 /apex/com.android.tzdata/etc/tz/tzlookup.xml

I'm figuring out what to do with this file organization and format in order to offer an actual fix, but for now I'm just opening this issue to log the discovery.