Skip to content

feat: add desc_add_sysreq() #165

@JosiahParry

Description

@JosiahParry

Feature Request

It would be great if desc had capabilities to add system requirements to the DESCRIPTION file.

Even better would be a way to ensure that the sysreq is compatible with the rstudio/r-system-requirements database and, if not found in the database an encouraging message to add it to the sysreq db.

Inspired by Posit Package Manager build issue with extendr packages: extendr/rextendr#457

Motivation

In {rextendr} we add "Cargo (Rust's package manager), rustc >= 1.65.0" with a custom function that's a little scary (below). (source)

This function will not effectively handle adding xz as a system requirement to existing DESCRIPTION files

update_description <- function(field, value, desc_path) {
  cli::cli_alert_info("Setting {.var {field}} to {.str {value}} in the {.file DESCRIPTION} file.")
  desc::desc_set(field, value, file = desc_path)
}

update_sys_reqs <- function(desc_path) {
  cur <- "Cargo (Rust's package manager), rustc"
  prev <- stringi::stri_trim_both(desc::desc_get("SystemRequirements", file = desc_path)[[1]])

  if (is.na(prev)) {
    update_description("SystemRequirements", cur, desc_path = desc_path)
  } else if (!identical(cur, prev)) {
    cli::cli_ul(
      c(
        "The SystemRequirements field in the {.file DESCRIPTION} file is already set.",
        "Please update it manually if needed."
      )
    )
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions