Ignore:
Timestamp:
Jun 12, 2009, 8:09:31 AM (8 years ago)
Author:
blb@…
Message:

Move install_register_imagefile to macports.tcl so it can be called outside of port1.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/images-and-archives/base/src/macports1.0/macports.tcl

    r52203 r52215  
    805805    $workername alias registry_installed registry::installed
    806806    $workername alias registry_active registry::active
     807
     808    # Image file processing
     809    $workername alias install_register_imagefile macports::install_register_imagefile
    807810
    808811    # deferred options processing.
     
    26582661    return
    26592662}
     2663
     2664# Procedure to install an image file; protocols currently supported
     2665# are file:, https?:, and ftp:.
     2666proc macports::install_image {imageurl} {
     2667    # Implement
     2668}
     2669
     2670# Procedure to install and register an imagefile; the file itself must
     2671# be local (see macports::install_image to install from varying URLs).
     2672# Install means to simply copy to the right path as the file is not expected
     2673# to be there as yet.  Registering it of course means simply adding to
     2674# the registry as installed, but not active.
     2675proc macports::install_register_imagefile {imagefile} {
     2676    global env macports::portimagefilepath macports::prefix
     2677    if {[info exists env(TMPDIR)]} {
     2678        set mytempdir [mkdtemp [file join $env(TMPDIR) mpimageXXXXXXXX]]
     2679    } else {
     2680        set mytempdir [mkdtemp [file join /tmp mpimageXXXXXXXX]]
     2681    }
     2682    set startpwd [pwd]
     2683    try {
     2684        if {[catch {cd $mytempdir} err]} {
     2685            throw MACPORTS $err
     2686        }
     2687        if {[catch {set tarcmd [findBinary tar ${macports::autoconf::tar_path}]} err]} {
     2688            throw MACPORTS $err
     2689        }
     2690        if {[catch {system "$tarcmd -xvf $imagefile +IMAGERECEIPT"} err]} {
     2691            throw MACPORTS $err
     2692        }
     2693        if {[catch {set fd [open "+IMAGERECEIPT" r]} err]} {
     2694            throw MACPORTS "Can't open image receipt: $err"
     2695        }
     2696        array set imagevars [list]
     2697        while {[gets $fd line] >= 0} {
     2698            set imagevars([lindex $line 0]) [lrange $line 1 end]
     2699        }
     2700        close $fd
     2701        set requiredvars {name version revision portvariants epoch categories contents prefix}
     2702        foreach required $requiredvars {
     2703            if {![info exists imagevars($required)]} {
     2704                throw MACPORTS "Image receipt missing required variable $required"
     2705            }
     2706        }
     2707
     2708        if {$imagevars(prefix) != $prefix} {
     2709            throw MACPORTS "Image prefix ($imagevars(prefix)) does not match ours ($prefix)"
     2710        }
     2711        set portimagepath [file join ${portimagefilepath} $imagevars(name)]
     2712        if {![file isdirectory $portimagepath]} {
     2713            file mkdir $portimagepath
     2714        }
     2715        ui_debug "Installing and registering [file tail $imagefile]"
     2716        file copy -force $imagefile $portimagepath
     2717
     2718        set regref [registry::new_entry $imagevars(name) $imagevars(version) $imagevars(revision) $imagevars(portvariants) $imagevars(epoch)]
     2719        registry::property_store $regref categories $imagevars(categories)
     2720        registry::property_store $regref contents $imagevars(contents)
     2721        foreach propname [array names imagevars] {
     2722            if {[lsearch -exact $requiredvars $propname] >= 0} {
     2723                continue
     2724            }
     2725            registry::property_store $regref $propname $imagevars($propname)
     2726            if {[lsearch -exact {depends_run depends_lib} $propname] != -1} {
     2727               registry::register_dependencies $imagevars($propname) $imagevars(name)
     2728            }
     2729        }
     2730        registry::write_entry $regref
     2731    } catch {* errorCode errorMessage } {
     2732        ui_error $errorMessage
     2733    } finally {
     2734        cd $startpwd
     2735        file delete -force $mytempdir
     2736    }
     2737
     2738    return 0
     2739}
     2740
Note: See TracChangeset for help on using the changeset viewer.