# pkg fetch



## balanga (May 1, 2018)

If I `pkg fetch PKGNAME` where is it stored and how do I subsequently install it?


----------



## SirDice (May 1, 2018)

It's stored in /var/cache/pkg. Files you have locally can be installed with pkg-add(8).


----------



## balanga (May 1, 2018)

I'm trying to specify reponame using `pkg fetch -r http://pkg.freebsd.org/FreeBSD:11:amd64/latest/All mc`
but get

No repositories are enabled.

Have I got the wrong repository? I see it here ... Is this the wrong one or is there some extra configuration required?


----------



## Bobi B. (May 1, 2018)

pkg-fetch(8)'s `-r` expects repository name, not URL. Repositories are configured in /etc/pkg/; see pkg.conf(5).

And your goal is?


----------



## SirDice (May 1, 2018)

Bobi B. said:


> Repositories are configured in /etc/pkg/


Custom repositories should go in /usr/local/etc/pkg/repos/.


----------



## balanga (May 1, 2018)

So I should run:-

`pkg fetch -r /usr/local/etc/pkg/repos/mypkg.conf mc` ....?

And if this file is a copy of  /etc/pkg/FreeBSD.conf it should work?

I tried this but get 'No repositories are enabled.'


----------



## ShelLuser (May 1, 2018)

When in doubt check the manualpage. In this case pkg-fetch(8):


```
-r reponame, --repository reponame
                   Fetches packages from the given reponame if multiple repo
                   support is enabled.  See pkg.conf(5).
```
Well, /usr/local/etc/pkg/repos/mypkg.conf is obviously not a repo name but a filename. Looking at pkg.conf(5) this should become more clear: you need to use the name of the actual repository.


----------



## SirDice (May 1, 2018)

Consider this:

```
myreponame: {
  enabled: yes
  url: packages.example.com/packages/${ABI}
}
```

You reference that repository by its _name_: `pkg install -r myreponame somepackage`


----------



## balanga (May 1, 2018)

ShelLuser said:


> When in doubt check the manualpage. In this case pkg-fetch(8):
> 
> Well, /usr/local/etc/pkg/repos/mypkg.conf is obviously not a repo name but a filename. Looking at pkg.conf(5) this should become more clear: you need to use the name of the actual repository.



Some of these man pages need a month to study - there are so many options... Thanks for pointing out my error in misunderstanding reponame....

Just FYI check pkg.conf(5) ... it includes 

```
The file is in UCL    format.     For more information on the syntax of UCL,
     please visit the official UCL website -
     http://github.com/vstakhov/libucl.
```
So give it a try...


----------



## balanga (May 1, 2018)

SirDice said:


> It's stored in /var/cache/pkg. Files you have locally can be installed with pkg-add(8).



I have pkg-fetch(8) working now but pkg-add(8) is failing. Can I use the short name for pkg in both cases? ie unix2dos, or do I need to include the full filename of the pkg?


----------



## SirDice (May 1, 2018)

With pkg-add(8) you give the actual filename.


----------

