Ticket #70539: macports-1.0-buildpath-truncate.patch

File macports-1.0-buildpath-truncate.patch, 1.8 KB (added by nanigashi-uji (Nanigashi Uji), 5 weeks ago)
Line 
1diff -rc MacPorts-2.10.0.orig/src/macports1.0/macports.tcl MacPorts-2.10.0/src/macports1.0/macports.tcl
2*** MacPorts-2.10.0.orig/src/macports1.0/macports.tcl   Wed Aug  7 23:17:43 2024
3--- MacPorts-2.10.0/src/macports1.0/macports.tcl        Tue Aug 13 20:25:36 2024
4***************
5*** 3028,3043 ****
6      return 0
7  }
8 
9  proc macports::getportbuildpath {id {portname {}}} {
10      variable portdbpath
11!     regsub {://} $id {.} port_path
12      regsub -all {/} $port_path {_} port_path
13      return [file join $portdbpath build $port_path $portname]
14  }
15 
16  proc macports::getportlogpath {id {portname {}}} {
17      variable portdbpath
18!     regsub {://} $id {.} port_path
19      regsub -all {/} $port_path {_} port_path
20      return [file join $portdbpath logs $port_path $portname]
21  }
22--- 3028,3056 ----
23      return 0
24  }
25 
26+ proc macports::trim_prefix {fullpath prefix} {
27+     set fullpath [file normalize $fullpath]
28+     set prefix   [file normalize $prefix]
29+     if {[string first $prefix $fullpath] != 0} {
30+         return $fullpath
31+     }
32+     set relative_path [string range $fullpath [string length $prefix] end]
33+     set relative_path [string trimleft $relative_path "/\\"]
34+     return $relative_path
35+ }
36+
37  proc macports::getportbuildpath {id {portname {}}} {
38      variable portdbpath
39!     set s_id [macports::trim_prefix $id [file join $portdbpath sources]]
40!     regsub {://} $s_id {.} port_path
41      regsub -all {/} $port_path {_} port_path
42      return [file join $portdbpath build $port_path $portname]
43  }
44 
45  proc macports::getportlogpath {id {portname {}}} {
46      variable portdbpath
47!     set s_id [macports::trim_prefix $id [file join $portdbpath sources]]
48!     regsub {://} $s_id {.} port_path
49      regsub -all {/} $port_path {_} port_path
50      return [file join $portdbpath logs $port_path $portname]
51  }