Skip to content
forked from drat-base/drat

Sample drat repository for easy forking and bootstrapping

Notifications You must be signed in to change notification settings

LandSciTech/drat

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

drat - LandSciTech R package 📦 repository

We are using the drat R package to set up the infrastructure for a mini R package repository.

The intent is to make it easy for R users to install LandSciTech R packages that are not on CRAN, and keep them up to date.

Usage

Package Users: Installation of LandSciTech R packages

The easiest way to set yourself up to use this drat repository is to first install the drat package:

install.packages("drat")

Then add the LandSciTech drat repo to your list of repositories to install from:

drat::addRepo("LandSciTech")

Add the above line to your .Rprofile file so that the LandSciTech drat repository is available every time you run R. This discussion of R startup processes is a good introduction if you have never edited your .Rprofile before.

Now you can install a package from the LandSciTech repository with install.packages(). For example:

install.packages(NAME_OF_PACKAGE_TO_INSTALL)

Package Authors: Adding a package to the LandSciTech drat repository.

On Github:

  1. Fork this LandSciTech drat repository.

On the command line:

  1. Clone this repository to your machine and open the directory:

    git clone https://github.com/[YOUR GITHUB USERNAME]/drat
    cd drat
    
  2. Build the package that you want to add to the drat repository. This can be done on the command line or in R using devtools:

    a. Command-line: Move to the directory in which your package directory resides and replace mypkg with the name of your package. Either of these will build a file called mykg_pkg.ver.tar.gz one directory up from your package directory:

    R CMD build "mypackage"
    

    b. R/Rstudio: In the console in your R package project:

    devtools::build()
  3. Open R, and use the drat::insertPackage() function to add the built package (tar.gz file) to the drat repo:

    drat::insertPackage("mypackage_pkg.ver.tar.gz", "path/to/drat")
    • If you are comfortable, you can add the argument commit = TRUE to the above function call and it will automatically commit the changes that add the package to the gh-pages branch in the drat repository. Otherwise, go to step 4:
  4. Visually verify that the package has been added in src/contrib, then add, commit, and push the changes. Once you are satisfied you have added your package and would like to submit it to the LandSciTech drat repository, create a pull request to merge your changes (i.e. the addition of a new package) back in the LandSciTech drat repository.

Package Authors: Removing a package from the LandSciTech drat repository.

Removing a package from a drat repository is a multi-stage process whereby the source file of the package is removed, the drat repository index is updated and then the changes are committed and pushed.

  1. The first step is to fork this LandSciTech drat repository.

  2. There are many way to remove the source file. Here we are removing it with R. If you are in the top-level drat directory you can set the directory where the source files are along with the specific source file you'd like to remove. From there removing the file is easily accomplished:

    # Source directory
    pkgdir <- normalizePath("./src/contrib", winslash = "\\")
    
    # Filename of the package you would like to remove
    pkgname <- "FILENAME.tar.gz"
    
    # Remove the source file
    file.remove(file.path(pkgdir, pkgname))
  3. Now that we have removed the file, we need to update our index so that the repository no longer looks for the removed package like this:

    tools::write_PACKAGES(dir = pkgdir, type = "source")
  4. After completing steps 1, 2 and 3, there should 4 changes in your repository: the package itself and the three PACKAGES files. Stage, commit and push those changes. If you are happy with the results, you can submit a pull request to the LandSciTech drat repository. Once accepted, your package should now be completely removed from the LandSciTech drat repository.

Project Status

Under active development.

Please note this was copied from the bcgov drat repository since their README provides good advice.

License

Copyright 2017 Province of British Columbia

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at 

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

Sample drat repository for easy forking and bootstrapping

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published