-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add information about updating in
tools/
- Loading branch information
1 parent
b0ae341
commit 5dc9ba0
Showing
4 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
^civil\.Rproj$ | ||
^\.Rproj\.user$ | ||
^LICENSE\.md$ | ||
^tools$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
-------------------------------------------------------------------------------- | ||
Updating `civil` dependencies | ||
|
||
1. Update the version in `update-database.R`. | ||
|
||
2. Run `update-database.R` to update `inst/tzdata/` and | ||
`inst/tzdata/windowsZones.xml`. | ||
|
||
3. Run `update-date-library.R` to update the headers and `tz.cpp` in `src/`. | ||
|
||
4. Go back through `tz.cpp` and comment out all uses to `std::cerr()`, which | ||
R CMD Check doesn't like. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
library(here) | ||
library(fs) | ||
|
||
# Notes about this updater: | ||
# | ||
# Don't forget to update the version below. | ||
# | ||
# This updater will download all the required information and will place it | ||
# in the right place. The next few paragraphs describe what it downloads in | ||
# case you have to do it manually for some reason. | ||
# | ||
# The time zone database is downloaded from: https://www.iana.org/time-zones. | ||
# If you are going to do it manually for some reason, choose the latest | ||
# version, and grab the one with JUST the data, in the format like | ||
# `tzdata2019c.tar.gz`. Uncompress it, and then take the contents of the | ||
# folder and move them into `inst/tzdata/`. | ||
# | ||
# On Windows, we also need a `windowsZone.xml` mapping file. | ||
# It can be found here if you need to download it manually: | ||
# https://raw.githubusercontent.com/unicode-org/cldr/master/common/supplemental/windowsZones.xml. | ||
# Download this file and place it in `inst/tzdata` as `windowsZones.xml`. | ||
|
||
# Update the version! | ||
version <- "2020d" | ||
|
||
# ------------------------------------------------------------------------------ | ||
# Download the time zone database | ||
|
||
file <- paste0("tzdata", version, ".tar.gz") | ||
|
||
path_base <- "https://data.iana.org/time-zones/releases/" | ||
path_version <- path(path_base, file) | ||
|
||
dir_temp <- tempdir() | ||
path_temp <- tempfile(fileext = ".tar.gz", tmpdir = dir_temp) | ||
|
||
download.file(path_version, path_temp) | ||
|
||
untar(path_temp, exdir = here("inst", "tzdata")) | ||
|
||
unlink(path_temp) | ||
unlink(dir_temp, recursive = TRUE, force = TRUE) | ||
|
||
# ------------------------------------------------------------------------------ | ||
# Download the Windows mapping file | ||
|
||
windows_mapping_url <- "https://raw.githubusercontent.com/unicode-org/cldr/master/common/supplemental/windowsZones.xml" | ||
path_dest_windows_mapping <- here("inst/tzdata/windowsZones.xml") | ||
|
||
download.file(windows_mapping_url, path_dest_windows_mapping) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
library(here) | ||
library(fs) | ||
library(glue) | ||
|
||
# Notes about this updater: | ||
# | ||
# The `tz.cpp` file that is downloaded into `src/tz.cpp` will need to be updated | ||
# to pass R CMD Check. All calls to `std::cerr` will have to be commented out. | ||
|
||
# ------------------------------------------------------------------------------ | ||
# cd into temp dir | ||
# git clone the repo | ||
|
||
dir_temp <- tempdir() | ||
dir_dest <- dir_create(path(dir_temp, "dest/")) | ||
|
||
url_repo <- "https://github.com/HowardHinnant/date" | ||
|
||
cmd_cd <- glue(shQuote("cd"), " ", dir_dest) | ||
cmd_clone <- glue(shQuote("git"), " clone ", url_repo) | ||
cmd <- glue(cmd_cd, "; ", cmd_clone) | ||
|
||
# cd into temp dir | ||
# git clone the repo | ||
system(cmd) | ||
|
||
dir_date <- path(dir_dest, "date") | ||
|
||
# ------------------------------------------------------------------------------ | ||
# Update headers and tz.cpp | ||
# Will overwrite src/tz.cpp (which will need to be tweaked) | ||
|
||
dir_src <- here("src") | ||
|
||
dir_date_include_date <- path(dir_date, "include", "date") | ||
dir_copy(dir_date_include_date, dir_src, overwrite = TRUE) | ||
|
||
file_date_src_tz <- path(dir_date, "src", "tz.cpp") | ||
file_pkg_src_tz <- path(dir_src, "tz.cpp") | ||
|
||
file_copy(file_date_src_tz, file_pkg_src_tz, overwrite = TRUE) | ||
|
||
# ------------------------------------------------------------------------------ | ||
|
||
unlink(dir_temp, recursive = TRUE, force = TRUE) |