[52215] branches/images-and-archives/base/src

blb at macports.org blb at macports.org
Fri Jun 12 01:09:32 PDT 2009


Revision: 52215
          http://trac.macports.org/changeset/52215
Author:   blb at macports.org
Date:     2009-06-12 01:09:31 -0700 (Fri, 12 Jun 2009)
Log Message:
-----------
Move install_register_imagefile to macports.tcl so it can be called outside of port1.0

Modified Paths:
--------------
    branches/images-and-archives/base/src/macports1.0/macports.tcl
    branches/images-and-archives/base/src/port1.0/portimagefile.tcl

Modified: branches/images-and-archives/base/src/macports1.0/macports.tcl
===================================================================
--- branches/images-and-archives/base/src/macports1.0/macports.tcl	2009-06-12 08:07:17 UTC (rev 52214)
+++ branches/images-and-archives/base/src/macports1.0/macports.tcl	2009-06-12 08:09:31 UTC (rev 52215)
@@ -805,6 +805,9 @@
     $workername alias registry_installed registry::installed
     $workername alias registry_active registry::active
 
+    # Image file processing
+    $workername alias install_register_imagefile macports::install_register_imagefile
+
     # deferred options processing.
     $workername alias getoption macports::getoption
 
@@ -2657,3 +2660,81 @@
     }
     return
 }
+
+# Procedure to install an image file; protocols currently supported
+# are file:, https?:, and ftp:.
+proc macports::install_image {imageurl} {
+    # Implement
+}
+
+# Procedure to install and register an imagefile; the file itself must
+# be local (see macports::install_image to install from varying URLs).
+# Install means to simply copy to the right path as the file is not expected
+# to be there as yet.  Registering it of course means simply adding to
+# the registry as installed, but not active.
+proc macports::install_register_imagefile {imagefile} {
+    global env macports::portimagefilepath macports::prefix
+    if {[info exists env(TMPDIR)]} {
+        set mytempdir [mkdtemp [file join $env(TMPDIR) mpimageXXXXXXXX]]
+    } else {
+        set mytempdir [mkdtemp [file join /tmp mpimageXXXXXXXX]]
+    }
+    set startpwd [pwd]
+    try {
+        if {[catch {cd $mytempdir} err]} {
+            throw MACPORTS $err
+        }
+        if {[catch {set tarcmd [findBinary tar ${macports::autoconf::tar_path}]} err]} {
+            throw MACPORTS $err
+        }
+        if {[catch {system "$tarcmd -xvf $imagefile +IMAGERECEIPT"} err]} {
+            throw MACPORTS $err
+        }
+        if {[catch {set fd [open "+IMAGERECEIPT" r]} err]} {
+            throw MACPORTS "Can't open image receipt: $err"
+        }
+        array set imagevars [list]
+        while {[gets $fd line] >= 0} {
+            set imagevars([lindex $line 0]) [lrange $line 1 end]
+        }
+        close $fd
+        set requiredvars {name version revision portvariants epoch categories contents prefix}
+        foreach required $requiredvars {
+            if {![info exists imagevars($required)]} {
+                throw MACPORTS "Image receipt missing required variable $required"
+            }
+        }
+
+        if {$imagevars(prefix) != $prefix} {
+            throw MACPORTS "Image prefix ($imagevars(prefix)) does not match ours ($prefix)"
+        }
+        set portimagepath [file join ${portimagefilepath} $imagevars(name)]
+        if {![file isdirectory $portimagepath]} {
+            file mkdir $portimagepath
+        }
+        ui_debug "Installing and registering [file tail $imagefile]"
+        file copy -force $imagefile $portimagepath
+
+        set regref [registry::new_entry $imagevars(name) $imagevars(version) $imagevars(revision) $imagevars(portvariants) $imagevars(epoch)]
+        registry::property_store $regref categories $imagevars(categories)
+        registry::property_store $regref contents $imagevars(contents)
+        foreach propname [array names imagevars] {
+            if {[lsearch -exact $requiredvars $propname] >= 0} {
+                continue
+            }
+            registry::property_store $regref $propname $imagevars($propname)
+            if {[lsearch -exact {depends_run depends_lib} $propname] != -1} {
+               registry::register_dependencies $imagevars($propname) $imagevars(name)
+            }
+        }
+        registry::write_entry $regref
+    } catch {* errorCode errorMessage } {
+        ui_error $errorMessage
+    } finally {
+        cd $startpwd
+        file delete -force $mytempdir
+    }
+
+    return 0
+}
+

