Automating your MacPorts upgrades
Porticus is a very nice tool for maintaining your MacPorts. I find it easier than the command line port utility. But mostly, I use it for routinely updating (uh, sorry — “upgrading”) my ports. What if that could be automated?
Here's how.
Create /etc/daily.local with this content
#!/bin/sh
#
# /etc/daily.local
#
# I got this from http://hacks.oreilly.com/pub/h/336
# General parameters
PATH=/bin:/usr/bin:/sbin:/usr/sbin
. /etc/hostconfig
# Update MacPorts, if present
if [ -f /opt/local/bin/port ]; then
/opt/local/bin/port selfupdate >> macports.log 2>&1 && /opt/local/bin/port upgrade installed >> macports.log 2>&1
fi
This adds the MacPorts update to your daily maintenance regimen. Typically, the Mac's periodic scripts are run at around 3:00 AM and they take care of all kids of things like updating your locate database. The /etc/daily.local file is executed if present.
Naturally, if you would rather do your MacPorts update weekly or monthly, then use /etc/weekly.local or /etc/monthly.local instead.
Create /etc/newsyslog.d/macports.conf with this content
# logfilename [owner:group] mode count size when flags [/pid_file] [sig_num]
/var/log/macports.log 640 7 * @T00 J
This additional config file for newsyslog says to rotate the macports.log file created by our daily.local. For more info, use man newsyslog
And so on…
Obviously, you can use this trick for other things you'd like to run periodically. For example, you can update Fink be putting this into your daily.local:
# Update Fink, if present
if [ -f /sw/bin/fink ]; then
/sw/bin/fink selfupdate >> fink.log 2>&1 && /sw/bin/fink update-all && /sw/bin/fink cleanup >> fink.log 2>&1
fi
Labels: macos
Comments: