<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/4dfabb9c0de9abfcbb4acf1ad68471b0a20983ab">https://github.com/macports/macports-base/commit/4dfabb9c0de9abfcbb4acf1ad68471b0a20983ab</a></p>
<pre style="white-space: pre; background: #F8F8F8">The following commit(s) were added to refs/heads/master by this push:
<span style='display:block; white-space:pre;color:#404040;'> new 4dfabb9c0 Set SOURCE_DATE_EPOCH to when port was last changed
</span>4dfabb9c0 is described below
<span style='display:block; white-space:pre;color:#808000;'>commit 4dfabb9c0de9abfcbb4acf1ad68471b0a20983ab
</span>Author: Joshua Root <jmr@macports.org>
AuthorDate: Mon May 13 08:12:50 2024 +1000
<span style='display:block; white-space:pre;color:#404040;'> Set SOURCE_DATE_EPOCH to when port was last changed
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> This is the timestamp of the last commit affecting the portdir if it is
</span><span style='display:block; white-space:pre;color:#404040;'> in a git repo, otherwise the latest mtime of the files in the portdir.
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> Closes: https://trac.macports.org/ticket/59672
</span><span style='display:block; white-space:pre;color:#404040;'> Closes: https://github.com/macports/macports-base/pull/274
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> Co-authored-by: harens <12570877+harens@users.noreply.github.com>
</span>---
src/port1.0/portmain.tcl | 76 +++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 75 insertions(+), 1 deletion(-)
<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 99ee71db5..567fea64a 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;'>@@ -171,7 +171,81 @@ default distpath {[file normalize [file join $portdbpath distfiles ${dist_subdir
</span>
default use_xcode {[expr {${build.type} eq "xcode" || !([file exists /usr/lib/libxcselect.dylib] || ${os.major} >= 20) || ![file executable /Library/Developer/CommandLineTools/usr/bin/make]}]}
<span style='display:block; white-space:pre;background:#ffe0e0;'>-default source_date_epoch 1715555555
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+default source_date_epoch {[portmain::get_source_date_epoch]}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# Figure out when this port was last modified, intended to be used as a
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# timestamp for reproducible builds.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+proc portmain::get_source_date_epoch {} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ variable source_date_epoch_cached
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[info exists source_date_epoch_cached]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return $source_date_epoch_cached
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ global portpath
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set newest 0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[catch {findBinary git} git]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set git {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } elseif {[getuid] == 0} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[catch {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set prev_euid [geteuid]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set prev_egid [getegid]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[geteuid] != 0} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ seteuid 0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # Must change egid before dropping root euid.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ setegid [name_to_gid [file attributes $portpath -group]]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ seteuid [name_to_uid [file attributes $portpath -owner]]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } result]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_debug "get_source_date_epoch: dropping privileges failed: $result"
</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 {$git ne {} && ![catch {exec -ignorestderr $git -C $portpath rev-parse --is-inside-work-tree}]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # Use time of last commit only if there are no uncommitted changes
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {![catch {exec -ignorestderr $git -C $portpath status --porcelain $portpath} result]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$result eq ""} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {![catch {exec -ignorestderr $git -C $portpath log -1 --pretty=%ct $portpath} result]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set source_date_epoch_cached $result
</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:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return $result
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_debug "get_source_date_epoch: git log failed: $result"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_debug "get_source_date_epoch: uncommitted changes in portpath"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } else {
</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;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</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:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # TODO: Ensure commit timestamps as extracted above are set in
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # ports tree distributed as tarball.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ fs-traverse fullpath [list $portpath] {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[catch {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[file type $fullpath] eq "file"} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set mtime [file mtime $fullpath]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$mtime > $newest} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set newest $mtime
</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;'>+ } result]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_debug "get_source_date_epoch: $result"
</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;'>+ set source_date_epoch_cached $newest
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return $newest
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span>
proc portmain::main {args} {
return 0
</pre><pre style='margin:0'>
</pre>