Time zones of Earth are changed several times per year, both for future and past dates. In order to ensure that our clocks display the correct time, Guix needs to keep our time zone package (tzdata) up to date.
However, the current situation makes this impractical, because changing tzdata causes ~1400 package rebuilds per-architecture (`guix refresh -l tzdata`). We should make sure that packages which use time zones look up the time zones dynamically, at run-time, rather than recording a store reference to the tzdata package, which will be obsolete in months, at the latest. I used `guix graph --type=reverse-package tzdata` to start, and found that the main culprit here is bluez, which depends on tzdata via libical. Using the attached patch, we can make libical look up time zones at runtime with the $TZDIR environment variable. Bluez still builds with this; I'm not sure what it does with libical and if it still works correctly. However, this makes evolution-data-server test suite fail. I'm not sure how to fix evolution-data-server correctly. The fine points of looking up time zones in evolution-data-server were already discussed: <https://bugs.gnu.org/35746>
>From 29bd8e4b8fcd332f110dc6d7bb99755300b76299 Mon Sep 17 00:00:00 2001 From: Leo Famulari <[email protected]> Date: Thu, 16 Apr 2020 15:50:40 -0400 Subject: [PATCH] gnu: libical: Dynamically bind the time zones with TZDIR. * gnu/packages/patches/libical-honor-TZDIR.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. * gnu/packages/calendar.scm (libical)[source]: Use it. [arguments]: Remove the 'patch-paths' phase. [inputs]: Remove tzdata. --- gnu/local.mk | 1 + gnu/packages/calendar.scm | 24 +++---------- .../patches/libical-honor-TZDIR.patch | 36 +++++++++++++++++++ 3 files changed, 42 insertions(+), 19 deletions(-) create mode 100644 gnu/packages/patches/libical-honor-TZDIR.patch diff --git a/gnu/local.mk b/gnu/local.mk index 9f212434a9..0b7569b245 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1075,6 +1075,7 @@ dist_patch_DATA = \ %D%/packages/patches/jsoncpp-fix-inverted-case.patch \ %D%/packages/patches/julia-SOURCE_DATE_EPOCH-mtime.patch \ %D%/packages/patches/kdbusaddons-kinit-file-name.patch \ + %D%/packages/patches/libical-honor-TZDIR.patch \ %D%/packages/patches/libnftnl-dont-check-NFTNL_FLOWTABLE_SIZE.patch \ %D%/packages/patches/libvirt-create-machine-cgroup.patch \ %D%/packages/patches/libziparchive-add-includes.patch \ diff --git a/gnu/packages/calendar.scm b/gnu/packages/calendar.scm index 81b2b436c1..701cd7d6aa 100644 --- a/gnu/packages/calendar.scm +++ b/gnu/packages/calendar.scm @@ -119,6 +119,8 @@ the <tz.h> library for handling time zones and leap seconds.") (base32 "1z33wzaazbd7drl6qbh1750whd78xl2cg0gjnxyya9m83vgndgha")) (patches + (append + (search-patches "libical-honor-TZDIR.patch") ;; Add a patch slated for 3.0.8 which preserves backwards- ;; compatibility in the icalattach_new_from_data() function, ;; which accidentally changed in 3.0.7 and could break some uses. @@ -132,34 +134,18 @@ the <tz.h> library for handling time zones and leap seconds.") (file-name "libical-3.0.7-preserve-icalattach-api.patch") (sha256 (base32 - "0v8qcxn8a6sh78grzxd61j9478928dx38l5mf8mkdrbxv47vmvvp"))))))) + "0v8qcxn8a6sh78grzxd61j9478928dx38l5mf8mkdrbxv47vmvvp")))))))) (build-system cmake-build-system) (arguments '(#:tests? #f ; test suite appears broken - #:configure-flags '("-DSHARED_ONLY=true") - #:phases - (modify-phases %standard-phases - (add-before 'configure 'patch-paths - (lambda* (#:key inputs #:allow-other-keys) - ;; TODO: libical 3.1.0 supports using TZDIR instead of a hard-coded - ;; zoneinfo database. When that is released we can drop - ;; the tzdata dependency. - (let ((tzdata (assoc-ref inputs "tzdata"))) - (substitute* "src/libical/icaltz-util.c" - (("\\\"/usr/share/zoneinfo\\\",") - (string-append "\"" tzdata "/share/zoneinfo\"")) - (("\\\"/usr/lib/zoneinfo\\\",") "") - (("\\\"/etc/zoneinfo\\\",") "") - (("\\\"/usr/share/lib/zoneinfo\\\"") ""))) - #t))))) + #:configure-flags '("-DSHARED_ONLY=true"))) (native-inputs `(("gtk-doc" ,gtk-doc) ("perl" ,perl) ("pkg-config" ,pkg-config))) (inputs `(("glib" ,glib) - ("libxml2" ,libxml2) - ("tzdata" ,tzdata))) + ("libxml2" ,libxml2))) (propagated-inputs ;; In Requires.private of libical.pc. `(("icu4c" ,icu4c))) diff --git a/gnu/packages/patches/libical-honor-TZDIR.patch b/gnu/packages/patches/libical-honor-TZDIR.patch new file mode 100644 index 0000000000..c8c6edcd83 --- /dev/null +++ b/gnu/packages/patches/libical-honor-TZDIR.patch @@ -0,0 +1,36 @@ +Make libical look for the time zone database in the directory pointed to +by TZDIR. + +Patch copied from nixpkgs: + +https://github.com/NixOS/nixpkgs/blob/19.09/pkgs/development/libraries/libical/respect-env-tzdir.patch + +--- a/src/libical/icaltz-util.c ++++ b/src/libical/icaltz-util.c +@@ -94,9 +94,9 @@ + static const char *zdir = NULL; + + static const char *search_paths[] = { ++ "/etc/zoneinfo", + "/usr/share/zoneinfo", + "/usr/lib/zoneinfo", +- "/etc/zoneinfo", + "/usr/share/lib/zoneinfo" + }; + +@@ -178,6 +178,15 @@ + const char *fname = ZONES_TAB_SYSTEM_FILENAME; + size_t i, num_search_paths; + ++ const char *env_tzdir = getenv ("TZDIR"); ++ if (env_tzdir) { ++ sprintf (file_path, "%s/%s", env_tzdir, fname); ++ if (!access (file_path, F_OK|R_OK)) { ++ zdir = env_tzdir; ++ return; ++ } ++ } ++ + num_search_paths = sizeof(search_paths) / sizeof(search_paths[0]); + for (i = 0; i < num_search_paths; i++) { + snprintf(file_path, MAXPATHLEN, "%s/%s", search_paths[i], fname); -- 2.26.2
