Cleanup and switch fromports to packages

I have a server running 11.3-p7 that has been upgraded over time since about 2009. When I originally built it, I chose not to use packages and I have been regretting that decision for years due to how much time it takes to handle updates. As I did not initially intend for it to be a server, I also remember installing a bunch of ports for fun and play and I am certain there is a lot of cruft laying about that I can remove.

So, I have a couple of questions and can really use your help. Please keep in mind that this is a production server:

1) According to pkg autoremove, there are 307 packages that can be removed, freeing up 7GB of space. According to pkg info there are 754 packages total installed. I know I did a lot of stupid stuff in the beginning, but 307 seems very high. In your experience, how reliable is pkg autoremove? Part of my concern is that some of the packages included in the list are commonly used programs such as zip, unzip, zsh, tmux, and spamassassin to name a few that I use regularly. I guess my issue is that I don't completely understand why it is generating this list in this manner as I explicitly installed zsh, tmux, and spamassassin.

2) I want to switch over to using packages instead of building ports with portmaster every time there is an update that I need to install. I don't remember ever setting any custom options when installing ports, but it has been a long time so I may have. From my research, it seems like the two best options would be to upgrade from 11.3 to 12.1 with the risk of old customization being broken or to make my own build server to build my own packages. Are there any other options that I am missing? At this time, I would prefer to avoid making a build server as I don't have a very suitable machine for it, but I will work something out if that is the only option.

Thanks!
 
Please keep in mind that this is a production server:
Then I assume you have made backups and verified their integrity.

Part of my concern is that some of the packages included in the list are commonly used programs such as zip, unzip, zsh, tmux, and spamassassin to name a few that I use regularly. I guess my issue is that I don't completely understand why it is generating this list in this manner as I explicitly installed zsh, tmux, and spamassassin.

In that case I wouldn’t rely on pkg autoremove. Instead delete individually the packages. You can create a list for the packages to be removed by executing pkg autoremove -n > remove , delete from the list the programs you want to keep, clean up the list so it consists only of the package names ( no version numbers ), with an editor which masters part of line global deletion/substitution, run pkg delete `cat remove` . Before deleting I would make a list of the installed packages: pkg info > pkg-info , pkg prime-list > prime-list.

From my research, it seems like the two best options would be to upgrade from 11.3 to 12.1 with the risk of old customization being broken or to make my own build server to build my own packages.

You don’t need to upgrade to 12.1 to switch over from ports to packages, unless you want to switch the release version.
Are there any other options that I am missing?

The only fact you should be concerned is to decide which package repository you want to track, latest or quarterly . latest is tracking the head ports tree, quarterly as the name says ( the currently installed programs are latest, unless you track a different ports branch than head ). In case you decide for latest, a new repository configuration file needs to be created, pkg.conf(5), and pkg upgrade run. In case of quarterly no repo config file needs to be edited ( quarterly is default ) only pkg upgrade -f run.
 
When I originally built it, I chose not to use packages and I have been regretting that decision for years due to how much time it takes to handle updates.
IMHO, there are only two good reasons for building ports yourself:
  • You want a lot of custom port options
  • You want to change something in DEFAULT_VERSIONS (e.g. it's pretty pointless to install libressl as a package)
If one of these applies to your usecase, you might for example want to build your own package repository using ports-mgmt/poudriere on a more powerful machine that you'll only have to start to build updates.

Otherwise, follow the advice already given :)
 
In that case I wouldn’t rely on pkg autoremove. Instead delete individually the packages. You can create a list for the packages to be removed by executing pkg autoremove -n > remove , delete from the list the programs you want to keep, clean up the list so it consists only of the package names ( no version numbers ), with an editor which masters part of line global deletion/substitution, run pkg delete `cat remove` . Before deleting I would make a list of the installed packages: pkg info > pkg-info , pkg prime-list > prime-list.
I definitely won't be using pkg autoremove. I would like to understand why pkg thinks those were installed as dependencies and are no longer needed as I've used autoremove in the APT world and never had this sort of issue before. I'm curious if it's something I did in the past.
You don’t need to upgrade to 12.1 to switch over from ports to packages, unless you want to switch the release version.
Apologies - I should have been more clear on this. I was planning to do the upgrade to 12.1 since I would be going through all of this work already.
The only fact you should be concerned is to decide which package repository you want to track, latest or quarterly . latest is tracking the head ports tree, quarterly as the name says ( the currently installed programs are latest, unless you track a different ports branch than head ). In case you decide for latest, a new repository configuration file needs to be created, pkg.conf(5), and pkg upgrade run. In case of quarterly no repo config file needs to be edited ( quarterly is default ) only pkg upgrade -f run.

I planned to stick with quarterly as I don't really have a need to track latest.

Thanks for the feedback!
 
I would like to understand why pkg thinks those were installed as dependencies and are no longer needed ...

Could be a bug. pkg autoremove is supposed to remove "orphaned packages, which were installed during dependency resolution and are no longer needed" ( pkg-autoremove(8) ) . Those packages are also know as automatic packages ( pkg(8), pkg-query(8) )

I'm curious if it's something I did in the past.

I suppose you haven’t set the packages as automatically installed package ( EXAMPLES pkg(8) ). Check with

pkg query ‘%a %o’ | sort

0 = non-automatic package
1 = automatic package

If those packages you have listed ( zip, unzip, zsh, tmux, and spamassassin ) are marked 0, but autoremove lists them for deletion, then it's a case for a bug report.
 
Back
Top