# Ports, Packages, Oh My!!!



## tzoi516 (Oct 31, 2013)

I've seen so many variations of package and port management mentioned (cvsup, svn, portsnap, portmaster, pkgng, poudiere, etc), and the Handbook covers pkg_add, pkgng, and svn.

After creating a new laptop build with Xorg/Xfce4 and security/geli, I gave KDE 4 a try and now get databases/sqlite errors when running www/firefox and mail/thunderbird. I've updated the ports tree via different methods, updated various ports, and am still getting that SQLite error under KDE 4. There are so many ways I've found on FreeBSD.org to update that I I just want to use the 1 or 2 preferred method(s) after rebuilding the laptop. So what is/are the preferred utilities by longtime BSD users? Not looking for instructions, just preferred methods - I can read and figure things out :stud. Thanks.


----------



## ShelLuser (Oct 31, 2013)

Depends on what your goal is. If you're aiming for ease of use and stability then obviously it's suggested to use the methods currently supported. So the pkg_* tools for package management and portsnap to keep your ports tree up to date.

That is; if you actually want to build packages yourself. To save time and effort you can also utilize binary packages (using `pkg_add -r`) which means that you won't have to maintain your ports tree.


----------



## jrm@ (Oct 31, 2013)

keep the ports tree updated with portsnap()
build everything from ports (usually with ports-mgmt/portmaster or manually with a `# make install clean` in the port directory)
 use devel/ccache and a RAM disk for building (see this BSDNow tutorial)
If I had one really fast box, I'd consider using ports-mgmt/poudriere as a package build server.
pkgng for package management
Added: Don't forget to look at /usr/ports/UPDATING before updating a package

YMMV


----------



## wblock@ (Oct 31, 2013)

Forget csup or cvsup, they are obsolete.

Here is what I suggest: Upgrading FreeBSD Ports.  That uses portsnap(8) to update the ports tree and ports-mgmt/portmaster to upgrade ports.

I use devel/subversion to update my own ports tree, because I have custom patches there.

devel/ccache is helpful for building the operating system (until 10.0, anyway), but I have never seen any real improvements when using it for ports.  I just don't rebuild ports often enough for them to be in the cache.  Maybe a really large cache would help.


----------



## aupanner (Oct 31, 2013)

Personally I keep a ports tree up-to-date via nightly `portsnap cron` (in cron), weekly `portsnap update` (manual), use `portmaster <dir/name>` (to (re)install ports), or `portmaster -aD` (to update em all).

I also chose to use pkgng (although why, I couldn't quite tell you).  To do that in 9.2 entails three steps:

Install ports-mgmt/pkg
Specify to use PKGNG in /etc/make.conf

```
WITH_PKGNG=yes
```

Update existing packages to PKGNG format, by issuing `pkg2ng`
Using PKGNG has the side effect of breaking some periodic scripts. To fix this, I needed to add to /etc/periodic.conf

```
# Show installed changes to packages (see /etc/periodic/daily/490.status-pkg-changes and /usr/local/etc/periodic/daily/490.status-pkg-changes)
daily_status_pkg_changes_enable="YES"
pkg_info="/usr/sbin/pkg info"
# Show available changes to packages (see /etc/periodic/weekly/400.status-pkg and /usr/local/etc/periodic/daily/400.status-pkg)
weekly_status_pkg_enable="YES"
pkg_version="/usr/sbin/pkg version"
# pkgng audit (see /usr/local/etc/periodic/security/410.pkg_audit)
daily_status_security_pkgaudit_enable="YES"
```

Postscript:
I should also note that `pkg2ng` marks all packages as "non-automatic". Pkgng distinguishes between "automatic" (eg: installed as a dependency) and "non-automatic" (eg: installed directly).  This status was not recorded previously.  If you want to get these values correct, you will need to delete all packages and reinstall. There are some tools out there to twiddle the automatic state, but that's more annoying than just doing a clean reinstall as long as you've got a free afternoon.


----------



## pvoigt (Oct 31, 2013)

I'm having exactly the same problem: The ports collection is the reason why I've started to move my home server from Linux to FreeBSD. But it's hard to hold the red line with the various ports tools. I know that a wrong combination of tools can even break depencies or destroy the database. I am surely not in the position to recommend the one or the other tool but would like to tell what I am using. I hope to get some useful hints.

I'm keeping the ports tree updated by portsnap running regularly by cron and according to email notifications manually.

For upgrading ports I usually use portupgrade or `make deinstall reinstall` in the ports tree. I prefer the last version if I feel configuration is needed via `make config`.

New ports are installed either by portinstall or `make config install clean`.

I am getting version information via `portversion -v` and `pkg_info`.

And finally, if a port is now longer needed, I prefer to use pkg_delete.

Up to now I did not yet use portmaster - it is not even installed. I feel it is an alternative to
portinstall and portinstall. Is this true or should I better use portmaster?

And one final question: I am not sure if any of the above tools uses or is the next generation package format PKGNG - as far as I've understood it is not.


----------



## wblock@ (Oct 31, 2013)

pvoigt said:
			
		

> For upgrading ports I usually use portupgrade or `make deinstall reinstall` in the ports tree. I prefer the last version if I feel configuration is needed via `make config`.



When you just rebuild a port, it does not automatically rebuild anything that depends on it.  portupgrade or portmaster are upgrade tools.  portmaster does it automatically, portupgrade uses the -r and -R flags.



> And finally, if a port is now longer needed, I prefer to use pkg_delete.



That's fine, it's functionally equal to `make deinstall`.



> Up to now I did not yet use portmaster - it is not even installed. I feel it is an alternative to portinstall and portinstall. Is this true or should I better use portmaster?



portmaster is an alternative to portupgrade.  Both are automatic port upgrade tools.  After using portupgrade for something like a decade, I now use portmaster, which is newer and has less overhead.



> And one final question: I am not sure if any of the above tools uses or is the next generation package format PKGNG - as far as I've understood it is not.



That is the back-end database that keeps track of installed packages.  On 10.0, it's the default.  On 9.x and earlier, it must be installed by the user (if desired, it's not required at present).


