inst/header_cmd.R

## generated by rang, do not edit by hand
## DEBUG INFO: CMD

current.r.version <- NA
bioc.mirror <- NA
path <- file.path(Sys.getenv("CACHE_PATH"), "rpkgs") ## cache must have been enforced

.build.raw.tarball <- function(raw.tarball.path, x, version, tarball.path, current.r.version) {
    vignetteflag <- "--no-vignettes"
    tmp.dir <- tempfile()
    dir.create(tmp.dir)
    system(command = paste("tar", "-zxf ", raw.tarball.path, "-C", tmp.dir))
    pkg.dir <- list.files(path = tmp.dir, full.names = TRUE)[1]
    new.pkg.dir <- file.path(tmp.dir, x)
    file.rename(pkg.dir, new.pkg.dir)
    expected.tarball.path <- paste(x, "_", version, ".tar.gz", sep = "")
    res <- system(command = paste("R", "CMD", "build", vignetteflag, new.pkg.dir))
    if (!file.exists(expected.tarball.path)) {
        res <- system(command = paste("R", "CMD", "build", new.pkg.dir))
    }
    stopifnot(file.exists(expected.tarball.path))
    file.rename(expected.tarball.path, tarball.path)
    return(tarball.path)
}

.build.dir.tarball <- function(dir.pkg.path, x, version, tarball.path, current.r.version) {
    vignetteflag <- "--no-vignettes"
    expected.tarball.path <- paste(x, "_", version, ".tar.gz", sep = "")
    res <- system(command = paste("R", "CMD", "build", vignetteflag, dir.pkg.path))
    if (!file.exists(expected.tarball.path)) {
        res <- system(command = paste("R", "CMD", "build", dir.pkg.path))
    }
    stopifnot(file.exists(expected.tarball.path))
    file.rename(expected.tarball.path, tarball.path)
    return(tarball.path)
}

.install.from.source <- function(x, version, handle, source, uid, lib,
                                 path = tempdir(), verbose, cran.mirror, bioc.mirror, current.r.version) {
    tarball.path <- file.path(path, paste(x, "_", version, ".tar.gz", sep = ""))
    raw.tarball.path <- file.path(path, paste("raw_", x, "_", version, ".tar.gz", sep = ""))
    dir.pkg.path <- file.path(path, paste("dir_", x, "_", version, sep = ""))
    if (file.exists(raw.tarball.path)) {
        tarball.path <- .build.raw.tarball(raw.tarball.path, x = x, version = version, tarball.path,
                                           current.r.version = current.r.version)
        if (!file.exists(tarball.path)) {
            stop("building failed.")
        }
    }
    if (file.exists(dir.pkg.path)) {
        tarball.path <- .build.dir.tarball(dir.pkg.path, x = x, version = version, tarball.path,
                                           current.r.version = current.r.version)
        if (!file.exists(tarball.path)) {
            stop("building failed.")
        }
    }
    if (!is.na(lib)) {
        l <- paste("-l", lib)
    } else {
        l <- ""
    }
    res <- system(command = paste("R", "CMD", "INSTALL", tarball.path, l))
}

Try the rang package in your browser

Any scripts or data that you put into this service are public.

rang documentation built on Oct. 8, 2023, 5:06 p.m.