Changes between Version 48 and Version 49 of PortfileRecipes


Ignore:
Timestamp:
Mar 6, 2013, 12:19:09 AM (11 years ago)
Author:
neverpanic (Clemens Lang)
Comment:

start documenting the deactivate hack

Legend:

Unmodified
Added
Removed
Modified
  • PortfileRecipes

    v48 v49  
    447447* 'Noncommercial' means a license that prohibits commercial use.
    448448* Public domain code, while technically not having or needing a license, should list the license as 'public-domain'.
     449
     450== Using the "deactivate hack" == #deactivatehack
     451Using the so-called deactivate hack becomes necessary when a file that used to be provided by port A is going to be provided by port B from now on and we need a seamless update path. Without the deactivate hack the activation phase of port B would fail because one of the files it tries to install is already there. The deactivate hack works around this problem, by deactivating A if it is active. It is often combined with a check for a specific version of A. An example might clear this up:
     452
     453Let's say the `kerberos5` port used to install the file `${prefix}/bin/compile_et`, but we're trying to move this part to a library called `libcomerr`. Since the `kerberos5` port will still need `compile_et` to build, it will add a dependency on `libcomerr`. This will cause MacPorts to install `libcomerr` before upgrading `kerberos5`. When MacPorts tries to activate `libcomerr`, the old version of `kerberos5` is still active and the conflicting file is still installed. Usually, MacPorts would bail out at this point and require the user to solve this problem manually. However, since this would affect all users that had `kerberos5` installed, this is undesirable.
     454
     455In this very case, we know `kerberos5` stopped providing `compile_et` in version 1.11. We will add the deactivate hack to `libcomerr`, where it will check whether any `kerberos5` <= 1.11 port is active, and if there is, it will deactivate it before activating `libcomerr`. After activating `libcomerr`, MacPorts will then happily continue with the upgrade and install the new (and non-conflicting) version of `kerberos5`. The following block is taken from the `libcomerr` Portfile:
     456
     457{{{#!tcl
     458# both kerberos5 and e2fsprogs previsouly conflicted because they installed files now provided by libcomerr
     459if {![catch {set installed [lindex [registry_active kerberos5] 0]}]} {
     460    set krb_version [lindex $installed 1]
     461    if {[vercmp $krb_version 1.11] < 0} {
     462        # kerberos5 used to install some files now provided by libcomerr in versions < 1.11
     463        registry_deactivate_composite kerberos5 "" [list ports_nodepcheck 1]
     464    }
     465}
     466}}}