[138807] branches/gsoc15-dependency/base/src/macports1.0

ijackson at macports.org ijackson at macports.org
Mon Jul 20 11:25:45 PDT 2015


Revision: 138807
          https://trac.macports.org/changeset/138807
Author:   ijackson at macports.org
Date:     2015-07-20 11:25:44 -0700 (Mon, 20 Jul 2015)
Log Message:
-----------
Add installed port information to the $pool repo
$repo_installed by reading registry::installed.

Modified Paths:
--------------
    branches/gsoc15-dependency/base/src/macports1.0/macports.tcl
    branches/gsoc15-dependency/base/src/macports1.0/macports_libsolv.tcl

Modified: branches/gsoc15-dependency/base/src/macports1.0/macports.tcl
===================================================================
--- branches/gsoc15-dependency/base/src/macports1.0/macports.tcl	2015-07-20 11:43:41 UTC (rev 138806)
+++ branches/gsoc15-dependency/base/src/macports1.0/macports.tcl	2015-07-20 18:25:44 UTC (rev 138807)
@@ -2753,6 +2753,7 @@
             # macports::libsolv::print
             set search_res [macports::libsolv::search $pattern \
             $case_sensitive $matchstyle $field]
+            # macports::libsolv::create_installed_pool
             return $search_res
         }
     } else {

Modified: branches/gsoc15-dependency/base/src/macports1.0/macports_libsolv.tcl
===================================================================
--- branches/gsoc15-dependency/base/src/macports1.0/macports_libsolv.tcl	2015-07-20 11:43:41 UTC (rev 138806)
+++ branches/gsoc15-dependency/base/src/macports1.0/macports_libsolv.tcl	2015-07-20 18:25:44 UTC (rev 138807)
@@ -43,6 +43,9 @@
     ## Variable for portindexinfo
     variable portindexinfo
 
+    ## Variable to track registry changes.
+    variable regupdate
+
     ## Some debugging related printing of variable contents
     proc print {} {
         set pool [create_pool]
@@ -83,7 +86,22 @@
 
             ## Create a new pool instance by calling Pool contructor.
             set pool [solv::Pool]
+            ## Repo for installed ports
+            set repo_installed [$pool add_repo "installed"]
 
+            ## Create a list of installed ports by reading registry::installed.
+            array set installed_ports [list]
+            try {
+                foreach installed [registry::installed] {
+                    lassign $installed name version revision variants active epoch
+                    if {$active != 0} {
+                        set installed_ports($name,$epoch,$version,$revision) $installed
+                    }
+                }
+            } catch * {
+                ui_warn "No installed ports found in registry"
+            }
+            
             foreach source $sources {
                 set source [lindex $source 0]
                 ## Add a repo in the pool for each source as mentioned in sources.conf
@@ -95,9 +113,6 @@
                 } else {
                     try {
                         while {[gets $fd line] >= 0} {
-                            # Create a solvable for each port processed.
-                            set solvable [$repo add_solvable]
-
                             ## Clear the portinfo contents to prevent attribute leak \
                             #  from previous iterations
                             array unset portinfo
@@ -107,6 +122,15 @@
                             
                             array set portinfo $line
 
+                            # Create a solvable for each port processed.
+                            # If the port is already installed add it to $repo_installed. Also add it to $repo
+                            if {[info exists installed_ports($name,$portinfo(epoch),$portinfo(version),$portinfo(revision))]} {
+                                    set solvable [$repo_installed add_solvable]
+                            } else {
+                                set solvable [$repo add_solvable]
+                            }
+                            # set solvable [$repo add_solvable]
+
                             $solvable configure -name $name \
                             -evr "$portinfo(epoch)@$portinfo(version)-$portinfo(revision)" \
                             -arch "i386"
@@ -158,6 +182,7 @@
                         #  is available for lookup and dataiterator functions. Do this after\
                         #  all the solvables are added to repo as it is a costly operation.
                         $repodata internalize
+                        $pool configure -installed $repo_installed
                         close $fd
                     }
                 }
@@ -165,8 +190,9 @@
             ## createwhatprovides creates hash over all the provides of the package \
             #  This method is necessary before we can run any lookups on provides.
             $pool createwhatprovides
+    
+            return $pool
         }
-        return $pool
     }
 
     ## Search using libsolv. Needs some more work.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20150720/bec51a05/attachment-0001.html>


More information about the macports-changes mailing list