[MacPorts] #70539: base: failure for building some ports (depending on conditions) when Macports is installed at deeper directory hierarchy with "--prefix" option
MacPorts
noreply at macports.org
Tue Aug 13 12:42:29 UTC 2024
#70539: base: failure for building some ports (depending on conditions) when
Macports is installed at deeper directory hierarchy with "--prefix"
option
---------------------------+--------------------
Reporter: nanigashi-uji | Owner: (none)
Type: defect | Status: new
Priority: Normal | Milestone:
Component: base | Version: 2.10.0
Keywords: | Port:
---------------------------+--------------------
I have installed Macports as follows
{{{
% tar xvf MacPorts-2.9.3.tar.bz2
% cd MacPorts-2.9.3
% ./configure
--prefix=${HOME}/Documents/workspace/opr/depot/macports-2.9.3.arm64 \
--with-no-root-privileges --enable-readline \
--enable-shared --without-startupitems \
--with-applications-
dir=${HOME}/Documents/workspace/opr/depot/macports-2.9.3.arm64/Applications
\
--with-frameworks-
dir=${HOME}/Documents/workspace/opr/depot/macports-2.9.3.arm64/Library/Frameworks
% make && make install &&
${HOME}/Documents/workspace/opr/depot/macports-2.9.3.arm64/bin/port -v
selfupdate
}}}
Then we can basically use port command with out trouble, but sometimes we
fail to build some ports almost randomly. The reason why some ports are
failed to be build is intermediate file name become longer than the
FILENAME_MAX or PATH_MAX of macOS. One of the reason of the too long
intermediate filename is that "${portbuildpath}" is generated based on the
full path of Portfile like
"${prefix}/var/macports/build/_Users_{username}_Documents_workspace_opr_depot_macports-2.9.3.arm64_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_{category}_{portname}"
in the example above.
So, I propose to modify "macports.tcl" as follows to reduce the
possibility the probability of the error due to too long filename during
the build.
{{{
diff -rupN MacPorts-2.10.0.orig/src/macports1.0/macports.tcl
MacPorts-2.10.0/src/macports1.0/macports.tcl
--- MacPorts-2.10.0.orig/src/macports1.0/macports.tcl 2024-08-07
23:17:43
+++ MacPorts-2.10.0/src/macports1.0/macports.tcl 2024-08-13
20:25:36
@@ -3028,16 +3028,29 @@ proc _source_is_obsolete_svn_repo {source_dir} {
return 0
}
+proc macports::trim_prefix {fullpath prefix} {
+ set fullpath [file normalize $fullpath]
+ set prefix [file normalize $prefix]
+ if {[string first $prefix $fullpath] != 0} {
+ return $fullpath
+ }
+ set relative_path [string range $fullpath [string length $prefix]
end]
+ set relative_path [string trimleft $relative_path "/\\"]
+ return $relative_path
+}
+
proc macports::getportbuildpath {id {portname {}}} {
variable portdbpath
- regsub {://} $id {.} port_path
+ set s_id [macports::trim_prefix $id [file join $portdbpath sources]]
+ regsub {://} $s_id {.} port_path
regsub -all {/} $port_path {_} port_path
return [file join $portdbpath build $port_path $portname]
}
proc macports::getportlogpath {id {portname {}}} {
variable portdbpath
- regsub {://} $id {.} port_path
+ set s_id [macports::trim_prefix $id [file join $portdbpath sources]]
+ regsub {://} $s_id {.} port_path
regsub -all {/} $port_path {_} port_path
return [file join $portdbpath logs $port_path $portname]
}
diff -rupN MacPorts-2.10.0.orig/src/port1.0/tests/portutil.test
MacPorts-2.10.0/src/port1.0/tests/portutil.test
--- MacPorts-2.10.0.orig/src/port1.0/tests/portutil.test 2024-08-07
23:17:43
+++ MacPorts-2.10.0/src/port1.0/tests/portutil.test 2024-08-13
20:25:56
@@ -52,9 +52,21 @@ proc init_eval_targets {} {
set mport [mportopen file://.]
+ proc trim_prefix {fullpath prefix} {
+ set fullpath [file normalize $fullpath]
+ set prefix [file normalize $prefix]
+ if {[string first $prefix $fullpath] != 0} {
+ return $fullpath
+ }
+ set relative_path [string range $fullpath [string length $prefix]
end]
+ set relative_path [string trimleft $relative_path "/\\"]
+ return $relative_path
+ }
+
proc getportbuildpath {id {portname ""}} {
global portdbpath
- regsub {://} $id {.} port_path
+ set s_id [trim_prefix $id [file join $portdbpath sources]]
+ regsub {://} $s_id {.} port_patha
regsub -all {/} $port_path {_} port_path
return [file join $portdbpath build $port_path $portname]
}
}}}
--
Ticket URL: <https://trac.macports.org/ticket/70539>
MacPorts <https://www.macports.org/>
Ports system for macOS
More information about the macports-tickets
mailing list