# How to copy a port build



## balanga (Mar 25, 2019)

If I have built an app  from ports how do I copy it to another system? Do I first need to create a pkg and then use `pkg install` on the other system?


----------



## acheron (Mar 25, 2019)

yes


----------



## balanga (Mar 25, 2019)

Any guidance/tips on how to do that?


----------



## acheron (Mar 25, 2019)

`make package` or `pkg create firefox` if firefox is installed and scp/rsync


----------



## balanga (Mar 25, 2019)

So, I've now managed to create  my pkg and want to install it from a local repository....

According to https://www.freebsd.org/cgi/man.cgi?query=pkg.conf  the system wide configuration file is:-
/usr/local/etc/pkg.conf

and that includes:-

```
# Configuration options -- default values.

#PKG_DBDIR = "/var/db/pkg";
#PKG_CACHEDIR = "/var/cache/pkg";
#PORTSDIR = "/usr/ports";
#INDEXDIR = "";
#INDEXFILE = "INDEX-10";        # Autogenerated
#HANDLE_RC_SCRIPTS = false;
#DEFAULT_ALWAYS_YES = false;
#ASSUME_ALWAYS_YES = false;
#REPOS_DIR [
#    "/etc/pkg/",
#    "/usr/local/etc/pkg/repos/",
#]
```

so even though these values are commented out I assume they are used. But when installing my pkg in  /usr/local/etc/pkg/repos/ and running `pkg install -n -r /usr/local/etc/pkg/repo kodi` I get 





> No repositories are enabled.


I created a /usr/local/etc/pkg/repo and put my pkg in it.

Then after creating /usr/local/etc/pkg/repo/FreeBSD.conf containing

```
FreeBSD: { enabled: YES }
```
I get the same msg.

Is there a tutorial on this anywhere?


----------



## SirDice (Mar 25, 2019)

You're not supposed to put the packages in /usr/local/etc/pkg/repos, it's for configuration files. Similar to /etc/yum.repos.d/ on CentOS/RedHat. You don't save RPMs in there either. 



balanga said:


> Is there a tutorial on this anywhere?


Have a read through pkg-repositories(8).

You can install packages from a local directory with pkg-add(8), i.e. `pkg add /tmp/mypackage.tgz`


----------



## acheron (Mar 25, 2019)

If you have only one pkg you can do `pkg add /tmp/kodi.txz`
If you have multiple pkgs, you can create some random dir (see url below), put them here and do `pkg repo $url`
This is what I have on my system :

```
cat /usr/local/etc/pkg/repos/FreeBSD-base.conf
# FreeBSD base system repository
FreeBSD-base: {
  url: "file:///usr/obj/usr/src/repo/${ABI}/latest",
  enabled: no
}

FreeBSD-base2: {
  url: "http://192.168.2.1/repo/FreeBSD:13:aarch64/latest/",
  enabled: yes
}
```


----------



## balanga (Mar 25, 2019)

Well I thought I'd finally got the hang of it but it turns out that the pkg was built on 11.2 and that I couldn't install it on 12.0 ..

So now I have to run:-

```
freebsd-update upgrade -r 12.0-RELEASE
freebsd-update install
shutdown -r now
freebsd-update install
pkg-static upgrade -f
freebsd-update install
shutdown -r now
```

and then I can start to build my app again....

although I'm not sure if I need to upgrade ports... Is the same ports collection used for every architecture and release of FreeBSD?


----------



## Minbari (Mar 25, 2019)

If you have multiple machines which run FreeBSD the best way it's to install ports-mgmt/poudriere to build custom packages. With poudriere you can build packages for 11.2, 12.0, arm, i386, etc.


----------



## balanga (Mar 26, 2019)

Minbari said:


> If you have multiple machines which run FreeBSD the best way it's to install ports-mgmt/poudriere to build custom packages. With poudriere you can build packages for 11.2, 12.0, arm, i386, etc.



Never having looked into ports-mgmt/poudriere properly, I always imagined it was difficult to setup.


----------



## SirDice (Mar 26, 2019)

balanga said:


> I always imagined it was difficult to setup.


It's surprisingly easy to set up and maintain. Once you've set it up you will wonder why you didn't do it sooner.


----------

