3.2.1 ‘CPT_PATH

Similar to the ‘PATH’ variable, ‘cpt’ find repositories from the ‘CPT_PATH’ variable. Here is an example:

CPT_PATH=$HOME/repos/repo1:$HOME/repos/repo2:$HOME/repos/repo3

This is a simplistic and a structured example for repository locations, but it doesn’t necessarily need to be as tidy as the example above. Here is an example for something a little more complex.

CPT_PATH=$HOME/repos/overrides:/var/db/cpt/repo/core:/var/db/cpt/repo/extra:$HOME/repos/personal

This example brings us to the next section of this document.

  1. Repository preferences

    When you are using multiple repositories from multiple vendors, you will find out that some repositories have the same packages. ‘cpt’ doesn’t care about conflicting packages. If you want to build a package that exists on multiple repositories, ‘cpt’ will build the first matching package. This means that if ‘grep’ package (for the sake of an example) exists on both ‘$HOME/repos/personal’ and ‘$HOME/repos/carbs/extra’, and you want to install from your personal repository, you must set ‘CPT_PATH’ so that your personal repository is listed before the ‘extra’ repository.

    CPT_PATH=$HOME/repos/personal:$HOME/repos/carbs/extra
    
  2. Setting the ‘CPT_PATH

    You can set the ‘CPT_PATH’ variable on your shell configuration or your ‘.profile’ file in a way that is easy to read.

    The below example sets ‘CPT_PATH’ in a way that is easy to understand which repository comes first:

    CPT_PATH=$HOME/repos/overrides
    CPT_PATH=$CPT_PATH:$HOME/repos/carbs/core
    CPT_PATH=$CPT_PATH:$HOME/repos/carbs/extra
    CPT_PATH=$CPT_PATH:$HOME/repos/carbs/xorg
    CPT_PATH=$CPT_PATH:$HOME/repos/personal
    export CPT_PATH