[42847] trunk/base/src/upgrade_sources_conf_default.tcl

blb at macports.org blb at macports.org
Mon Dec 1 00:34:14 PST 2008


Revision: 42847
          http://trac.macports.org/changeset/42847
Author:   blb at macports.org
Date:     2008-12-01 00:34:14 -0800 (Mon, 01 Dec 2008)
Log Message:
-----------
base/src/upgrade_sources_conf_default.tcl - copy some code from mportinit
to better parse the lines from sources.conf, which then allows the use
of lists to vastly improve detection of whether the default tag is present,
so we don't end up with '[nosync,default,default]'

Modified Paths:
--------------
    trunk/base/src/upgrade_sources_conf_default.tcl

Modified: trunk/base/src/upgrade_sources_conf_default.tcl
===================================================================
--- trunk/base/src/upgrade_sources_conf_default.tcl	2008-12-01 08:28:44 UTC (rev 42846)
+++ trunk/base/src/upgrade_sources_conf_default.tcl	2008-12-01 08:34:14 UTC (rev 42847)
@@ -23,15 +23,6 @@
 }
 
 
-proc append_default_tag_to_line {line} {
-   if {[regexp {^(.* )\[(.*)\](.*)$} $line -> line_begin current_tag line_end]} {
-      return "${line_begin}\[${current_tag},default\]${line_end}"
-   } else {
-      return "${line} \[default\]"
-   }
-}
-
-
 set mktempChannel [open "|/usr/bin/mktemp -t macports_sources_upgrade" r]
 set tempfile [read -nonewline $mktempChannel]
 close $mktempChannel
@@ -41,27 +32,33 @@
 set defaultWritten false
 
 while {[gets $sourcesConfChannel line] >= 0} {
+   set addDefault false
    if {!$defaultSeen && ![regexp {^\s*#|^$} $line]} {
-      if {[string first {[default]} $line] >= 0} {
-         set defaultSeen true
-      } elseif {[regexp {^\s*rsync://rsync\.(macports|darwinports)\.org/(release|dpupdate)/d?ports} $line]} {
-         set line [append_default_tag_to_line $line]
-         set defaultSeen true
-         set defaultWritten true
-      } elseif {[regexp {^\s*file://(/[^ #]+)} $line -> filepath]} {
-         if {[file exists [file join ${filepath} .svn]]} {
-            set svnChannel [open "|svn info ${filepath}" r]
-            set svnURL {}
-            while {[gets $svnChannel svnLine] >= 0} {
-               regexp {^URL: (.*)} $svnLine -> svnURL
+      if {[regexp {^([\w-]+://\S+)(?:\s+\[(\w+(?:,\w+)*)\])?$} $line -> url flags]} {
+         set flags [split $flags ,]
+         if {[lsearch $flags default] >= 0} {
+            set defaultSeen true
+         } elseif {[regexp {rsync://rsync\.(macports|darwinports)\.org/(release|dpupdate)/d?ports} $url]} {
+            set addDefault true
+         } elseif {[regexp {file://(/.+)} $url -> filepath]} {
+            if {[file exists [file join ${filepath} .svn]]} {
+               set svnChannel [open "|svn info ${filepath}" r]
+               set svnURL {}
+               while {[gets $svnChannel svnLine] >= 0} {
+                  regexp {^URL: (.*)} $svnLine -> svnURL
+               }
+               close $svnChannel
+               if {[regexp {^https?://svn\.(macports|macosforge)\.org/repository/macports/trunk/dports} $svnURL]} {
+                  set addDefault true
+               }
             }
-            close $svnChannel
-            if {[regexp {^https?://svn\.(macports|macosforge)\.org/repository/macports/trunk/dports} $svnURL]} {
-               set line [append_default_tag_to_line $line]
-               set defaultSeen true
-               set defaultWritten true
-            }
          }
+         if {$addDefault} {
+            lappend flags default
+            set line "$url \[[join $flags ,]\]"
+            set defaultSeen true
+            set defaultWritten true
+         }
       }
    }
    puts $tempfileChannel $line
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20081201/98361c4b/attachment.html>


More information about the macports-changes mailing list