Confused: how does pkg, ports, and freebsd-update work?

Hello Everybody!

Just recently I migrated to FreeBSD from Debian Linux and I'd like to ask a couple of noobish question about things that confuse me in FreeBSD OS. I'm sure that information concerning things I want to ask about are there somewhere but I just can't seem to find straightforward answers. Please go easy on me :)

The first thing: the 'freebsd-update' command. When I use it to download and apply 'patches' I'm applying them to what exactly? Only kernel, applications included in vanilla installation of FreeBSD? And how does this relate to 'pkg' command? Is pkg able to update the same things freebsd-update updates? I just can't understand this, because in Debian there was no division - all I had to do was 'apt-get upgrade' and the system updates everything from kernel to web browser.

The second thing: how ports relate to the package system? When I install something from ports will the information concerning this application be available to pkg? Can I update an application which I installed from the ports collection with pkg? And if so - how would the update process treat custom-build application?
 
Packages are pre-compiled ports. Ports will always be ahead of packages because someone has to compile and test them. When you install from ports, a package is made and installed.

Installing from packages will be faster since compiling is not necessary.

freebsd-update adds patches to the kernel and all the supporting systems but not applications.

https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/ports.html
https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/updating-upgrading-freebsdupdate.html
 
Thank You!
And, just to be sure: the packages are pre-compiled ports WITH default compilation options selected?
 
I've forgotten the list but one problem is due to what I mentioned before, that packages are later than ports and, if a package requests an older dependency that was updated and installed by using ports, there could be issues.

I think most people choose one or the other. I have a fast system so I use ports for everything. Someone on a slow system would probably be best to stick with packages. An experienced user knows how to deal with the potential problem I mentioned.

However, I believe portmaster(8) and pkg(8) now warn of inconsistencies but someone else will have to verify that.
 
I am trying to find how to determine what ports revision was used to build latest official packages. I remember somebody even wrote a little script to automate it, but I can't find it. Can somebody help?

The idea is to use exactly the same ports as were used for building packages, so potential inconsistencies will be avoided.
 
I am trying to find how to determine what ports revision was used to build latest official packages. I remember somebody even wrote a little script to automate it, but I can't find it. Can somebody help?

The idea is to use exactly the same ports as were used for building packages, so potential inconsistencies will be avoided.

The SVN revision of the ports tree used to build the packages is not included in the package metadata (the ports are also built from portsnap(8) trees where the SVN revision is not even available) so I don't see how this could be even achieved? If it was it would be very trivial to match the right revision of the ports tree, you just checkout the correct revision and use that.
 
IIRC there was a way to extract ports revision used to build official packages. This info is not in a package meta-data, but, I think, somewhere in the build cluster history, log or something.
 
shirozuki, no one has mentioned ports-mgmt/poudriere. ADDED: Although you'll find information in the Handbook linked to above. If you have a multi-core system, preferably with ZFS, then poudriere can be the best of both worlds. You can customize the options ports are compiled with, ports can be compiled in parallel and you only have to compile once if you have more than one system. Here's a tutorial. It's more involved to get things set up than simply pkg install some_package, so if you're trying to ease into things it might not be what you're looking for.
 
Could You please elaborate? :) What should I be aware of and pay attention to when mixing them?
When I understand the experts in this forum correctly it is difficult to make sure that the dependencies are on track. As far as I know ports and packages finally use pkg as back end but the source and hence the dependencies can differ. Therefore it might be better not to mix ports and packages unless the user knows exactly what is going on. At least this is my understanding and conclusion.
 
When I understand the experts in this forum correctly it is difficult to make sure that the dependencies are on track. As far as I know ports and packages finally use pkg as back end but the source and hence the dependencies can differ. Therefore it might be better not to mix ports and packages unless the user knows exactly what is going on. At least this is my understanding and conclusion.

The ports tree is rolling---port maintainers can update their ports at their leisure, and users can grab a snapshot via portsnap or svn-lite at their leisure. The package repository is only updated once per week, though. So without knowing exactly which revision of the ports tree is used to update the repository there's a potential for conflicting dependencies. I typically install a package from the repository if I want to try it out. If I like it, I add it to my list of packages to be built with ports-mgmt/poudriere. I run Poudriere once a week, so a package could sit on my system for days before being rebuilt from source. For what it's worth, I've yet to run into problems doing this. Dumb luck, maybe.
 
freebsd-update updates base files, plus the generic kernel. Base files would be most of what is initially in (but not limited to) /bin, /etc, /sbin boot and other files that are used before any packages or ports are added. The kernel can be installed independently of freebsd-update, too, so while it is part of the base, it is sort of different.

IIRC there was a way to extract ports revision used to build official packages. This info is not in a package meta-data, but, I think, somewhere in the build cluster history, log or something.
I don't know, but I do know that port builds use the "HEAD" revision, which means the latest. This seems to imply another revision of ports, but not necessarily. If possible, it'd have to be a snapshot.
 
I found what I was looking for:

To get ports revision that was used to build packages for FreeBSD 10 amd64:

Code:
svn up -r `fetch -qo - http://beefy2.isc.freebsd.org/data/10amd64-default/.data.json | jq -r '.builds[.builds.latest].svn_url | split("@")[1]'`

