# Local pkg repository



## balanga (Mar 21, 2020)

I'm attempting to set up my local pkg repository following this guide Thread 68179.

I'm intending to use Apache as I'm most familiar with that. What I'd like to confirm is whether 

DocumentRoot "/usr/local/www/repo" should be the local equivalent of  https://pkg.freebsd.org/FreeBSD:12:amd64/quarterly/   ?


----------



## balanga (Mar 21, 2020)

Was wondering whether I could do a host override on my router to redirect pkg.freebsd.org to 192.168.1.31 (my repository host) so that I could leave /etc/pkg/FreeBSD.conf untouched....

Can I expect that to work?


----------



## balanga (Mar 22, 2020)

Well it seemed realatively easy enough to create

/usr/local/www/apache24/data/FreeBSD:12:amd64

and then copy over files from *pkg.FreeBSD.org* although I have yet to copy over the contents as I'm not sure about how much space the directories take up.

I changed the redirection on my router and `pkg install -y mc` seemed to work once I worked out which files were required. However I'm not sure whether I downloaded the files from my local repository or from FreeBSD since there is no logfile entry for accessing the repository...


----------



## T-Daemon (Mar 22, 2020)

balanga said:


> However I'm not sure whether I downloaded the files from my local repository or from FreeBSD since there is no logfile entry for accessing the repository...


Try `pkg query %R mc`. Run `pkg help query` for %R.


----------



## balanga (Mar 22, 2020)

It returns
*FreeBSD*
Not sure what that tells me... 
ping pkg.freebsd.org pings 192.168.1.34 which is my local repository, however there are no enties in apache's access.log showing the files have been accessed..


----------



## T-Daemon (Mar 22, 2020)

What is set in /etc/pkg/FreeBSD.conf or /usr/local/etc/pkg/repos/FreeBSD.conf as local repository  name? Ex.:

```
*FreeBSD*: {
           url: "pkg+http://pkg.freebsd.org/${ABI}/latest",
           enabled:    true,
```
Set the name to something unique, ex.: *Balanga*: { , reinstall mc, check again. If it's from the local repository, it should return _Balanga_.


----------



## balanga (Mar 22, 2020)

You're missing what I've done... I haven't changed anything on the system I'm testing. It is a first boot environment where FreeBSD has just been installed and a firstboot script is being run. I'm attempting to reroute requests to pkg.freebsd.org via my router without making any manual changes to the newly installed system.


----------



## balanga (Mar 22, 2020)

Just found the problem with the apache access logs... looks like they had been access, but it didn't look right.. the reason... the web server was in a jail and had a PDT timezone whereas it should have been a GMT timezone


----------



## balanga (Mar 22, 2020)

Now that I have configured a local pkgs repository I need to install some pkgs... how much space does 
*/FreeBSD:12:amd64/quarterly/All/*
take up?

Just wondered if it's possible to use my local repository as more of a cache so pkgs would be served if previously retrieved, but if not they would be directly retrieved from FreeBSD...


----------



## Phishfry (Mar 22, 2020)

86.9731 Gigabytes to be exact:
`pkg stats`

```
Local package database:
    Installed packages: 1035
    Disk space occupied: 10 GiB

Remote package database(s):
    Number of repositories: 1
    Packages available: 31541
    Unique packages: 31541
    Total size of packages: 81 GiB
```


----------



## balanga (Mar 23, 2020)

So the question, for me, is given that I'll probably only ever want 1% of 31,000 apps should I allocate 81GB of disk space for a repository where 99% of the space will never be used?

How to decide what to add to the repository?


----------

