# Updating Ports Help



## markbsd (Nov 6, 2013)

What is the most effective way to update/upgrade individual ports?

Run `pkg info` to determine what has newer versions available.

Then `# portmaster --packages-if-newer [port_name]`?


----------



## markbsd (Nov 6, 2013)

Or would I be better off installing ports-mgmt/portupgrade and running `pkg_version -l "<"` to get a list of outdated ports than using `portupgrade -R [port_name]`?


----------



## tzoi516 (Nov 6, 2013)

markbsd said:
			
		

> Or would I be better off installing ports-mgmt/portupgrade and running `pkg_version -l "<"` to get a list of outdated ports than using `portupgrade -R [port_name]`?



I've been using ports-mgmt/portmaster and running `portmaster [port_name]`


----------



## wblock@ (Nov 6, 2013)

Careful, you have multiple things mixed together.

The ports tree is meant to work as a whole.  If you try to leave some ports at outdated versions, it will eventually cause problems.

`pkg info` is a command from the new pkg package management system.  *If you have switched to pkg, do not use any of the old package system commands any more.  The old system commands all start with pkg_*.  Note the underline.

ports-mgmt/portmaster and ports-mgmt/portupgrade were developed to handle upgrading ports.  Use them.  In fact, use portmaster.  There is almost no reason to go with portupgrade.  Related: Upgrading FreeBSD Ports.

As far as using packages for port upgrades: I'm convinced that most people spend more time "saving time" with binary packages than just building from ports.  No doubt somebody has it working perfectly and we don't hear from them because there are no problems, but we sure hear about the other side.


----------



## markbsd (Nov 6, 2013)

tzoi516 said:
			
		

> I've been using ports-mgmt/portmaster and running `portmaster [port_name}`



And this just installs the new version over the top of the existing version?



			
				wblock@ said:
			
		

> Careful, you have multiple things mixed together.
> 
> The ports tree is meant to work as a whole.  If you try to leave some  ports at outdated versions, it will eventually cause problems.



Ultimately, I want to keep all my apps (which have all been installed from ports) up-to-date. But when I last performed `portmaster -af` it was running for 3 straight days (literally), then left my system not working correctly. So, I've done a fresh install and am using a minimalist approach.



> `pkg info` is a command from the new pkg package management system.  *If  you have switched to pkg, do not use any of the old  package system commands any more.  The old system commands all start  with pkg_*.  Note the underline.



I have switched to the new pkgng system.

What is the pkgng `pkg_info` alternative? And is it even unwise to perform query pkg_ commands?



> ports-mgmt/portmaster and  ports-mgmt/portupgrade were developed to handle upgrading  ports.  Use them.  In fact, use portmaster.  There is  almost no reason to go with portupgrade.  Related: Upgrading FreeBSD Ports.



So, how do I perform updates/upgrades (collectively and of individual ports/packages) with `portmaster`?



> As far as using packages for port upgrades: I'm convinced that most  people spend more time "saving time" with binary packages than just  building from ports.  No doubt somebody has it working perfectly and we  don't hear from them because there are no problems, but we sure hear  about the other side.



I am using exclusively ports this time round. It takes forever to install things, but apparently it's better.


----------



## tzoi516 (Nov 6, 2013)

markbsd said:
			
		

> And this just installs the new version over the top of the existing version?



Recursively checks and upgrades/installs all dependencies of the installed port.


----------



## markbsd (Nov 6, 2013)

tzoi516 said:
			
		

> Recursively checks and upgrades/installs all dependencies of the installed port.



Awesome! Thank you!


----------



## wblock@ (Nov 6, 2013)

markbsd said:
			
		

> And this just installs the new version over the top of the existing version?



Yes, but it also updates any ports that depend on the one just updated.



> Ultimately, I want to keep all my apps (which have all been installed from ports) up-to-date. But when I last performed portmaster -af it was running for 3 straight days



