Skip to contents

You may have the need to serve your own version of this site locally. If that is the case, you can do so quite easily. There are two steps to hosting your own version of the site/API. First, you must download the requisite json files and store them in their own directory. Second, you must serve them on a server. Since this is only plain-text, you can serve it on Netlify (my choice) or Github pages. sysreqs also provides a function for serving them locally.

Create the directories

You can create your own directories using create_sysreqs_site() and specifying the output directory.

outdir <- "_api"
create_sysreqs_site(outdir)

Check the output directory.

list.files(outdir)
#> [1] "index.html"    "patterns.json" "pkgs"          "rules"        
#> [5] "systems.json"

Serve the site

We can serve the site locally using serve_sysreqs() and providing the directory containing the json files that we need. This will create an httpuv server that runs in the background.

By default this runs on localhost:8080 you can change this by setting the host and port arguments your self.

serve_sysreqs(outdir)
#>  site being served at http://0.0.0.0:8080

We can check if this is working by using httr to call the local server.

httr::GET("http://localhost:8080/patterns.json")
#> Response [http://localhost:8080/patterns.json]
#>   Date: 2022-04-05 18:57
#>   Status: 200
#>   Content-Type: application/json
#>   Size: 3.22 kB
#> {"apparmor":["\\bapparmor\\b","\\blibapparmor\\b"],"atk":["\\batk\\b"],"autom...

Awesome! If we want to use this server for our get_pkg_sysreqs() and other functions we need to change the environment variable SYSREQS_URL. By default it is set to .

Sys.setenv("SYSREQS_URL" = "http://localhost:8080")

We can check if this is correct using the internal function b_url() which assigns the base url for http queries.

sysreqs:::b_url()
#> [1] "http://localhost:8080"

Let’s now try out one of the package’s functions.

sysreqs::fetch_systems()
#> [[1]]
#> [[1]]$os
#> [1] "linux"
#> 
#> [[1]]$distribution
#> [1] "ubuntu"
#> 
#> [[1]]$versions
#> [[1]]$versions[[1]]
#> [1] "14.04"
#> 
#> [[1]]$versions[[2]]
#> [1] "16.04"
#> 
#> [[1]]$versions[[3]]
#> [1] "18.04"
#> 
#> [[1]]$versions[[4]]
#> [1] "20.04"
#> 
#> 
#> 
#> [[2]]
#> [[2]]$os
#> [1] "linux"
#> 
#> [[2]]$distribution
#> [1] "centos"
#> 
#> [[2]]$versions
#> [[2]]$versions[[1]]
#> [1] "6"
#> 
#> [[2]]$versions[[2]]
#> [1] "7"
#> 
#> [[2]]$versions[[3]]
#> [1] "8"
#> 
#> 
#> 
#> [[3]]
#> [[3]]$os
#> [1] "linux"
#> 
#> [[3]]$distribution
#> [1] "redhat"
#> 
#> [[3]]$versions
#> [[3]]$versions[[1]]
#> [1] "6"
#> 
#> [[3]]$versions[[2]]
#> [1] "7"
#> 
#> [[3]]$versions[[3]]
#> [1] "8"
#> 
#> 
#> 
#> [[4]]
#> [[4]]$os
#> [1] "linux"
#> 
#> [[4]]$distribution
#> [1] "opensuse"
#> 
#> [[4]]$versions
#> [[4]]$versions[[1]]
#> [1] "42.3"
#> 
#> [[4]]$versions[[2]]
#> [1] "15.0"
#> 
#> [[4]]$versions[[3]]
#> [1] "15.2"
#> 
#> [[4]]$versions[[4]]
#> [1] "15.3"
#> 
#> 
#> 
#> [[5]]
#> [[5]]$os
#> [1] "linux"
#> 
#> [[5]]$distribution
#> [1] "sle"
#> 
#> [[5]]$versions
#> [[5]]$versions[[1]]
#> [1] "12.3"
#> 
#> [[5]]$versions[[2]]
#> [1] "15.0"
#> 
#> [[5]]$versions[[3]]
#> [1] "15.2"
#> 
#> [[5]]$versions[[4]]
#> [1] "15.3"

Stop serving the site.