<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/7bfefcbdc35c7249082f7f6cec32d90e90bed912">https://github.com/macports/macports-base/commit/7bfefcbdc35c7249082f7f6cec32d90e90bed912</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit 7bfefcbdc35c7249082f7f6cec32d90e90bed912
</span>Author: Joshua Root <jmr@macports.org>
AuthorDate: Fri Feb 16 07:46:20 2024 +1100
<span style='display:block; white-space:pre;color:#404040;'> portstartupitem: use dict for startupitems_dict
</span>---
src/port1.0/portstartupitem.tcl | 100 ++++++++++++++++++++--------------------
1 file changed, 49 insertions(+), 51 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/port1.0/portstartupitem.tcl b/src/port1.0/portstartupitem.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index 17b17bb31..61dd6d7eb 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/port1.0/portstartupitem.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/port1.0/portstartupitem.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -156,40 +156,40 @@ proc portstartupitem::foreach_startupitem {body} {
</span> name netchange pidfile plist requires restart start stop type \
uniquename user daemondo.verbosity]
<span style='display:block; white-space:pre;background:#ffe0e0;'>- array set startupitems_dict {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set startupitems_dict [dict create]
</span> if {[info exists startupitems] && $startupitems ne ""} {
foreach {key val} $startupitems {
if {$key eq "name"} {
set curname $val
# these have defaults based on the name
set uniquename org.macports.${val}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend startupitems_dict($curname) uniquename $uniquename
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend startupitems_dict($curname) plist ${uniquename}.plist
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set startupitems_dict $curname uniquename $uniquename
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set startupitems_dict $curname plist ${uniquename}.plist
</span> }
<span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend startupitems_dict($curname) $key $val
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set startupitems_dict $curname $key $val
</span> }
} else {
global startupitem.name
foreach var $vars {
global startupitem.${var}
if {[info exists startupitem.${var}]} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend startupitems_dict(${startupitem.name}) $var [set startupitem.${var}]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set startupitems_dict ${startupitem.name} $var [set startupitem.${var}]
</span> }
}
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- uplevel 1 "set si_vars [list $vars]"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- foreach item [array names startupitems_dict] {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- uplevel 1 "array unset si_dict; array set si_dict [list $startupitems_dict($item)]"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ uplevel 1 [list set si_vars $vars]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict for {item subdict} $startupitems_dict {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ uplevel 1 [list set si_dict $subdict]
</span> uplevel 1 {
foreach si_var $si_vars {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[info exists si_dict($si_var)]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set si_${si_var} $si_dict($si_var)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[dict exists $si_dict $si_var]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set si_${si_var} [dict get $si_dict $si_var]
</span> } else {
global startupitem.${si_var}
if {[info exists startupitem.${si_var}]} {
set si_${si_var} [set startupitem.${si_var}]
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set si_dict($si_var) [set startupitem.${si_var}]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set si_dict $si_var [set startupitem.${si_var}]
</span> }
}
}
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -283,11 +283,9 @@ proc portstartupitem::install_darwin_launchd {srcpath dstdir install} {
</span> proc portstartupitem::startupitem_create_darwin_launchd {attrs} {
global UI_PREFIX prefix destroot destroot.keepdirs subport macosx_deployment_target
<span style='display:block; white-space:pre;background:#ffe0e0;'>- array set si $attrs
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set uniquename $si(uniquename)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set plistname $si(plist)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set daemondest $si(location)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set uniquename [dict get $attrs uniquename]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set plistname [dict get $attrs plist]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set daemondest [dict get $attrs location]
</span> set itemdir ${prefix}/etc/${daemondest}/${uniquename}
file mkdir ${destroot}${itemdir}
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -295,32 +293,32 @@ proc portstartupitem::startupitem_create_darwin_launchd {attrs} {
</span> file attributes ${destroot}${itemdir} -owner root -group wheel
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {$si(custom_file) ne ""} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[dict get $attrs custom_file] ne ""} {
</span> # The port is supplying its own plist
<span style='display:block; white-space:pre;background:#ffe0e0;'>- file copy $si(custom_file) ${destroot}${itemdir}/${plistname}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- install_darwin_launchd ${itemdir}/${plistname} $daemondest $si(install)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ file copy [dict get $attrs custom_file] ${destroot}${itemdir}/${plistname}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ install_darwin_launchd ${itemdir}/${plistname} $daemondest [dict get $attrs install]
</span> return
}
set scriptdir ${prefix}/etc/startup
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set itemname $si(name)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set username $si(user)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set groupname $si(group)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set itemname [dict get $attrs name]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set username [dict get $attrs user]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set groupname [dict get $attrs group]
</span> set args [list \
"${prefix}/bin/daemondo" \
"--label=${itemname}" \
]
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {$si(executable) ne "" &&
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- $si(init) eq "" &&
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- $si(start) eq "" &&
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- $si(stop) eq "" &&
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- $si(restart) eq ""} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[dict get $attrs executable] ne "" &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ [dict get $attrs init] eq "" &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ [dict get $attrs start] eq "" &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ [dict get $attrs stop] eq "" &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ [dict get $attrs restart] eq ""} {
</span>
# An executable is specified, and there is no init, start, stop, or restart
# code; so we don't need a wrapper script
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set args [concat $args "--start-cmd" $si(executable) ";"]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set args [concat $args "--start-cmd" [dict get $attrs executable] ";"]
</span>
} else {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -330,14 +328,14 @@ proc portstartupitem::startupitem_create_darwin_launchd {attrs} {
</span> set wrappername ${itemname}.wrapper
set wrapper "${itemdir}/${wrappername}"
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {$si(start) eq ""} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set si(start) [list "sh ${scriptdir}/${subport}.sh start"]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[dict get $attrs start] eq ""} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set attrs start [list "sh ${scriptdir}/${subport}.sh start"]
</span> }
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {$si(stop) eq ""} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set si(stop) [list "sh ${scriptdir}/${subport}.sh stop"]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[dict get $attrs stop] eq ""} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set attrs stop [list "sh ${scriptdir}/${subport}.sh stop"]
</span> }
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {$si(restart) eq ""} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set si(restart) [list Stop Start]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[dict get $attrs restart] eq ""} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set attrs restart [list Stop Start]
</span> }
lappend args \
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -361,7 +359,7 @@ proc portstartupitem::startupitem_create_darwin_launchd {attrs} {
</span> puts ${item} "# Init"
puts ${item} "#"
puts ${item} "prefix=$prefix"
<span style='display:block; white-space:pre;background:#ffe0e0;'>- foreach line $si(init) { puts ${item} ${line} }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach line [dict get $attrs init] { puts ${item} ${line} }
</span> puts ${item} ""
puts ${item} "#"
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -369,7 +367,7 @@ proc portstartupitem::startupitem_create_darwin_launchd {attrs} {
</span> puts ${item} "#"
puts ${item} "Start()"
puts ${item} "\{"
<span style='display:block; white-space:pre;background:#ffe0e0;'>- foreach line $si(start) { puts ${item} "\t${line}" }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach line [dict get $attrs start] { puts ${item} "\t${line}" }
</span> puts ${item} "\}"
puts ${item} ""
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -378,7 +376,7 @@ proc portstartupitem::startupitem_create_darwin_launchd {attrs} {
</span> puts ${item} "#"
puts ${item} "Stop()"
puts ${item} "\{"
<span style='display:block; white-space:pre;background:#ffe0e0;'>- foreach line $si(stop) { puts ${item} "\t${line}" }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach line [dict get $attrs stop] { puts ${item} "\t${line}" }
</span> puts ${item} "\}"
puts ${item} ""
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -387,7 +385,7 @@ proc portstartupitem::startupitem_create_darwin_launchd {attrs} {
</span> puts ${item} "#"
puts ${item} "Restart()"
puts ${item} "\{"
<span style='display:block; white-space:pre;background:#ffe0e0;'>- foreach line $si(restart) { puts ${item} "\t${line}" }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach line [dict get $attrs restart] { puts ${item} "\t${line}" }
</span> puts ${item} "\}"
puts ${item} ""
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -414,12 +412,12 @@ proc portstartupitem::startupitem_create_darwin_launchd {attrs} {
</span> close ${item}
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {$si(netchange)} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[dict get $attrs netchange]} {
</span> lappend args "--restart-netchange"
}
# To log events then tell daemondo to log at verbosity=n
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {$si(logevents)} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[dict get $attrs logevents]} {
</span> lappend args "--verbosity=[option startupitem.daemondo.verbosity]"
}
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -431,7 +429,7 @@ proc portstartupitem::startupitem_create_darwin_launchd {attrs} {
</span> # (3) clean [pidfilename]
# (4) manual [pidfilename]
#
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set pidfileArgCnt [llength $si(pidfile)]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set pidfileArgCnt [llength [dict get $attrs pidfile]]
</span> if {${pidfileArgCnt} > 0} {
if { $pidfileArgCnt == 1 } {
set pidFile "${prefix}/var/run/${itemname}.pid"
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -439,7 +437,7 @@ proc portstartupitem::startupitem_create_darwin_launchd {attrs} {
</span> lappend destroot.keepdirs "${destroot}${prefix}/var/run"
}
} else {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set pidFile [lindex $si(pidfile) 1]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set pidFile [lindex [dict get $attrs pidfile] 1]
</span> }
if {${pidfileArgCnt} > 2} {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -447,7 +445,7 @@ proc portstartupitem::startupitem_create_darwin_launchd {attrs} {
</span> }
# Translate into appropriate arguments to daemondo
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set pidStyle [lindex $si(pidfile) 0]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set pidStyle [lindex [dict get $attrs pidfile] 0]
</span> switch -- ${pidStyle} {
none { lappend args "--pid=none" }
auto { lappend args "--pid=fileauto" "--pidfile" ${pidFile} }
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -458,7 +456,7 @@ proc portstartupitem::startupitem_create_darwin_launchd {attrs} {
</span> }
}
} else {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {$si(executable) ne ""} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[dict get $attrs executable] ne ""} {
</span> lappend args "--pid=exec"
} else {
lappend args "--pid=none"
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -496,15 +494,15 @@ proc portstartupitem::startupitem_create_darwin_launchd {attrs} {
</span> puts ${plist} "<key>GroupName</key><string>$groupname</string>"
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {$si(logfile) ne ""} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- puts ${plist} "<key>StandardOutPath</key><string>$si(logfile)</string>"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[dict get $attrs logfile] ne ""} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ puts ${plist} "<key>StandardOutPath</key><string>[dict get $attrs logfile]</string>"
</span> }
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {$si(logfile.stderr) ne ""} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- puts ${plist} "<key>StandardErrorPath</key><string>$si(logfile.stderr)</string>"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[dict get $attrs logfile.stderr] ne ""} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ puts ${plist} "<key>StandardErrorPath</key><string>[dict get $attrs logfile.stderr]</string>"
</span> }
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {$si(debug)} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[dict get $attrs debug]} {
</span> puts ${plist} "<key>Debug</key><true/>"
}
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -513,7 +511,7 @@ proc portstartupitem::startupitem_create_darwin_launchd {attrs} {
</span>
close ${plist}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- install_darwin_launchd ${itemdir}/${plistname} $daemondest $si(install)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ install_darwin_launchd ${itemdir}/${plistname} $daemondest [dict get $attrs install]
</span> }
proc portstartupitem::startupitem_create {} {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -528,7 +526,7 @@ proc portstartupitem::startupitem_create {} {
</span> }
switch -- ${si_type} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- launchd { startupitem_create_darwin_launchd [array get si_dict] }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ launchd { startupitem_create_darwin_launchd $si_dict }
</span> default { ui_error "$UI_PREFIX [msgcat::mc "Unrecognized startupitem type %s" ${si_type}]" }
}
}
</pre><pre style='margin:0'>
</pre>