Changes between Initial Version and Version 1 of howto/Upgrade


Ignore:
Timestamp:
Jul 13, 2008, 9:12:40 PM (16 years ago)
Author:
blb@…
Comment:

Add new howto: Locally upgrading a port to a new version

Legend:

Unmodified
Added
Removed
Modified
  • howto/Upgrade

    v1 v1  
     1[wiki:howto <- Back to the HOWTO section]
     2
     3= How to upgrade a port's version locally =
     4
     5 * Audience: Those who don't want to wait for a port to be updated
     6 * Requires: MacPorts >=1.6
     7
     8== Introduction ==
     9
     10Sometimes ports will fall behind the currently-available version.  When other ports are updated this can cause issues when the newer version of a port is needed for compatibility.  The Portfile for a port can be updated locally to allow you to upgrade it now, without waiting for an official update from the maintainer.
     11
     12Anytime you see <portname> in this document, replace with the actual name of the port in which you are interested, it is only a placeholder here.
     13
     14== Updating the port ==
     15
     16=== Step 1: '''Getting into the port directory and keeping a copy of the original''' ===
     17
     18First, cd into the port's directory (which contains the Portfile) by running:
     19{{{
     20cd `port dir <portname>`
     21}}}
     22(note the backward ticks).  Then save a copy of the Portfile:
     23{{{
     24sudo cp Portfile Portfile.orig
     25}}}
     26
     27=== Step 2: '''Editing the Portfile''' ===
     28
     29Use:
     30{{{
     31sudo port edit <portname>
     32}}}
     33to edit the Portfile for the given port (this will open it in whatever editor you have defined via the VISUAL or EDITOR environment variables, or vi if not defined).  Since you're already in the directory containing the Portfile, you can also open it directly from here, but {{{port edit}}} always works.
     34
     35(Note: there are apparently two MacPorts options, ports_edit_editor and ports_ed_editor, which can be used but there appears to be no documentation about them).
     36
     37=== Step 3: '''Updating the version''' ===
     38
     39Once the Portfile has been opened, find the line which starts with {{{version}}}:
     40{{{
     41version              1.4.1
     42}}}
     43Update the version given on that line (1.4.1 in this example) to the newly-desired version, then save the Portfile.  For example, if the new version is 1.5, it should simply look like:
     44{{{
     45version              1.5
     46}}}
     47Also, search for a revision line like:
     48{{{
     49revision             2
     50}}}
     51and if found, delete it.  Updated versions should start with revision 0 (which is the default when revision isn't present).
     52
     53=== Step 4: '''Fetching and updating the checksums''' ===
     54
     55Now fetch and run the checksum phase (which will fail, since it hasn't been updated for the new version) by running:
     56{{{
     57sudo port -d checksum <portname>
     58}}}
     59This will fetch the new version you've specified then run a checksum against the downloaded file.  This will fail and since the debug (-d) flag was used, specify the checksums from the new file (among other lines):
     60{{{
     61...
     62checksums      md5     2e39a43b93b50c2ca90bcade26010878 \
     63               sha1    2766d858b15d5d76da61e096fa6ffeb55b0469fb \
     64               rmd160  29488b09cc6d8013716c8a7d190fe6bc9625e568
     65...
     66}}}
     67Copy this section (all three lines), use {{{sudo port edit <portname>}}} again, and change the checksum lines to be what you just copied.
     68
     69=== Step 5: '''Installing the new version''' ===
     70
     71Now that the correct checksum has been specified, you can install the new version with:
     72{{{
     73sudo port -d install <portname>
     74}}}
     75Use the debug flag again so that, in case something bad happens, the error message will be seen.  If it doesn't succeed, that goes beyond the scope of this document.
     76
     77Otherwise, the port will be installed with the latest version specified.
     78
     79=== Step 6: '''Filing an update ticket''' ===
     80
     81Since it succeeded, [http://trac.macports.org/newticket file a ticket] to upgrade the port to the new version.  The best way to do this is to attach a diff against the Portfile to the new ticket, so generate a diff by running:
     82{{{
     83diff -u Portfile.orig Portfile | sudo tee <portname>.diff
     84}}}
     85Then specify the <portname>.diff as a file to be attached to the new ticket.
     86
     87=== Step 7: '''Cleaning up''' ===
     88
     89Do a little clean up so extra files aren't left around:
     90{{{
     91sudo rm <portname>.diff
     92sudo mv Portfile.orig Portfile
     93}}}
     94
     95== TODO ==
     96
     97One thing to add is about patches, some may no longer be needed (they're irrelevant with the new version, they've been integrated upstream, etc), so should be removed.  Others may need updates which gets more complicated.
     98
     99[wiki:howto <- Back to the HOWTO section]