[42751] branches/release_1_7

Simon Ruderich simon at ruderich.org
Sun Nov 30 09:44:06 PST 2008


On Sun, Nov 30, 2008 at 10:41:05AM -0600, Adam Mercer wrote:
> [snip]
>
> [ram at cizin base]$ cat /opt/local/etc/macports/sources.conf
> #rsync://rsync.macports.org/release/ports/
> file:///Users/ram/opt/macports [nosync]
> [ram at cizin base]$
>
> [snip]
>
> Any idea why base is complianing this directory doesn't exist when it does?
>
> Cheers
>
> Adam

The problem is that you don't have a [default] port in your sources.conf. Then
MacPorts fails sometimes because of a missing $sources_default in
[macports::getportresourcepath] (see my other mail). Thats why I committed
this change so the problem can be easily found.

Now I think it would be better to just issue a warning if no [default] is
there and use the first source as default. I attached the change as patch
default.diff. It also fixes the problem when no sources are defined at all but
a directory "ports" exists.

But maybe the best way would be to try to find the resource in all sources
(default first).

I just saw r42760 [1] and the question is if my patch should be committed or
not. It maybe useful to people who change their sources.conf later or have it
in a custom place but otherwise it's not necessary (except for the ports fix).
Please tell me if it should be committed.

Thanks,
Simon

[1]: http://trac.macports.org/changeset/42760
-- 
+ privacy is necessary
+ using http://gnupg.org
+ public key id: 0x6115F804EFB33229
-------------- next part --------------
diff --git a/base/src/macports1.0/macports.tcl b/base/src/macports1.0/macports.tcl
index 170ce0d..60a78fd 100644
--- a/base/src/macports1.0/macports.tcl
+++ b/base/src/macports1.0/macports.tcl
@@ -432,19 +432,23 @@ proc mportinit {{up_ui_options {}} {up_options {}} {up_variations {}}} {
             }
         }
     }
-    # Make sure the default port source is defined. Otherwise
-    # [macports::getportresourcepath] fails when the first source doesn't
-    # contain _resources.
-    if {![info exists sources_default]} {
-        return -code error "No default port source specified in $sources_conf"
-    }
 
+    # If no sources are defined try to use the "ports" directory in pwd as
+    # source.
     if {![info exists sources]} {
         if {[file isdirectory ports]} {
             set sources "file://[pwd]/ports"
+            set sources_default [concat [list $sources] [list default]]
         } else {
             return -code error "No sources defined in $sources_conf"
         }
+    # If no default source was defined in sources.conf use the first source
+    # as default and issue an error. This prevents an 'can't read
+    # "sources_default"' error in [macports::getportresourcepath] if the
+    # requested resource doesn't exist (in this source).
+    } elseif {![info exists sources_default]} {
+        set sources_default [lindex $sources 0]
+        ui_error "$sources_default specifies no default source."
     }
 
     if {[info exists variants_conf]} {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 194 bytes
Desc: not available
URL: <http://lists.macosforge.org/pipermail/macports-dev/attachments/20081130/0ccfbeb6/attachment.bin>


More information about the macports-dev mailing list