# Using pkg with binary package tree



## ronaldlees (Jan 16, 2018)

Maybe there's an easy way to do what I want to do on FreeBSD.  I tend to do something a particular way (which is whatever method I first determined would work well enough for purpose, on the day I discovered it).  Then ten years pass.

Anyway, recently I've been using Gentoo on my XU4 board and its SSD, because no BSD has been ported to it yet.  It uses portage, which IIRC is a project that looked to the FreeBSD ports system for inspiration.  Anyway, it contains a binary package tree that mirrors the ports build files tree that our ports system uses.  So, it's easy to install a binary package, without worrying about whether or not all of the correct packages have been built and saved.  You just run quickpkg "*/*" once in awhile, and the whole binary tree is up to snuff.  I've grown to like this way of doing things.  I can make archival copies of the tree, and transfer it to other devices, and install stuff with no worries about missing packages, etc.

 So, how do I do that on FreeBSD?  It's probably already built into ports, and simple - meaning I've just not expended enough time to update my "method"


----------



## rigoletto@ (Jan 16, 2018)

I do not know if I understood your question very well, but isn't it something like a poor cousin of ports-mgmt/poudriere and/or ports-mgmt/synth package repository?

Btw, since you are using Gentoo you may want to take a look in Paludis, an alternative to portage (what is very slow because it is written in python), but also Sabayon the "binary" Gentoo.

Cheers!


----------



## ronaldlees (Jan 16, 2018)

lebarondemerde said:


> I do not know if I understood your question very well, but isn't it something like a poor cousin of ports-mgmt/poudriere and/or ports-mgmt/synth package repository?
> 
> Btw, since you are using Gentoo you may want to take a look in Paludis, an alternative to portage (what is very slow because it is written in python), but also Sabayon the "binary" Gentoo.
> 
> Cheers!



Thanks, I'll have a look at those alternatives to portage.  Well, I know I could use poudriere or synth, but those are real projects with non-trivial setups.  With portage, there's no work involved with creating a binary package tree that's meshed/sync'ed with the portage "ports" build tree.  So, you end up with a transferable archive that can install any binary in the tree, and knows properly which dependencies need to be installed, and so forth, and it takes no effort.  One can make a copy of the binary package tree, put it on another computer and install any binary package with no effort, and it's all synced into the build tree.  

So yes - it's like a poor cousin, but it's part of the base port system, with no extra stuff needed.


----------



## scottro (Jan 17, 2018)

Is there any chance that make package could do what you want?  For example, I build a custom version of dwm, and, if I feel like playing around with the config, I can do `make package dwm` which creates a binary package that I can install in case something goes wrong with my build. I've not tried it in any complicated sense, so don't know how it would do pulling in dependencies and such.


----------



## rigoletto@ (Jan 17, 2018)

scottro

`make package` use pkg-create(8). And yeah, it almost certainly can be scripted to do what ronaldlees want.


----------



## scottro (Jan 17, 2018)

Bah, pkg-create.  Yes, thank you, my bad. I'm blaming my medication.


----------



## ronaldlees (Jan 17, 2018)

Yeah, I use:

  mkdir package-archive
  cd package-archive
  pkg create -a

  - which builds packages for all of the installed ports on the system, and deposits the resulting .txz files in the package-archive directory.   That's OK, but when I subsequently use pkg to install one of the packages in that directory, it's messy because they're not smoothly tied into the ports tree for dependencies. Meta packages work OK, but it seems to be a hit or miss thing on other packages depending upon -- I guess - how the packages were built.

Also - if I want to collect a small subset (and all the dependencies) of the binary packages in the package-archive into a smaller  archive tarball containing a certain type of packages, for example, I have to manually piece the set together.


----------



## rigoletto@ (Jan 17, 2018)

ronaldlees said:


> Yeah, I use:
> 
> mkdir package-archive
> cd package-archive
> ...



Take a look on pkg-repo(8). 

However, I still think it is simpler just using ports-mgmt/synth, and point the other machines to grab the packages from that repository. The only necessary extra would  be a tiny webserver or some ftp server.


----------



## ronaldlees (Jan 17, 2018)

Thanks, I'll have a look.


----------



## rigoletto@ (Jan 17, 2018)

Oh, one time you have your repo you can use net/syncthing (and friends) to keep the other machines repos automatically updated.


----------



## phoenix (Jan 18, 2018)

If you only every use the default settings when installing from the ports tree, then you can skip it completely and just use pkg(8) to install everything.  That handles all your dependency tracking.  Binary packages are built multiple times per week (if tracking the "head" or "latest" package repo) or every 3 months (if tracking the "quarterly" repo; with security updates happening as needed).

You don't even have to have the ports tree installed on a system in order to use pkg(8).

If you change the options when building from the ports tree, though, you won't be able to use the package repos provided by FreeBSD.  But, you can create your own package repos using tools like poudriere or synth.


----------