Modified: branches/images-and-archives/base/src/port1.0/portimagefile.tcl
===================================================================
--- branches/images-and-archives/base/src/port1.0/portimagefile.tcl	2009-06-12 08:07:17 UTC (rev 52214)
+++ branches/images-and-archives/base/src/port1.0/portimagefile.tcl	2009-06-12 08:09:31 UTC (rev 52215)
@@ -133,73 +133,3 @@
     return $filelist
 }
 
-
-# Install (copy to portimagefilepath) an imagefile and register
-# it as installed in the MacPorts registry.  This makes no assumptions
-# about how the imagefile was created/acquired
-proc portimagefile::install_register_imagefile {imagefile} {
-    global env portimagefilepath prefix
-    if {[info exists env(TMPDIR)]} {
-        set mytempdir [mkdtemp [file join $env(TMPDIR) mpimageXXXXXXXX]]
-    } else {
-        set mytempdir [mkdtemp [file join /tmp mpimageXXXXXXXX]]
-    }
-    set startpwd [pwd]
-    try {
-        if {[catch {_cd $mytempdir} err]} {
-            throw MACPORTS $err
-        }
-        if {[catch {set tarcmd [findBinary tar ${portutil::autoconf::tar_path}]} err]} {
-            throw MACPORTS $err
-        }
-        if {[catch {system "$tarcmd -xvf $imagefile +IMAGERECEIPT"} err]} {
-            throw MACPORTS $err
-        }
-        if {[catch {set fd [open "+IMAGERECEIPT" r]} err]} {
-            throw MACPORTS "Can't open image receipt: $err"
-        }
-        array set imagevars [list]
-        while {[gets $fd line] >= 0} {
-            set imagevars([lindex $line 0]) [lrange $line 1 end]
-        }
-        close $fd
-        set requiredvars {name version revision portvariants epoch categories contents prefix}
-        foreach required $requiredvars {
-            if {![info exists imagevars($required)]} {
-                throw MACPORTS "Image receipt missing required variable $required"
-            }
-        }
-
-        if {$imagevars(prefix) != $prefix} {
-            throw MACPORTS "Image prefix ($imagevars(prefix)) does not match ours ($prefix)"
-        }
-        set portimagepath [file join ${portimagefilepath} $imagevars(name)]
-        if {![file isdirectory $portimagepath]} {
-            file mkdir $portimagepath
-        }
-        ui_debug "Installing and registering [file tail $imagefile]"
-        file copy -force $imagefile $portimagepath
-
-        set regref [registry_new $imagevars(name) $imagevars(version) $imagevars(revision) $imagevars(portvariants) $imagevars(epoch)]
-        registry_prop_store $regref categories $imagevars(categories)
-        registry_prop_store $regref contents $imagevars(contents)
-        foreach propname [array names imagevars] {
-            if {[lsearch -exact $requiredvars $propname] >= 0} {
-                continue
-            }
-            registry_prop_store $regref $propname $imagevars($propname)
-            if {[lsearch -exact {depends_run depends_lib} $propname] != -1} {
-               registry_register_deps $imagevars($propname) $imagevars(name)
-            }
-        }
-        registry_write $regref
-    } catch {* errorCode errorMessage } {
-        ui_error $errorMessage
-    } finally {
-        _cd $startpwd
-        file delete -force $mytempdir
-    }
-
-    return 0
-}
-
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20090612/1a14d806/attachment.html>


More information about the macports-changes mailing list