----------



## pvoigt (Oct 31, 2013)

Thanks, @wblock@, for clarifying some more points to me.

When reading your answer I see some more remaining question. I will try to ask as precise as possible in the hope each one can  be answered with just one sentence:

 Do installed (binary) packages and (from source built) ports use the the package database or does it depend on the database format (pkg vs. PKGNG)?

 As portmaster is more recent: Can I install and use portmaster with portugrade/portinstall in a parallel way?

 I'm currently running version 9.2-RELEASE-p1 and I'm planing to upgrade to 10-RELEASE via freebsd-update. As far as I understood this requires a rebuild of all installed ports. Will this automatically switch to PKGNG or should I better move to PKGNG now, e.g. before upgrading to version 10?

 @aupanner briefly describes migration to PKGNG in three steps: Step three remains unclear: How do you convert to the new database format?

 Will portupgrade, portinstall, portversion and pkg_delete still work with the new database format? If no, which replacements will you have to use?

 Being with the new database format: Can I still install ports with `make install|deinstall|reinstall|deinstall`?

 Is there a brief summary on these questions and the migration to the new database format?
Regards,
Peter

PS: I would really like to correct some typos and formating errors afterwards but I am unable to locate the EDIT button .


----------



## Juanitou (Oct 31, 2013)

A bit simplified, but that's how I do it (a beginner managing and old computer for fun): `portsnap fetch update` updates the port tree, `pkg [updating|version]` to read updating information and check needed updates, `portmaster [-e] [port1, port2¦]` to install and delete ports.


----------



## wblock@ (Nov 1, 2013)

pvoigt said:
			
		

> 1.) Do installed (binary) packages and (from source built) ports use the the package database or does it depend on the database format (`pkg` vs. `pkgng`)?



A port builds into a package, which is then installed the same as any other package.

Only one back-end database is used to record which packages are installed.  On FreeBSD 8 and 9, it will be the old-format database by default.  On FreeBSD 10 and later, it will be pkg.  Users of FreeBSD 8 and 9 can also switch to pkg.

(Note: "pkg" is the preferred name of the new package system now.)



> 2.) As `portmaster` is more recent: Can I install and use `portmaster` with `portugrade`/`portinstall` in a parallel way?



Yes, but there is no reason to do that.  portmaster does pretty much everything portupgrade does.  Incidentally, I'm pretty sure that portinstall is really just part of of portupgrade, not a separate thing.



> 3.) I'm currently running version 9.2-RELEASE-p1 and I'm planing to upgrade to 10-RELEASE via `freebsd-update`. As far as I understood this requires a rebuild of all installed ports. Will this automatically switch to `pkgng`



No.



> or should I better move to `pkgng` now, e.g. before upgrading to version 10?



I don't think it matters, but I would switch after the operating system upgrade and before rebuilding all ports.



> 4.) aupanner briefly describes migration to pkgng in three steps: Step three remains unclear: How do you convert to the new database format?



`pkg2ng` does that.  See Using pkgng for Binary Package Management.



> 5.) Will `portupgrade`, `portinstall`, `portversion` and `pkg_delete` still work with the new database format? If no, which replacements will you have to use?



Yes, yes, probably, and no.  pkg supplies replacements for the old pkg_* programs.  See the link above.



> 6.) Being with the new database format: Can I still install ports with `make install|deinstall|reinstall|deinstall`?



Of course.  It's only the back end database that has changed.



> 7.) Is there a brief summary on these questions and the migration to the new database format?



See the link above.


----------



## tzoi516 (Nov 1, 2013)

OK, this helps a lot. However, I think I just got confused. `pkgng` maintains the database backend that portsnap(8) and `portmaster` work from?


----------



## kpa (Nov 1, 2013)

The PKGNG database is a package database that records installed packages (installed from a remote repository or installed by installing a port) on the system, nothing else. It has nothing to do with portsnap(8) that is a tool meant for updating the /usr/ports ports tree.


----------



## pvoigt (Nov 1, 2013)

Thanks wblock@ for your brief an precise answers. They help a lot. As a fist step I've installed ports-mgmt/portmaster via portinstall. After having studied your provided link I am going to upgrade to pkgng before I upgrade to 10.0-RELEASE.


----------



## tzoi516 (Nov 1, 2013)

wblock@ said:
			
		

> (Note: "pkg" is the preferred name of the new package system now.)


Said as an abbreviation or "package"?


----------



## wblock@ (Nov 1, 2013)

tzoi516 said:
			
		

> Said as an abbreviation or "package"?



Good question.  I'd pronounce it as "package" unless that could be confused with the binary packages it manages.


----------



## tzoi516 (Nov 7, 2013)

Per FreshPorts 2013-06-22, ports-mgmt/portmaster doesn't require this in /etc/make.conf anymore:


```
WITH_PKGNG=yes
```

Has anyone noticed any impact with removing it?


----------



## wblock@ (Nov 7, 2013)

portmaster does not need it, but other programs still might.


----------