Is it a good way to keep ports and packages in sync?
 
Use svnup(1), net/svnup, to update kernel source files. Use portsnap(8) to update your ports, and use freebsd-update(8) to update the base system.

svnup is much easier to use than other svn programs. All you have to do is uncomment which server you choose, and reference which section you want to update from /usr/local/etc/svnup.conf.

Something like this, svnup is one word in this example: svnup release
 
Last edited by a moderator:
Big thanks to all of you guys for sharing your knowledge! I'd very much like to learn more about FreeBSD. The official FreeBSD handbook is probably the best piece of documentation I've ever seen, but the way I see it - it's more about getting certain things done allowing one to easily accomplish specific tasks. Does anyone know any good tutorial or even a book that could help a noob such as myself understand how FreeBSD functions and get a little bit more familiar with its structure?
 
svnup is much easier to use than other svn programs. All you have to do is uncomment which server you choose, and reference which section you want to update from /usr/local/etc/svnup.conf.
Hi sidetone, according to the FreeBSD Handbook, he has to install the port devel/subversion and check the sources remotely and then update. Is it possible to update the sources with svnup? Must I install the port svnup to update the sources on FreeBSD? what line of the file must uncomment? Can I update all the sources without removing any reference?
 
Hi sidetone, according to the FreeBSD Handbook, he has to install the port svn and check the sources remotely and then update. Is it possible to update the sources with svnup? Must I install the port svnup to update the sources on FreeBSD? what line of the file must uncomment? Can I update all the sources without removing any reference?
net/svnup can replace svn directly for the purpose of updating sources, for common use. To configure and use it, edit /usr/local/etc/svnup.conf
uncomment one of the host lines according to which server is closer to you, and check that the [release] section matches your version:
Code:
host=svn0.<choice of server>.freebsd.org
[release]
branch=base/releng/10.1
Then all you'd have to do is type svnup and the section of the options you want.
Code:
svnup release

You can use either svnup or svn, you don't need both, but svnup is made to be easier to use for those who don't need development options.

svnup(1), svnup.conf(5)

I didn't understand your last question about removing references, but svnup works independently svn, uses a different configuration file, and if you meant uncommenting, svnup.conf's configuration is simple. I believe this answers your last question too, or is easier to figure out now.
 
Does anyone know any good tutorial or even a book that could help a noob such as myself understand how FreeBSD functions and get a little bit more familiar with its structure?

There are several books but (almost all of) the latest ones were made for FreeBSD 6 and 7 releases. Much is still the same, but they covered csup and cvup which aren't used for updating FreeBSD's base sources anymore. There are some books listed in https://www.freebsd.org/publish.html, and there are a few not listed there. FreeBSD 6 Unleashed, Network Administration with FreeBSD 7, Absolute FreeBSD (2nd edition), the Best of FreeBSD basics, are a few books that I want or already own. There are some more recent books too, these are made for specific tasks, are in other languages, or are made with information from wikis. https://wiki.freebsd.org/ is a wiki for developers, not for common tasks; http://www.freebsdwiki.net/index.php/Main_Page is a wiki, but a lot of it's latest edits were from 2007. http://www.bsdnow.tv/ and http://www.bsdguides.org are two websites. There are a couple more websites and many manpages to fill in on what can't be found or was updated.
 
net/svnup can replace svn directly for the purpose of updating sources, for common use. To configure and use it, edit /usr/local/etc/svnup.conf
uncomment one of the host lines according to which server is closer to you, and check that the [release] section matches your version:
Code:
host=svn0.<choice of server>.freebsd.org
[release]
branch=base/releng/10.1

Then all you'd have to do is type svnup and the section of the options you want.
Code:
svnup release

You can use either svnup or svn, you don't need both, but svnup is made to be easier to use for those who don't need development options.

svnup(1)svnup.conf(5)

I didn't understand your last question about removing references, but svnup works independently svn, uses a different configuration file, and if you meant uncommenting, svnup.conf's configuration is simple. I believe this answers your last question too, or is easier to figure out now.
If you are using a version FreeBSD 10.0-RELEASE or greater and all you want to do is sync from the latest available source , you can just use svnlite(1) which is included in the base install and will accomplish the same thing as using net/svnup or devel/subversion(svn). For example:

Initial full checkout:
# svnlite checkout https://svn0.us-west.freebsd.org/base/releng/10 /usr/src

Updating local source:
# svnlite up /usr/src
 
Does svnlite use a config file that is simple like svnup.conf? Does it use svn.conf? I looked into svnliteadmin, and didn't see options for it. svnlite's manpage didn't say anything on it, and the link from that manpage was about svn in general and was from 2011. There's nothing about svn in /etc either.
 
Does svnlite use a config file that is simple like svnup.conf? Does it use svn.conf? I looked into svnliteadmin, and didn't see options for it. svnlite's manpage didn't say anything on it, and the link from that manpage was about svn in general and was from 2011.

It's the full blown Subversion revision control system that is designed to do a whole lot more than just checking out a copy from a repository. There is no "simple" configuration file for it. It does say "lite" but that's just because it has the more advanced repository management features stripped away so it can be built as part of the base system without too many dependencies.
 
Back
Top