<pre style='margin:0'>
Joshua Root (jmroot) pushed a commit to branch master
in repository macports-base.
</pre>
<p><a href="https://github.com/macports/macports-base/commit/3750e1d66ce4a25323902db1d7b98d8f26b957ea">https://github.com/macports/macports-base/commit/3750e1d66ce4a25323902db1d7b98d8f26b957ea</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit 3750e1d66ce4a25323902db1d7b98d8f26b957ea
</span>Author: Joshua Root <jmr@macports.org>
AuthorDate: Tue Jun 4 07:35:01 2024 +1000
<span style='display:block; white-space:pre;color:#404040;'> Also consider portgroups for SOURCE_DATE_EPOCH
</span>---
src/port1.0/portmain.tcl | 67 +++++++++++++++++++++++++++++++++++-------------
1 file changed, 49 insertions(+), 18 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/port1.0/portmain.tcl b/src/port1.0/portmain.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index bfd14f23c..ecca36574 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/port1.0/portmain.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/port1.0/portmain.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -180,10 +180,11 @@ proc portmain::get_source_date_epoch {} {
</span> if {[info exists source_date_epoch_cached]} {
return $source_date_epoch_cached
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- global portpath
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ global portpath PortInfo
</span> set newest 0
if {[catch {findBinary git} git]} {
set git {}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ set paths_in_git_repo 0
</span> } elseif {[getuid] == 0} {
if {[catch {
set prev_euid [geteuid]
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -198,28 +199,58 @@ proc portmain::get_source_date_epoch {} {
</span> ui_debug "get_source_date_epoch: dropping privileges failed: $result"
}
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {$git ne {} && ![catch {exec -ignorestderr $git -C $portpath rev-parse --is-inside-work-tree 2> /dev/null}]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set checkpaths [list $portpath]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[info exists PortInfo(portgroups)]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lappend checkpaths {*}[lmap g $PortInfo(portgroups) {lindex $g 2}]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$git ne {}} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set checkdirs [list $portpath {*}[lmap p [lrange $checkpaths 1 end] {file dirname $p}]]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set paths_in_git_repo 1
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach d $checkdirs {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[catch {exec -ignorestderr $git -C $d rev-parse --is-inside-work-tree 2> /dev/null}]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set paths_in_git_repo 0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ break
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$paths_in_git_repo} {
</span> # Use time of last commit only if there are no uncommitted changes
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {![catch {exec -ignorestderr $git -C $portpath status --porcelain $portpath 2> /dev/null} result]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {$result eq ""} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {![catch {exec -ignorestderr $git -C $portpath log -1 --pretty=%ct $portpath 2> /dev/null} result]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set source_date_epoch_cached $result
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[info exists prev_euid]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- seteuid 0
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[info exists prev_egid]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- setegid $prev_egid
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- seteuid $prev_euid
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set any_uncommitted 0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach p $checkpaths d $checkdirs {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[catch {exec -ignorestderr $git -C $d status --porcelain $p 2> /dev/null} result]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set any_uncommitted 1
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_debug "get_source_date_epoch: git status failed: $result"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ break
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } elseif {$result ne ""} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set any_uncommitted 1
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_debug "get_source_date_epoch: uncommitted changes to $p"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ break
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {!$any_uncommitted} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set log_failed 0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach p $checkpaths d $checkdirs {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {![catch {exec -ignorestderr $git -C $d log -1 --pretty=%ct $p 2> /dev/null} result]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$result > $newest} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set newest $result
</span> }
<span style='display:block; white-space:pre;background:#ffe0e0;'>- return $result
</span> } else {
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ set log_failed 1
</span> ui_debug "get_source_date_epoch: git log failed: $result"
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ break
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {!$log_failed} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set source_date_epoch_cached $newest
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[info exists prev_euid]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ seteuid 0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[info exists prev_egid]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ setegid $prev_egid
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ seteuid $prev_euid
</span> }
<span style='display:block; white-space:pre;background:#ffe0e0;'>- } else {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- ui_debug "get_source_date_epoch: uncommitted changes in portpath"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return $newest
</span> }
<span style='display:block; white-space:pre;background:#ffe0e0;'>- } else {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- ui_debug "get_source_date_epoch: git status failed: $result"
</span> }
}
if {[info exists prev_euid]} {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -231,7 +262,7 @@ proc portmain::get_source_date_epoch {} {
</span> }
# TODO: Ensure commit timestamps as extracted above are set in
# ports tree distributed as tarball.
<span style='display:block; white-space:pre;background:#ffe0e0;'>- fs-traverse fullpath [list $portpath] {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ fs-traverse fullpath $checkpaths {
</span> if {[catch {
if {[file type $fullpath] eq "file"} {
set mtime [file mtime $fullpath]
</pre><pre style='margin:0'>
</pre>