Nick Rutherford

A bash script to update macports system & installed ports, and the same for ruby gems.

To update all your macports and ruby gems try this brief script

#!/usr/bin/env bash
if [ $(whoami) = "root"]
then
  #macports updates
#update the macports app and its list of available ports / port tree
port -v selfupdate 

# ref for not using port upgrade -u outdated : http://lists.macosforge.org/pipermail/macports-users/2007-October/005849.html

#download, build, activate, and deactivate previous versions of any installed ports with available updates
port upgrade outdated 

#uninstall any old ports no longer in use (disable this if you want to do version switching)
port -f uninstall inactive

#rubygems updates
gem update --system #update the gems application
gem update #update installed gems
else
    sudo $0
fi

Installation

I have this setup:

My scripts go into a local directory, e.g. ~/scripts/port_and_gem_update.sh I link into /usr/bin using ln, e.g.

ln ~/scripts/port_and_gem_update.sh /usr/bin/portupdt

which provides you with a terminal command you can use from wherever you like, called portupdt. I also do this with my mateup script.

1 Response to “Another trivial update bash script”

  1. Nick Rutherford

    Nick Rutherford Says:

    It's worth pointing out also that there is an error reported when you do port upgrade outdated and there are no outdated ports. This is normal, as the error message itself indicates in the third or fourth line. It's reporting that it has been told to update nothing, which is ok if there is nothing to update!

Sorry, comments are closed for this article.