内容

在这里,我们描述了处理原始HDF5源代码以生成随此包分发的修改版本所采取的步骤。本表格仅供使用者作记录之用Rhdf5lib包不需要遵循这里详细介绍的任何步骤。

库(stringr)

下载HDF5源压缩包并解压缩到一个临时目录中。我们将输出文件夹重命名为hdf5

Hdf5_source <- tempfile() download.下载。untar(tarfile = hdf5_source, exdir = tempdir()) system2("mv", args = c(file.path(tempdir(), "hdf5-1.10.6"), file.path(tempdir(), "hdf5")))
Hdf5_dir <- file.path(tempdir(), "hdf5")

删除我们不分发的文件夹。

断开(x = file)链接。路径(hdf5_dir c(“例子”,“fortran”,“java”、“release_docs”、“测试”、“testpar”、“工具”、“c++ /例子”,“c++ /测试”、“霍奇金淋巴瘤/ fortran”、“霍奇金淋巴瘤/例子”,“霍奇金淋巴瘤/工具”,“霍奇金淋巴瘤/测试”、“霍奇金淋巴瘤/ c++ /例子”,“霍奇金淋巴瘤/ c++ /测试”)),递归= TRUE)

接下来,我们对配置脚本和制作文件进行一些修改,删除对已删除的文件夹的引用。

Configure_ac <- xfun::read_utf8(文件。路径(hdf5_dir configure.ac)) # #修改列表构建文件启动<——(str_detect (configure_ac、模式=“AC_CONFIG_FILES”))<——结束(str_detect (configure_ac(开始:(长度(configure_ac))),模式  = "\\)$"))[ 1) + - 1开始config_files < - configure_ac[开始:结束]rm_idx <——(str_detect (config_files、模式=“测试/ | testpar / |工具/ / | fortran / java / | | |例子h5c + + /”))config_files < - config_files [-rm_idx] config_files[长度(config_files)] < - paste0(尾(config_files, 1),"])") configure_ac[start] <- paste(config_files, collapse = "\n") configure_ac <- configure_ac[-((start+1):(end))] ## remove reference to h5cc h5cc <- str_which(configure_ac, pattern = "chmod 755 [a-z/]*/h5cc") configure_ac <- configure_ac[-((h5cc):(h5cc+4))] ## fortran headers fortran_inc <- str_which(configure_ac, pattern = "AC_CONFIG_HEADERS\\(\\[fortran/src/H5config_f\\.inc") configure_ac[fortran_inc:(fortran_inc+1)] <- paste("##",Configure_ac [fortran_inc:(fortran_inc+1)]) ##写xfun::write_utf8(Configure_ac, con =文件。* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *。path(hdf5_dir, 'c++/Makefile.am')) idx <- str_which(make_cplusplus, "BUILD_CXX_CONDITIONAL") make_cplusplus[idx] <- "if BUILD_CXX_CONDITIONAL\n SUBDIRS=src\nendif\nDIST_SUBDIRS =src " make_cplusplus <- make_cplusplus[-((idx+1):(length(make_cplusplus)-2))] xfun::write_utf8(make_cplusplus, con =文件。path(hdf5_dir, "c++/ makefile .am")) ## HL makefile make_hl <- xfun::read_utf8(文件。path(hdf5_dir, 'hl/Makefile.am')) idx <- str_which(make_hl, "BUILD_HDF5_HL_CONDITIONAL") make_hl[idx] <- "if BUILD_HDF5_HL_CONDITIONAL\n SUBDIRS=src $(CXX_DIR)\nendif\nDIST_SUBDIRS =src c++" make_hl <- make_hl[-((idx+1):(length(make_hl)-2))] xfun::write_utf8(make_hl, con =文件。path(hdf5_dir, "hl/ makefile .am")) ## hl c++ makefile make_hl_cpp <- xfun::read_utf8(文件。path(hdf5_dir, 'hl/c++/Makefile.am')) idx <- str_which(make_hl_cpp, "^SUBDIRS=src") make_hl_cpp[idx] <- "SUBDIRS=src\nDIST_SUBDIRS=src" make_hl_cpp <- make_hl_cpp[-((idx+1):(length(make_hl_cpp)-2)] xfun::write_utf8(make_hl_cpp, con = file. cpp)。path(hdf5_dir, "hl/c++/ makefile .am")) ##主makefile make <- xfun::read_utf8(文件。path(hdf5_dir, 'Makefile.am')) idx <- str_which(make, "SUBDIRS = src")[1] make[idx] <- "SUBDIRS = src . path ")$(CXX_DIR) $(HDF5_HL_DIR)" make[idx+1] <- "DIST_SUBDIRS = src。c++ hl“[idx + 2] < -”“idx < - str_which(,“#让所有、测试和\ \(联合国\ \)安装”)使((idx + 1): (idx + 6) <——paste0(“# #”,使[(idx + 1): (idx + 6)]) xfun:: write_utf8(,反对=文件。路径(hdf5_dir Makefile.am))

