Questions About Automated Upgrade with "portupgrade" and "make config-conditional"

I am trying to find a command that will do a semi-automated (batch) upgrade of installed Ports. What I would like the command to do is:
  1. Check configurations for all Ports to be upgraded. If not configured run make config for user input.
  2. Upgrade all configured Ports without any user input.
According to my interpretation of the documentation I think the command that I want to use is portupgrade -ac --batch. But, I'm not sure if the "-c" switch checks configurations and asks for user input on non-configured Ports before doing the upgrade, or if it asks the user to configure once it reaches an unconfigured Port during the actual upgrade.

Also, will "-c" cancel out "--batch" or vice-versa?

In the past I have run two commands which seemed to do the trick, but perhaps unnecessary:
Code:
# portupgrade -an
...
# portupgrade -a
Note: I intentionally omitted some of the otherwise recommended switches, such as "-b", for brevity.

Any input on whether I am doing this right or if there is a better way? Thank you.

And one more question about ports-mgmt/portupgrade: My interpretation of the "-r" and "-R" switches will force rebuilding of dependents and dependencies of the current Port respectively. Am I correct in this?
 
Hi,

I will not exactly respond to your question but DutchDaemon proposed a script (for portmaster(8) but easily adaptable for portupgrade(1) and the new pkg(8)* ).

However, in my humble opinion, ports-mgmt/poudriere would be more adapted for automated upgrades. First, it builds packages on jail and not directly on your system and therefore you cannot end up with an half upgraded system. Plus, this method is less prone to the "Damned, I forgot to read the UPDATING file.. again" syndrome (for which you can only blame yourself). Once again, it is just my opinion.

In short, here are the steps you could follow. First, set poudriere(8) with a jail and a port tree as explained in Building Packages with Poudriere.

Then, the following script should fullfil your requirements (assuming the ports you want to upgrade are the ones on your machine - change the variables according to your tree name and jail name) :
Code:
#! /bin/sh

# list all the packages installed (non automatically)
PKG_LIST=$(pkg query -e '%a = 0' %o)

JAIL_NAME=jail_name
TREE_NAME=tree_name

# number of jails used to build packages
BUILDER_NUMBER=1

echo "updating ports tree"
poudriere ports -u -p ${TREE_NAME} || exit 1

echo "setting new options for all installed packages"
poudriere options -j ${JAIL_NAME} -p ${TREE_NAME} ${PKG_LIST} || exit 1

echo "delete unused packages"
poudriere pkgclean -y -j ${JAIL_NAME} -J ${BUILDER_NUMBER} -p ${TREE_NAME} ${PKG_LIST} || exit 1

echo "build packages"
poudriere bulk -j ${JAIL_NAME} -J ${BUILDER_NUMBER} -p ${TREE_NAME} ${PKG_LIST} || exit 1

exit 0
Ok, it is a simplistic one and some more logic could be added (I am abroad and could not check for typo with my FreeBSD install, but this script should work as expected).

In order to check the UPDATING file, you can create an alias like :
Code:
alias pkg_updating="pkg updating -f /usr/local/poudriere/ports/tree_name/UPDATING"
Then you can proceed using pkg(8) with pkg upgrade. Of course, for pkg(8) to use your local repo, you have to create the following file /usr/local/etc/pkg/repos/MyFreeBSD.conf :
Code:
myrepo: {
  url  : "file:///usr/local/poudriere/data/packages/jail_name-tree_name",
  enabled  : yes,
  mirror_type  : "none"
}

FreeBSD: { enabled: no }
The good news is that you have choices.

-- Edited --
* The DutchDaemon script link was related to an old version of the script. Now, it links to the one using pkgng.
 
Back
Top