Yes, -af means "force rebuilding of every installed port".  Don't do that, it is not appropriate for routine use.  Even -a is should not be used until after checking /usr/ports/UPDATING, as mentioned in the article above.



> What is the pkgng `pkg_info` alternative?



`pkg info`



> And is it even unwise to perform query pkg_ commands?



The old package database is completely different from the new.  As soon as you switched, the information in the old one was out of date.  After switching to pkg, do not use the old commands or trust information they provide.  It is wrong.



> So, how do I perform updates/upgrades with `portmaster`?



Upgrading FreeBSD Ports.  Klicken Sie auf den Link.



> I am using exclusively ports this time round. It takes forever to install things, but apparently it's better.



Tailor-made versus off-the-rack.


----------



## Juanitou (Nov 6, 2013)

markbsd said:
			
		

> And this just installs the new version over the top of the existing version?



May I suggest you tou just type `pkg` in your command prompt? All the commands are fully explained in the man page, and the same can be said of portmaster.

You could also check this thread: [thread=42901]Ports, Packages, Oh My!!![/thread]

Thatâ€™s how I do it:


> 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.


----------



## markbsd (Nov 6, 2013)

wblock@ said:
			
		

> Yes, but it also updates any ports that depend on the one just updated.



Is this a bad thing? If I have


```
# Install packages for build-only dependencies (--packages-build)
PM_PACKAGES_BUILD=pmp_build 
# Delete build-only dependencies when finished (--delete-build-only) 
PM_DEL_BUILD_ONLY=pm_dbo
```
In my /usr/local/etc/portmaster.rc, will the update process still delete build dependencies post install? Which is, ideally, what I want, yes?



> Yes, -af means "force rebuilding of every installed port".  Don't do that, it is not appropriate for routine use.  Even -a is should not be used until after checking /usr/ports/UPDATING, as mentioned in the article above.


I got the command from the Handbook. I don't know if it's outdated, but I won't ever be running that command again. I couldn't believe how long it took. Only to render my system unusable!



> `pkg info`
> 
> The old package database is completely different from the new.  As soon as you switched, the information in the old one was out of date.  After switching to pkg, do not use the old commands or trust information they provide.  It is wrong.


Good to know. Thanks!




> Upgrading FreeBSD Ports.  Klicken Sie auf den Link.
> 
> 
> Tailor-made versus off-the-rack.


I just wish it didn't take so long!


----------



## cpm@ (Nov 6, 2013)

Here you have a usable portmaster.rc example. Read portmaster(8)() manpage for details.


----------



## wblock@ (Nov 6, 2013)

markbsd said:
			
		

> Is this a bad thing? If I have
> 
> 
> ```
> ...



Build dependencies may be needed again by something else, so I don't delete them and have not tried having portmaster auto-delete them.  This could be a form of premature optimization.



> I got the command from the Handbook.



Where, exactly?



> I just wish it didn't take so long!



If you did not delete build dependencies, it would take less time because they would not have to be rebuilt every time...


----------



## markbsd (Nov 6, 2013)

wblock@ said:
			
		

> Build dependencies may be needed again by something else, so I don't delete them and have not tried having portmaster auto-delete them.  This could be a form of premature optimization.



Good point. I'll have to reconsider my position.




> Where, exactly?



http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/ports-using.html

Near the end of the page.




> If you did not delete build dependencies, it would take less time because they would not have to be rebuilt every time...



You make a good argument. But, how many ports that I install would have the same build dependencies as previously installed ports? I suppose that answer would determine whether or not keeping them is optimal. In the event of a collective `portmaster` update, I'd want as few apps as possible being updated, so it's not running for several days.


----------



## wblock@ (Nov 6, 2013)

Well, there are the autotools ports, which are not terribly big.  But there is also gcc, and a lot of ports use a particular version.  So on an upgrade, it must be built, then discarded.

So yes, that could certainly slow down the upgrade of lots of things.  So let me suggest turning off these options and running without them for a few months.  They can always be turned back on later, but as it is, they are probably slowing down the process.


----------



## srobert (Nov 6, 2013)

My (almost daily) port upgrades for my laptop usually proceed as follows.

```
#pkg audit -F
```
Only do that if you have PKGNG. If not I think it's `portaudit`.
If that reports no problems. Then I do. 

```
#portsnap fetch update
```
Assuming it updates the ports tree, I then do:
	
	



```
#more /usr/ports/UPDATING
```
If the UPDATING file has no special instructions, I then do:

```
#portmaster -aD
```
Then I select any new options that are needed and let it run to completion. 
I typically do this at the end of the day and it usually doesn't take long. Sometimes a large port like editors/libreoffice or www/firefox gets rebuilt, in which case I let it run overnight. If a large number of ports is upgrading, the probability for some sort of failure increases. Reading the compiler errors and doing some forum searches leads to resolution. Most often the whole process concludes in less than 15 minutes. That's on a dual core amd64 with 4 GB of RAM. Once in a while I do a `portmaster --clean-distfiles` to clean out old versions of distfiles that were missed when something went wrong. To make things build a little faster check out this tutorial.


----------



## ShelLuser (Nov 6, 2013)

markbsd said:
			
		

> But, how many ports that I install would have the same build dependencies as previously installed ports?


You might want to look into `portmaster -l | tee portmaster.log`. This will give you a list of all the installed ports divided into categories. You'll see exactly which ports have dependencies and which do not.

At first this can help you with getting an idea which ports would be suitable for removal. But these ports can also be liable build dependencies (provided you didn't de-install those already).

But in the end most ports will have build dependencies; see `# make build-depends-list` which you can run in a port directory to check for these. Be careful that you don't mix these with the run dependencies; sometimes they overlap but more than often they don't or differ slightly.


----------



## wblock@ (Nov 6, 2013)

markbsd said:
			
		

> http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/ports-using.html
> 
> Near the end of the page.





> If errors are encountered during the upgrade process, add -f to upgrade and rebuild all ports:
> `# portmaster -af`



That's... well, not terrible.  Not sure what situation the author was anticipating.  (This time, at least, it was not something I wrote...)


----------



## markbsd (Nov 7, 2013)

wblock@ said:
			
		

> Well, there are the autotools ports, which are not terribly big.  But there is also gcc, and a lot of ports use a particular version.  So on an upgrade, it must be built, then discarded.
> 
> So yes, that could certainly slow down the upgrade of lots of things.  So let me suggest turning off these options and running without them for a few months.  They can always be turned back on later, but as it is, they are probably slowing down the process.



I'll take your advice, see how it goes. I just don't want to end up with 100+ ports installed.

Xfce4, for example, only has 13 run dependencies, but it's now been installing from ports for OVER 4 HOURS! That's insane! I don't remember it taking this long when I installed it last week using `cd /usr/ports/x11-wm/xfce4 && make install clean`. Does using `portmaster /x11-wm/xfce4` (as opposed to `make install`) install more dependencies or something? Because it's taking so much longer to install this time than the last.



			
				srobert said:
			
		

> My (almost daily) port upgrades for my laptop usually proceed as follows.
> 
> ```
> #pkg audit -F
> ...



Thanks, srobert.

I don't know how you get it done in 15 minutes. My last `portmaster -af` literally took several days! And, I ran `portmaster` x11-wm/xfce4 a little over 4 hours ago -- it's still running!

I've had a quick look at /usr/ports/UPDATING, I'm not sure I'll know exactly how to interpret it, or how to adjust my updating/upgrading in accordance with its instructions



			
				ShelLuser said:
			
		

> You might want to look into `portmaster -l |  tee portmaster.log`. This will give you a list of all the  installed ports divided into categories. You'll see exactly which ports  have dependencies and which do not.
> 
> At first this can help you with getting an idea which ports would be  suitable for removal. But these ports can also be liable build  dependencies (provided you didn't de-install those already).
> 
> But in the end most ports will have build dependencies; see `# make  build-depends-list` which you can run in a port directory to check  for these. Be careful that you don't mix these with the run  dependencies; sometimes they overlap but more than often they don't or  differ slightly.



