# Convert from ports to packages



## linux->bsd (Apr 1, 2018)

`pkg upgrade` will reinstall unlocked ports as packages, and then presumably those packages can be managed (updated) through pkg. However, after upgrading all but a couple of ports to packages, portmaster dies during `portmaster -aR`. I also get the impression that dependency ports aren't converted using `pkg upgrade`, since I don't see things like devel/llvm40 get upgraded during `pkg upgrade`.

So my questions is: how do I convert all of my installed ports (minus a couple of locked ports, due to settings requirements) to packages, and still have a working portmaster?


----------



## talsamon (Apr 1, 2018)

If you mean the recent update of the llvm* ports: The packages are a few days later as the ports on the server. You can create a package either from the port with `make package`, change in the wrksrc directory and install it with `pkg add` or build it with ports-mgmt/poudriere.


----------



## ShelLuser (Apr 1, 2018)

Why would you want to use Portmaster if you're only using binary packages? As its name implies Portmaster is meant to help you with the port building process. So if you're converting your system to using packages then stop using Portmaster and from here on rely on pkg instead.

Also: I _strongly_ recommend not trying to mix ports and packages, because in the end that can easily lead to massive problems on your system. It can work, but it heavily depends on the ports involved, in most cases its plain out a bad idea. This guide maybe a good read on that.

As to devel/llvm40: keep in mind that ports have 2 kinds of dependencies: those for running the software (see `make run-depends-list`) and those for _building_ the software (see `make build-depends-list`). See ports(7) for a full list of those build targets by the way.

Ports do not require build dependencies (such as LLVM) in order to run. This is also why Portmaster provides an option to clean up those build dependencies (which is a bad idea): simply because there's no real dependency on those packages so that can easily be removed:


```
$ pkg info -rx llvm40
llvm40-4.0.1_6:
Press any key to continue...
```
Therefor it's not surprising that you don't see these packages mentioned during an upgrade (unless there's a newer version of course), simply because no package actually depends on it.

So to convert from ports to packages... Here's what I'd do:

```
$ pkg info -aqo > packages
$ pkg delete -a
$ pkg install `cat packages`
```
Optionally you could consider using -aD for deleting, this will prevent de-install scripts from running and that can save you some time. If you are going to use that you could also consider using -I when running pkg-install(8). There is a risk here mind you: packages use default settings so there is a chance that some things have changed, in which case re-running the installation scripts is a good idea.


----------



## drhowarddrfine (Apr 1, 2018)

As ShelLuser has implied, I think you are confused about the difference between ports and packages. Packages are made from ports so moving from one to another is not an "upgrade". There is a delay while a port is being packaged but, other than that, they are the same thing. You need to spend some time with the Handbook and read up on that.


----------



## SirDice (Apr 3, 2018)

linux->bsd said:


> I also get the impression that dependency ports aren't converted using `pkg upgrade`, since I don't see things like devel/llvm40 get upgraded during `pkg upgrade`.


There are _build_, _run_ and _library_ dependencies. _Build_ dependencies are only needed to _build_ ports. Packages don't need _build_ dependencies because they're already built.


----------



## linux->bsd (May 17, 2018)

Been a while since I posted this thread and finally had a chance to check the replies. Most of what was posted was obvious stuff that I already knew and appears to have been borne out of a misreading of my OP, but they might be helpful for future readers, so might still prove useful.

As to the reason I was using portmaster to update the two or three ports I didn't convert to packages, it should be able to handle those without trampling on the packages or choking on itself, but it doesn't. Converting the rest to packages using `pkg upgrade` works fine.

Looks like I'll be doing something along these lines: https://forums.freebsd.org/threads/pkg-and-options-changed.65535/

Thanks.


----------



## ShelLuser (May 17, 2018)

linux->bsd said:


> Most of what was posted was obvious stuff that I already knew and appears to have been borne out of a misreading of my OP,


I suggest we agree to disagree because that is not what I am reading up there.  To a certain degree...  I do recognize that I focused on Portmaster.

Nothing which a late response can't fix:

`# pkg upgrade -f`

This will (re)install everything as binary packages. Anything beyond that is up to you.



linux->bsd said:


> As to the reason I was using portmaster to update the two or three ports I didn't convert to packages, it should be able to handle those without trampling on the packages or choking on itself, but it doesn't.


This shows me that your previous comments don't hold up: apparently you do not know how this stuff works despite your claims here.

I'd like to suggest this read:

https://forums.freebsd.org/threads/guide-about-ports-and-binary-packages.62126/

It explains why the above came to be. Not in direct wording, but if you follow along the concept...


----------



## linux->bsd (May 29, 2018)

ShelLuser said:


> Nothing which a late response can't fix:



But that just shows you didn't read the OP (or not closely enough), because as I stated I already converted to packages -- and guess which method I used.

The only part I wasn't aware of is that portmaster will try to update all installed ports and packages. Which I should have realized considering the hoops one has to jump through to determine if an application was installed via ports or pkg.

But as I said in my last reply, that link I posted has the information (toward its end) that I'll use to reconfigure my setup: all packages, with the exception of two ports whose default configurations don't work for me, and those I'll update manually via the make system.


----------



## SirDice (May 29, 2018)

linux->bsd said:


> because as I stated I already converted to packages


One thing you fail to realize is that once installed _everything_ is a package, even the things you built from ports. Ports build packages and it's these packages that eventually get installed.


----------



## linux->bsd (Oct 20, 2018)

SirDice said:


> One thing you fail to realize is that once installed _everything_ is a package, even the things you built from ports. Ports build packages and it's these packages that eventually get installed.



Great. That's the piece of the puzzle that I was missing, and it makes ShelLuser's confusion about my comments make sense. Thanks.

October 31st is fast approaching, so time to roll out my own repo and upgrade.


----------

