Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pak when package installation is not found #284

Draft
wants to merge 32 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
7b933ef
Setup pak
schloerke Mar 18, 2021
93362ed
Use local lib path for pak that is ignored for regular execution
schloerke Mar 18, 2021
0114221
Fix pkgs to be installed
schloerke Mar 18, 2021
fdf66eb
Install pak before packages. If no install file exists, use pak to in…
schloerke Mar 18, 2021
bb51c28
Ignore lib folder
schloerke Mar 18, 2021
5d590b2
Remove gsl install
schloerke Mar 18, 2021
c722231
remove pdftools install
schloerke Mar 18, 2021
4adbd13
remove ragg install
schloerke Mar 18, 2021
727e2ca
remove rDEA install and test
schloerke Mar 18, 2021
e9eae2d
remove redland install
schloerke Mar 18, 2021
0f30a34
remove rgeos install
schloerke Mar 18, 2021
2190bfa
remove rgl
schloerke Mar 18, 2021
066f585
remove Rglpk
schloerke Mar 18, 2021
8e9d0e3
remove Rmpfr install
schloerke Mar 18, 2021
18fa843
remove rsvg install
schloerke Mar 18, 2021
02ea033
remove tesseract
schloerke Mar 18, 2021
c5864a7
remove textshaping
schloerke Mar 18, 2021
3314d33
Remove tiff
schloerke Mar 18, 2021
e922be7
remove units and udunits2
schloerke Mar 18, 2021
d56ca26
remove V8 install
schloerke Mar 18, 2021
62018f8
Rename pak install pkg file
schloerke Mar 18, 2021
fdc6291
Create test-pkgs.yaml
schloerke Mar 18, 2021
09bf627
Don't forget to checkout the repo. Run on `pak` branch
schloerke Mar 18, 2021
8499d49
try using an object and no an array
schloerke Mar 18, 2021
28c3722
Use a matrix like the example
schloerke Mar 18, 2021
79d5525
Revert to original single name setup. Say `test` needs `packages`
schloerke Mar 18, 2021
8fcb11a
Use hosted docker images
schloerke Mar 18, 2021
3bd9e30
formatting
schloerke Mar 18, 2021
f7ec94a
Merge branch 'master' into pak
schloerke Mar 18, 2021
e2dc63e
Test using focal
schloerke Mar 18, 2021
a903ac8
Delete .travis.yml
schloerke Mar 18, 2021
c39737d
xenial is missing libpcre2. Build local docker files to test latest
schloerke Mar 18, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use local lib path for pak that is ignored for regular execution
schloerke committed Mar 18, 2021
commit 93362ed527b3e60672070ee5b93ab752d80fdf8b
23 changes: 22 additions & 1 deletion pak/install_pkg.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
# Returns the file currently being sourced or run with Rscript
thisFile <- function() {
cmdArgs <- commandArgs(trailingOnly = FALSE)
needle <- "--file="
match <- grep(needle, cmdArgs)
if (length(match) > 0) {
# Rscript
return(normalizePath(sub(needle, "", cmdArgs[match])))
} else {
# 'source'd via R console
return(normalizePath(sys.frames()[[1]]$ofile))
}
}
# set to `pak` folder
setwd(dirname(thisFile()))

os <- tryCatch({
system("lsb_release -sc", intern = TRUE)
}, error = function(e) {
"local"
})

args <- commandArgs(TRUE)
if (length(args) > 0) {
pkgs <- args[-1]

# Must match install file
lib <- file.path("pak", "lib", R.Version()$platform, paste0(R.Version()$major, ".", R.Version()$minor))
lib <- file.path("lib", os, paste0(R.Version()$major, ".", R.Version()$minor))
# Load pak from our tmp lib
require("pak", character.only = TRUE, lib.loc = lib, quietly = TRUE)

27 changes: 26 additions & 1 deletion pak/setup.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,37 @@
# Returns the file currently being sourced or run with Rscript
thisFile <- function() {
cmdArgs <- commandArgs(trailingOnly = FALSE)
needle <- "--file="
match <- grep(needle, cmdArgs)
if (length(match) > 0) {
# Rscript
return(normalizePath(sub(needle, "", cmdArgs[match])))
} else {
# 'source'd via R console
return(normalizePath(sys.frames()[[1]]$ofile))
}
}
# set to `pak` folder
setwd(dirname(thisFile()))

os <- tryCatch({
system("lsb_release -sc", intern = TRUE)
}, error = function(e) {
"local"
})

# Must match install file
lib <- file.path("pak", "lib", R.Version()$platform, paste0(R.Version()$major, ".", R.Version()$minor))
lib <- file.path("lib", os, paste0(R.Version()$major, ".", R.Version()$minor))
if (!dir.exists(lib)) {
dir.create(lib, recursive = TRUE)
}

if (system.file(package = "pak", lib.loc = lib) == "") {
# install latest
install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/", lib = lib)
# quick test
require("pak", character.only = TRUE, lib.loc = lib, quietly = FALSE)

} else {
# Load pak from our tmp lib
require("pak", character.only = TRUE, lib.loc = lib, quietly = TRUE)