Created
November 28, 2019 09:52
-
-
Save mllg/b9c75ded211df7df58942c5d647b9c43 to your computer and use it in GitHub Desktop.
Rebuild R packages after system libraries have been upgraded
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
#!/usr/bin/env Rscript | |
libs = c("libopenblas", "libicu") | |
packages = character() | |
patterns = sprintf("^%s.* => not found$", libs) | |
for (lib in .libPaths()) { | |
files = list.files(path = lib, pattern = "\\.so(\\.[0-9]+)*$", recursive = TRUE, | |
ignore.case = TRUE, full.names = TRUE, no.. = TRUE) | |
for (file in files) { | |
lines = suppressWarnings(trimws(system2("ldd", file, stdout = TRUE, stderr = TRUE))) | |
for (pattern in patterns) { | |
if (any(grepl(pattern, lines))) { | |
packages = c(packages, basename(dirname(dirname(file)))) | |
} | |
} | |
} | |
} | |
if (length(packages)) { | |
install.packages(unique(packages)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment