# portupgrade options



## kr651129 (Jun 17, 2012)

So I was wondering if there is a way to use `# portupgrade` and when it prompts me with the configure menu to just accept the defaults and move on, the help shows --yes to answer yes to all questions but I'm not sure if that's what I'm needing?

Thank you


----------



## francis (Jun 17, 2012)

Hi @kr651129. There is an interesting option, called; BATCH. You can use it with the portupgrade tool or add this option to the /etc/make.conf file. Personally, I think, that this is not a good solution to build ports with default settings. In my opinion it is better to know what is set and/or decide which options should/could be used.


```
BATCH="yes"   [I][color="Gray"]adding this option to the [file]/etc/make.conf[/file] file.[/color][/I]
```
`# portupgrade -a --batch  [i][color="Gray"]Run an upgrading process in a batch mode (with [file]BATCH=yes[/file]).`[/color][/i]
`# portupgrade -y   [i][color="Gray"]Answer yes to all the questions. [/color][/i]`
`# portupgrade -m BATCH=yes   [i][color="Gray"]Also should work?[/color][/i]`

Now portupgrade should install ports with the default configs. Basically you can also export the BATCH options, depending on the shell, which you are using (Before update with portupgrade, set the environment variable*!*);

`# env BATCH=yes [i][color="Gray"]or:[/color][/i]`
`# export BATCH=yes`

And then execute these mentioned command e.g. portupgrade with *-a* and *--batch* options. But remember, I think, that it is better to decide, which options should be used to build port.

Best regards!


----------



## wblock@ (Jun 17, 2012)

Or use -c or -C options, which show all the option dialogs before starting to build.

Or use ports-mgmt/portmaster, which is what I would recommend.


----------



## kr651129 (Jun 17, 2012)

francis -- thank you!  Let me give you some background on my funny situation as to why I'm doing this and maybe you can tell me if there is a better approach.

I keep running into this problem with graphics/png where I need to upgrade it and remove the old version.  So I do this and then x11/gnome2 stops working because it can't find libpng.so.6 (along with all sorts of other ports that require libpng.so.6 so I did a little bit of googling and came accross this thread which suggested I try and do a portupgrade graphics/png and graphics/jpeg

After I did all this most of my ports worked except for www/chromium and x11/gnome2 I was trying to figure out why this was but out of nowhere I started to get kernel panic's on boot right after wlan0 would get turned on and set.  Sometimes I could login but I couldn't do much until the first panic.  I thought it might be a bad hard drive?  So I did an HDD test and it was fine.

Now I'm at the point where I installed a minimal system (x11/xorg, x11/gnome2, and www/opera) and decided that before I move forward I would upgrade graphics/png on a mostly fresh system and see what the results were?

What do you think?


----------



## wblock@ (Jun 17, 2012)

The problem is not because of port upgrade tool, it's a problem in procedure.  /usr/ports/UPDATING has instructions on upgrades that need manual steps.  Always (yes, always) check that file before upgrading ports.  It tells how to upgrade PNG without breaking other ports.


----------



## kr651129 (Jun 17, 2012)

wblock@ said:
			
		

> The problem is not because of port upgrade tool, it's a problem in procedure.  /usr/ports/UPDATING has instructions on upgrades that need manual steps.  Always (yes, always) check that file before upgrading ports.  It tells how to upgrade PNG without breaking other ports.



Since that was in the other thread I did check /usr/ports/UPDATING and upgraded the way it suggested which is why I'm left scratching my head on this one.  Hopefully on a fresh install with minimal ports I can move forward?


----------



## wblock@ (Jun 17, 2012)

When you rebuild whatever part of Gnome is trying to use the old PNG, it should be rebuilt to use the new one.  That could fail for a couple of reasons, like using packages or not having the latest ports tree.

Please show the exact commands you have used to update the ports tree and to update PNG.  It might also be helpful to see the Gnome error messages to know what port is having a problem (Gnome is a meta-port, made up of a bunch of smaller ports).


----------



## kpa (Jun 17, 2012)

I'd recommend switching to ports-mgmt/portmaster with a /usr/local/etc/portmaster.rc set with the following options:


```
BACKUP=bopt
ALWAYS_SCRUB_DISTFILES=dopt
PM_MAKE_ARGS='-DFORCE_PKG_REGISTER'
SAVE_SHARED=wopt
```

With those in place you will always have backups of the updated packages at /usr/ports/packages/portmaster-backup and backups of replaced shared libraries will be placed at /usr/local/lib/compat to avoid problems with ports that still depend on the earlier versions of the shared libraries.

I also recommend using DutchDaemon's portupdater script as the main update tool, the script is found here:

http://forums.freebsd.org/showpost.php?p=39092&postcount=37. Usage is simple:

`# portupdater y`

in interactive use and just (my crontab(5) entry, adjust to your needs)

```
35  3   *   *   *       /root/bin/portupdater
```

when run from cron(8).


----------



## icecoke (Jun 22, 2013)

*using defaults != using the options?*

Hi,

I have to touch this thread because I ask myself why it should be needed to _not_ use batch=yes or -y with portupgrade? Isn't it true that by using this option every option is answered the way it was on installing each port the first time? Except any new options if existent, or does it use the original defaults of the port? Can someone answer this?

Thanks a lot,
icecoke


----------



## wblock@ (Jun 22, 2013)

What is the attraction of using BATCH?  If the use is for an unattended automatic upgrade of ports, that works for a while.  But ports upgrades are not meant to be done that way.  If you skip reading and paying attention to the instructions in /usr/ports/UPDATING, there will be problems ranging from annoying to severe.

If you're concerned about the time spent waiting for the config screens, use -c or -C, where all the options screens are shown before building starts.  Or switch to ports-mgmt/portmaster as @kpa suggests, which does that by default.  (And also does not need Ruby or bdb.)


----------



## jozze (Jun 22, 2013)

All the functionality that ports-mgmt/portmaster offers is present in ports-mgmt/portupgrade, including backups, with addition that portupgrade preserves shared libraries, so you can run vim for example, while upgrading one of its dependencies.

@kr651129, I warmly recommend you to reread the portupgrade(1)() man page in great detail. Really. Read it again. And if you don't understand what you just read, read it yet again. While ports are fun and all, they're only fun as long as they're working. It is of utmost importance that you know the tools which you're going to use on a daily basis. To understand which options affect make and friends, read also ports(7)(), make.conf(5)() and make(1)(). Here you can only skim the relevant parts, IF you already read the Handbook.



			
				&quot said:
			
		

> ```
> [U]WARNING[/U]
> ...
> +o  Since portupgrade allows you to upgrade your installed packages with-
> ...


So, not always, but follow this advice from time to time, especially if you encounter a missing library like you have recently, even if UPDATING doesn't say anything. Almost all of your problems can be solved with this simple advice.

So to cope with a missing libpng.so.6, run `# portupgrade -Rrf png`. To identify missing libraries in the future, install (if you're NOT using PKGNG) sysutils/bsdadminscripts, and then run `# pkg_libchk -a`, or, if you're using PKGNG, enable SHLIB options and then search for them with `# pkg check -B`. Once you've found a port that is missing a library, rebuild it with -Rf flags of either portupgrade or portmaster.


----------



## wblock@ (Jun 22, 2013)

jozze said:
			
		

> All the functionality that ports-mgmt/portmaster offers is present in ports-mgmt/portupgrade, including backups, with addition that portupgrade preserves shared libraries, so you can run vim for example, while upgrading one of its dependencies.



ports-mgmt/portmaster does that with the -w option.  Really there is only one thing that portupgrade does that portmaster does not, and that's explicitly rebuilding all the ports upon which something depends.  On the other hand, I remember needing that only once in the last few years, and at that point I installed portupgrade, used it, then deinstalled it.


----------



## jozze (Jun 22, 2013)

Yeah, I read about the -w option, but as far as I understood, it's still different: portupgrade doesn't save the shared libraries, but it actually preserves them, despite deleting everything else. They are then removed, if the port builds, and is about to be reinstalled. The portmaster(8)() suggests that they are just saved, and then deleted when the rest of the port is deleted, but to be honest, I only use portmaster on one of my jails for testing ports/system and I'm not very familiar with it.

If I am wrong, please correct me, since so far, this has been one of my main reasons for keeping the bloated and sluggish (I read Ruby is slower than sh) portupgrade. On second thought, I don't want to hijack the thread, so if I want to ask more about portupgrade vs. portmaster, I'll start one myself.

As for explicitly rebuilding dependencies in portmaster, isn't that why the -R or -t flag is for?


----------



## kpa (Jun 22, 2013)

When used with the -w option portmaster saves the old libraries at /usr/local/lib/compat/pkg and does not delete them under any conditions. You have to clean up the old libraries yourself which is the most safe option.


----------