Thanks, ShelLuser. I've been looking at Freshports to ascertain how many run dependencies certain ports have. I want to install ports that have a minimal run dependency because I don't want too many ports installed. Freshports, however, doesn't provide build dependency information. Does`portmaster -l` do this?



			
				wblock@ said:
			
		

> That's... well, not terrible.  Not sure what  situation the author was anticipating.  (This time, at least, it was not  something I wrote...)



Maybe it should be removed from the Handbook if it is not advisable to perform that command? Or, at least, a warning of its potential for disaster should be given.

Out of interest, for those of you who have installed xfce4 from ports (specifically, `portmaster`), how long do you recall it took? Over 4 hours seems excessive, and it shows no signs of finishing up anytime soon


----------



## wblock@ (Nov 7, 2013)

markbsd said:
			
		

> I'll take your advice, see how it goes. I just don't want to end up with 100+ ports installed.



Huh?  With X and any window manager, you'll have a lot more than 100 ports installed.  There are lots of dependencies.  That's just the way modern software works.



> Xfce4, for example, only has 13 run dependencies, but it's now been installing from ports for OVER 4 HOURS! That's insane! I don't remember it taking this long when I installed it last week using `cd /usr/ports/x11-wm/xfce4 && make install clean`. Does using `portmaster /x11-wm/xfce4` (as opposed to `make install`) install more dependencies or something? Because it's taking so much longer to install this time than the last.



You were installing packages last time, right?  Or had some installed already.  Either way, a fresh build from ports takes a while, because it has to compile all the needed dependencies.  The first build always takes longer because of that.



> I don't know how you get it done in 15 minutes. My last `portmaster -af` literally took several days!



Yes.  -a means "rebuild everything that needs an upgrade".  But -af means "force-rebuild everything, whether it needs it or not."



> And, I ran `portmaster` x11-wm/xfce4 a little over 4 hours ago -- it's still running!



Are you installing xfce from scratch?  Because portmaster is an upgrade tool, and if you use it on a port that is already installed, it may just rebuild all the dependencies of that port.





> (`portmaster -af`)  Maybe it should be removed from the Handbook if it is not advisable to perform that command? Or, at least, a warning of its potential for disaster should be given.



No, in context it is okay: "If errors are encountered".  Problems arise when it is used routinely.



> Out of interest, for those of you who have installed xfce4 from ports (specifically, `portmaster`), how long do you recall it took? Over 4 hours seems excessive, and it shows no signs of finishing up anytime soon



It depends on a lot of things, the speed of the computer and internet connection, the number of dependencies that are already installed, options set in /etc/make.conf, and others.  Four hours or more on a slow machine, as it builds missing dependencies (including build dependencies, probably including gcc) is believable.


----------



## markbsd (Nov 8, 2013)

wblock@ said:
			
		

> Huh?  With X and any window manager, you'll have a lot more than 100 ports installed.  There are lots of dependencies.  That's just the way modern software works.



Wow. This both sucks and is surprising.




> You were installing packages last time, right?  Or had some installed already.  Either way, a fresh build from ports takes a while, because it has to compile all the needed dependencies.  The first build always takes longer because of that.


I used `pkg_add` last install. This is a fresh install where I've decided to use ports exclusively. I may have to rethink this decision.




> Yes.  -a means "rebuild everything that needs an upgrade".  But -af means "force-rebuild everything, whether it needs it or not."


Oh! That's not what I wanted.




> Are you installing xfce from scratch?  Because portmaster is an upgrade tool, and if you use it on a port that is already installed, it may just rebuild all the dependencies of that port.


Yes, from scratch. All that has been done on this system is:

1. Install FreeBSD (30 minutes)
2. Upgrade to pkgng (1 minute)
3. Install portmaster (2 minutes)
4. `portmaster x11/xorg` (overnight)
5. `portmaster x11-wm/xfce4` (20 hours and counting)




> No, in context it is okay: "If errors are encountered".  Problems arise when it is used routinely.
> 
> It depends on a lot of things, the speed of the computer and internet connection, the number of dependencies that are already installed, options set in /etc/make.conf, and others.  Four hours or more on a slow machine, as it builds missing dependencies (including build dependencies, probably including gcc) is believable.


How does 20+ hours sound? Like something is wrong, yes?


----------



## Deleted member 9563 (Nov 8, 2013)

markbsd said:
			
		

> How does 20+ hours sound? Like something is wrong, yes?



Just for perspective's sake; I did `# portmaster -a` on a machine that appeared to have 26 ports that needed to be updated - it took about 24 hours. A previous update with just a few ports took just a few minutes. I could see that several of the huge ports got involved. I don't know why, but it seems that widely varying update times are a reality. This, by the way, was on a reasonable machine: G6950 Clarkdale 2.8GHz with 8GB ram.


----------



## wblock@ (Nov 8, 2013)

It depends on what changed.  Sometimes a low-level port changes, and then all the higher ports that depend on it have to be rebuilt.


----------



## markbsd (Nov 9, 2013)

OJ said:
			
		

> Just for perspective's sake; I did `# portmaster -a` on a machine that appeared to have 26 ports that needed to be updated - it took about 24 hours. A previous update with just a few ports took just a few minutes. I could see that several of the huge ports got involved. I don't know why, but it seems that widely varying update times are a reality. This, by the way, was on a reasonable machine: G6950 Clarkdale 2.8GHz with 8GB ram.



Nevertheless, I think 20+ hours to install ~100 ports is deterrence enough to stay as far away from ports as I possibly can on this system!

What I'm now wondering, is if there are any possible complications from using pkgng the majority of the time, and using ports for very small installs. I've read that one should stick to one or the other, but, again, the consensus is divided with conflicting information.


----------



## Deleted member 9563 (Nov 9, 2013)

markbsd said:
			
		

> Nevertheless, I think 20+ hours to install ~100 ports is deterrence enough to stay as far away from ports as I possibly can on this system!
> 
> What I'm now wondering, is if there are any possible complications from using pkgng the majority of the time, and using ports for very small installs. I've read that one should stick to one or the other, but, again, the consensus is divided with conflicting information.



I think it's a matter of how well you can deal with the dependencies. Packages will lag behind a bit, so a mixture of pkg and ports could potentially cause some problem there. I'm no expert though - just an amateur with champagne tastes. 

At this point in my FreeBSD usage I've got two machines which are both running 9.2 RELEASE and mostly the same software. I'm having much better "luck" than I did two years ago. I think there are several reasons for this. One, some bugs have gotten fixed. Two, I've gotten better at this. And three, I've become more relaxed in my attitude to the occasional situation when I encounter a marathon ports build.


----------



## markbsd (Nov 9, 2013)

Granted, I'm a newb and have very limited experience, but I really can't fathom a scenario where one would benefit even minutely, let alone significantly, from ports over packages. Especially when you factor in the build time. Do you gain better security? Faster run-times? Less crashes? What, exactly, makes ports more beneficial? Nothing, I think. Perhaps, it sounds cool, or makes you seem more technical? I don't know.


----------



## Deleted member 9563 (Nov 9, 2013)

I've come to the same conclusion. I don't think there's much advantage to ports unless perhaps if you're running a public facing server and need the security updates.

My systems are now a mixture. Funny though, I started both these systems with packages only, but then found the ports sneaking in just because not all programs are available as packages, and because of my fumbling in updating. Even with the very large and complicated KDE which I'm now running, it doesn't seem to matter.


----------

