# Building inside a jail, how to install on host (outside the jail)



## Alain De Vos (Oct 13, 2022)

When building inside a jail : " /usr/ports , make , make install" , the files get installed in the jail.
But how do i install it outside the jail, on the host ? [ What is the proper way, the good way ]
[PS: With a PREFIX you get deeper in the jail, but not outside ]


----------



## angry_vincent (Oct 13, 2022)

maybe, in that jail, you can create pkg repository of all installed ports and move it to host.


----------



## kpedersen (Oct 13, 2022)

Generally you want to make a package `make package`.

Then you should be able to install these on the outside host.

You can also use pkg-create to create a package from an installed package (or port). However I don't like doing this after a while because any site specific tweaks to i.e config files also get added to the package.


----------



## mer (Oct 13, 2022)

kpedersen said:


> Generally you want to make a package `make package`.
> 
> Then you should be able to install these on the outside host.


Would the packages actually live in the jail, not on the host?  If so one would need to get them from the jail to the host.
I'm asking because I don't know what parts of a jail are visible to the host.


----------



## kpedersen (Oct 13, 2022)

mer said:


> Would the packages actually live in the jail, not on the host?  If so one would need to get them from the jail to the host.
> I'm asking because I don't know what parts of a jail are visible to the host.


Indeed. The packages will be built into the default directory inside /usr/ports. But from the host, you should just be able to use something similar to:

`# pkg add /myjails/buildjail/usr/ports/packages/All/mypackage-version.txz`

One nice thing about jails is they are completely exposed to the host as a basic directory structure. No virtual disk image, no network filesystem, no unionfs, etc.


----------



## mer (Oct 13, 2022)

kpedersen said:


> One nice thing about jails is they are completely exposed to the host as a basic directory structure. No virtual disk image, no network filesystem, no unionfs, etc.


Thanks.  I've not mucked around with them (no real need to) I know that some of the Linux container solutions work that way ($WORK, it's always a pain to figure out the path).


----------



## Alain De Vos (Oct 13, 2022)

Let's say i do in the jail:

```
cd /usr/ports/shells/mksh
make config
make
make package
```
Then i have a file:

```
/usr/ports/shells/mksh/mksh-59c.pkg
```
which i can install manually on the host as the jail-file-system is accessible from the host.

Problem are hundreds of dependencies.
For each dependency i have to manually "make package" and the build ".pkg" files are spread around (not in one directory)


----------



## angry_vincent (Oct 13, 2022)

look for `pkg-create`


----------



## kpedersen (Oct 13, 2022)

Alain De Vos said:


> For each dependency i have to manually "make package" and the build ".pkg" files are spread around (not in one directory)


Use `make package-recursive`

They should all go into a single folder inside /usr/ports/packages



			a quick question about make package-recursive


----------



## W.hâ/t (Oct 13, 2022)

I would use portmaster to create the packages instead of make-recursive


----------



## Alain De Vos (Oct 13, 2022)

Portmaster is rather slow. Parallizing is considered unstable.


----------



## Alain De Vos (Oct 13, 2022)

I'm gone try running "synth" (jrmarino) in a jail.


----------



## W.hâ/t (Oct 13, 2022)

The thing with make-recursive is that it will build some additional ports not required by the one you want to build.


----------



## Alain De Vos (Oct 13, 2022)

Normally i use poudriere in a jail, which is a good building system. But now i want to compile trinity-desktop for which no "real port exists".
So i am currently for that one trying to fall back on making all dependencies using "synth" in the same jail.
As far it seems to work.


----------



## W.hâ/t (Oct 13, 2022)

I am intrigued. Why not build the dependencies with the already configured poudriere?


----------



## Alain De Vos (Oct 13, 2022)

poudriere is very good to make a bulk list of packages and put those in "All" directory.
But you cannot use it when manual intervention is needed during the building process, like installing or deinstalling or patching a port.


----------



## W.hâ/t (Oct 13, 2022)

It is possible with `poudriere jail -s or poudriere testport -i`
I just dont know if it is a good or bad thing to do. That's why I was asking.


----------



## kpedersen (Oct 14, 2022)

W.hâ/t said:


> The thing with make-recursive is that it will build some additional ports not required by the one you want to build.


Really? First I have heard of this. What sort of additional ports and why if you don't mind me asking?

I tend to use BATCH=1 to skip the many config options other than the ones I am interested in beforehand; if this changes anything.

Slightly related, I have always suspected there to be an issue with deterministic reproducible builds this way; for example because a clean PREFIX isn't ensured for *every* port; some annoying detection in build scripts might end up compiling slightly different binaries. The porters do their best to avoid (sometimes by forcing it to drag in every possible dependency!) this but it is impossible to guarantee.


----------



## W.hâ/t (Oct 14, 2022)

Yes for some reason it does. I did a try for vim earlier to make sure. It did make a package for kuya, lutok, dejagnu, and an other I don't remeber. If you simply run make, it does not build them. I first saw this while running config-recursive.


----------



## alexseitsinger (Oct 20, 2022)

Alain De Vos said:


> When building inside a jail : " /usr/ports , make , make install" , the files get installed in the jail.
> But how do i install it outside the jail, on the host ? [ What is the proper way, the good way ]
> [PS: With a PREFIX you get deeper in the jail, but not outside ]


You couldn't find that kind of dangerous and destructive information on a (good) public forum like this so easily my friend. This is the kind of knowledge that careers are built on...


----------



## rigoletto@ (Oct 20, 2022)

You can get the answers to your questions looking how ports-mgmt/poudriere work (or make your life easier and use poudriere).


----------



## jmos (Oct 20, 2022)

I've wrote for myself a Tcl script that creates a package repository on the machine it is running on (on updates it also deletes the old packages, uses sub-directories like the ports-tree does, serves the repository via HTTP etc.). Simple. Combined with portmaster I'm even not thinking of looking at poudriere


----------



## bob2112 (Oct 24, 2022)

Alain De Vos said:


> poudriere is very good to make a bulk list of packages and put those in "All" directory.
> But you cannot use it when manual intervention is needed during the building process, like installing or deinstalling or patching a port.


Why would you need to patch a port manually during a build?


----------



## bob2112 (Oct 24, 2022)

W.hâ/t said:


> Yes for some reason it does. I did a try for vim earlier to make sure. It did make a package for kuya, lutok, dejagnu, and an other I don't remeber. If you simply run make, it does not build them. I first saw this while running config-recursive.



When you use 'config-recursive' you have to run it repeatedly until it stops bringing-up option menus. I think if you do this before  running 'package-recursive' it will work properly. You may end-up configuring ports that wont be built, but that's not a major problem. Recursive targets seem to have a problem picking-up dependency changes from option menus.


----------