解决CRAN Solaris构建器上报告的源代码中的问题。

代码<- xfun::read_utf8(文件。路径(hdf5_dir、“c++”、“src”、“H5Library.cpp”)< -)代码(代码,大小写不敏感([]{1})(退出\ \()”,替换= ' \ \ 1 std:: \ \ 2”)xfun: write_utf8(代码,反对=文件。path(hdf5_dir, 'c++', 'src', 'H5Library.cpp'))

处理修改后的脚本。

System (command = paste0("cd ", hdf5_dir, " && autoconf")) System (command = paste0("cd ", hdf5_dir, " && aclocal")) System (command = paste0("cd ", hdf5_dir, " && automake"))path(hdf5_dir, "autom4te.cache"),递归= TRUE)

0.1SZIP

现在我们为SZIP库执行类似的过程。

Szip_source <- tempfile()下载。文件(url = "https://support.hdfgroup.org/ftp/lib-external/szip/2.1.1/src/szip-2.1.1.tar.gz", dest = szip_source) untar(tarfile = szip_source, exdir = tempdir()) system2("mv", args = c(File .path(tempdir(), "szip-2.1.1"), File .path(tempdir(), "szip")))
Szip_dir <- file.path(tempdir(), "szip")
断开(x = file)链接。path(szip_dir, "test"), recursive = TRUE)
xfun:: read_utf8(文件。* * . path(szip_dir, "configure.ac")) %>% str_remove("test/Makefile") %>% xfun::write_utf8(文件。路径(szip_dir, "configure.ac")) xfun::read_utf8(文件。路径(szip_dir Makefile.am))%>% str_replace(pattern = "SUBDIRS=src test", replacement = "SUBDIRS=src") %>% xfun::write_utf8(file.path(szip_dir, "Makefile.am"))
System (command = paste0("cd ", szip_dir, " && autoconf")) System (command = paste0("cd ", szip_dir, " && aclocal")) System (command = paste0("cd ", szip_dir, " && automake"))path(szip_dir, "autom4te.cache"),递归= TRUE)

0.2创建压缩文件

将SZIP源代码移动到HDF5发行版中,并创建将随R包一起分发的tarball。我们使用这个系统焦油当使用R的内置函数时,我不知道如何在tarball中只包括基本目录。

System2 ("mv", args = c(szip_dir,文件。路径(hdf5_dir, szip)))系统2(“焦油”,args = c(“c”,tempdir(),“-czf file.path (tempdir(),“hdf5small_cxx_hl_1.10.6.tar.gz”),“hdf5”))

最后将此复制到/ tmp /因此,如果正确的话,很容易找到、检查并移动到包目录。

If (file.exists("/tmp/hdf5small_cxx_hl_1.10.6.tar.gz") {file.remove("/tmp/hdf5small_cxx_hl_1.10.6.tar.gz")} file.copy(file.path(tempdir(), "hdf5small_cxx_hl_1.10.6.tar.gz"), to = "/tmp/")