# Automate install of packages/ports using lists



## Anatoly_kch (Jan 30, 2021)

Is there any rather simple tool that can take two list of packages and install them:
- "leaves" packages list that is the goal. Packages with its dependencies should be installed from FreeBSD repository as possible.
-  list of packages that should be build from ports with custom options. If we hit any package in this list while processing packages/dependencies from the first list, we should build it from port with custom options. Options may be already in file at /var/db/ports. I'd prefer no poudriere/"clean builds" here, just simple make install.


----------



## obsigna (Jan 30, 2021)

How about:





						FreeBSD: Dual Mode updating of installed ports and packages
					






					obsigna.com


----------



## Mjölnir (Feb 6, 2021)

Short answer: No.  Long answer: excerpt from standard disclaimer:
The utilities sysutils/psearch or sysutils/portfind will help you to find available software in the ports(7) tree.
Some nice small utilities are self-contained in the ports(7) tree (most under sysutils) and are not available as packages.
If you mix self-built ports(7) & packages, adjust both to use the same version (_quarterly_ vs. _latest_): /etc/pkg/FreeBSD.conf & portsnap(8) can not use the _quarterly_ ports(7) tree branch, read the Handbook.


----------



## gnath (Feb 6, 2021)

All packages are built from ports tree with custom options. You may create a list of packages of your choice and then redirect/cat it to package install.


----------



## Snurg (Feb 6, 2021)

This is a task I need to do with my postinstaller, too.
This is not fully trivial, as I learned with a lot of help from SirDice (Thanks man   ).

You need to place your patches into the ports' patchdir and use FreeBSD's `make -DBATCH` directive.
Then you need to prevent your patched/modded version been overwritten by `pkg`, using `pkg lock`.

I am not sure yet about the correct method to update.
But I guess, in case your apps from ports are end user apps (no libraries etc), it is best to `pkg update` first, then to script through the ports' `make -DBATCH` steps?
There are some other potential difficulties involved. For example, with particular ports command line make options appear to change sometimes, so one has to use the make.conf method, as I learned here.


----------



## ShelLuser (Feb 6, 2021)

Anatoly_kch said:


> Is there any rather simple tool that can take two list of packages and install them:
> - "leaves" packages list that is the goal. Packages with its dependencies should be installed from FreeBSD repository as possible.
> -  list of packages that should be build from ports with custom options.


As a rule of thumb you should not mix ports with packages because that is a sure recipe for disaster. This may be a good read, it's dated but still very much relevant.

Having said that... ports-mgmt/portmaster might be up to the challenge but...  why not just script this yourself? It sounds so trivial that a simple shell script should be all you need, optionally with a little help from portmaster(8) which can be told to either grab packages from a repository or to build using the ports collection.

Even so... I still want to point out once more that combining ports with binary packages can easily lead to huge issues.


----------



## Snurg (Feb 6, 2021)

ShelLuser said:


> As a rule of thumb you should not mix ports with packages because that is a sure recipe for disaster.


Yes this is known and feared but unavoidable.

The thing which makes me headaches now is that I need to find out how I can make sure that the bootstrap apache does not cause issues until I got to the point that I can add a local poudriere repo server to the installation template.
The bootstrapper downloads port apache24, patches, configures, builds and installs that modded apache24.
In a later step it must install some normal (unmodded) apache24 from the normal FreeBSD repo into some jails.

Maybe the best thing is to install the modded apache (running the postinstaller script as root), then rename/copy the files somehow, and then remove/delete the port, so that the modded apache can run undisturbed as "blind-passenger-package" not being registered by neither `pkg` nor ports, ensuring that the system management web interface will not get affected by system updates or pkg transactions...


----------



## ShelLuser (Feb 6, 2021)

Snurg said:


> Yes this is known and feared but unavoidable.


No it's not.


----------

