Product SiteDocumentation Site

4.3.2. Setting [repository] Options

The [repository] sections (where repository is a unique repository ID, such as my_personal_repo) allow you to define individual Yum repositories. To define a new repository, either add this section to the /etc/yum.conf file, or to a .repo file in the /etc/yum.repos.d/ directory.
All .repo files in /etc/yum.repos.d/are read by yum, which allows you to create new, custom .repo files in this directory. Best practice is to define your repositories here instead of in /etc/yum.conf.
The following is a (bare-minimum) example of the form a .repo file takes:
[repository_ID]
name=A Repository Name
baseurl=http://path/to/repo or ftp://path/to/repo or file:///path/to/local/repo
Every [repository] section must contain the following minimum directives:
[repository_ID]
The repository ID is a unique, one-word (no spaces; underscores are allowed) string of characters (enclosed by brackets) that serves as a repository identifier.
name=A Repository Name
This is a human-readable string describing the repository.
baseurl=http://path/to/repo, ftp://path/to/repo, file:///path/to/local/repo
This is a URL to the directory where the repodata directory of a repository is located. Usually this URL is an HTTP link, such as:
baseurl=http://path/to/repo/releases/$releasever/server/$basearch/os/
Note that Yum always expands the $releasever, $arch and $basearch variables in URLs. See Section 4.3.3, “Using Yum Variables” for explanations of all Yum variables.
  • If the repository is available over FTP, use: ftp://path/to/repo
  • If the repository is local to the machine, use file:///path/to/local/repo
  • If a specific online repository requires basic HTTP authentication, you can specify your username and password in the http://path/to/repo by prepending it as username:password@link. For example, if a repository on http://www.example.com/repo/ requires a username of user and a password of password, then the baseurl link could be specified as:
    baseurl=http://user:password@www.example.com/repo/
The following is another useful [repository] directive:
enabled=value
...where value is one of:
0 — do not include this repository as a package source when performing updates and installs. This is an easy way of quickly turning repositories on and off, which is useful when you desire a single package from a repository that you do not want to enable for updates or installs.
1 — include this repository as a package source.
Turning repositories on and off can also be performed by passing either the --enablerepo=repo_name or --disablerepo=repo_name option to yum, or through the Add/Remove Software window of the PackageKit utility.
Many more [repository] options exist. Refer to the [repository] OPTIONS section of man yum.conf for the exhaustive list and descriptions for each.