Ticket #2365: portactivate.tcl.diff

File portactivate.tcl.diff, 1.9 KB (added by jberry@…, 20 years ago)

Patch to base/src/port1.0/portactivate.tcl

  • portactivate.tcl

    RCS file: /Volumes/src/cvs/od/proj/darwinports/base/src/port1.0/portactivate.tcl,v
    retrieving revision 1.3
    diff -u -u -r1.3 portactivate.tcl
     
    4141target_requires ${com.apple.activate} main fetch extract checksum patch configure build destroot install
    4242target_prerun ${com.apple.activate} activate_start
    4343
     44# define options
     45options activate.copy_defaults
     46default activate.copy_defaults ""
     47
    4448set_ui_prefix
    4549
     50proc copy_default_file { src dst } {
     51        # Only copy file if it doesn't already exist
     52        if { [file exists $dst] } {
     53                ui_debug [format "Default file %s already exists" $dst]
     54        } else {
     55                # Make sure the src file is readable
     56                if { ![file readable $src] } {
     57                        return -code error [msgcat::mc [format "Default file %s does not exist or is not readable" $src]]
     58                }
     59               
     60                ui_debug [format "Installing default file %s" $dst]
     61                file copy $src $dst
     62        }
     63}
     64
     65proc copy_default_files {files} {
     66        # args is a list of pairs of file paths. Number of args must be even
     67        if { [llength $files] % 2 != 0 } {
     68            return -code error [msgcat::mc "activate.copy_defaults must have an even number of parameters"]
     69        }
     70       
     71        # copy each src/dst pair of files. src is copied to dst iff dst doesn't exist.
     72        foreach { src dst } $files {
     73                copy_default_file $src $dst
     74        }
     75}
     76
    4677proc activate_start {args} {
    4778        global UI_PREFIX portname portversion portrevision variations portvariants
    4879   
     
    6293
    6394proc activate_main {args} {
    6495        global portname portversion portrevision portvariants
     96       
     97        # activate the port
    6598        registry_activate $portname ${portversion}_${portrevision}${portvariants}
     99       
     100        # copy any default files that don't yet exist
     101        copy_default_files [option activate.copy_defaults]
     102       
    66103    return 0
    67104}