<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/99d5fb30eb4c1ba8b7924807a052291ba31b792c">https://github.com/macports/macports-base/commit/99d5fb30eb4c1ba8b7924807a052291ba31b792c</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 99d5fb3 Allow multiple startupitems per port
</span>99d5fb3 is described below
<span style='display:block; white-space:pre;color:#808000;'>commit 99d5fb30eb4c1ba8b7924807a052291ba31b792c
</span>Author: Joshua Root <jmr@macports.org>
AuthorDate: Wed Mar 28 03:17:05 2018 +1100
<span style='display:block; white-space:pre;color:#404040;'> Allow multiple startupitems per port
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> The portfile interface is a new option called 'startupitems'. This
</span><span style='display:block; white-space:pre;color:#404040;'> should be filled with a list of key/value pairs, with the names of the
</span><span style='display:block; white-space:pre;color:#404040;'> keys corresponding to the startupitem.* options. Each startupitem
</span><span style='display:block; white-space:pre;color:#404040;'> declared this way must speficy at least a name. Other options will be
</span><span style='display:block; white-space:pre;color:#404040;'> taken to have the value of the corresponding startupitem.* option if
</span><span style='display:block; white-space:pre;color:#404040;'> not present. Options apply to the name that appeared immediately prior.
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> Example:
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> startupitem.create yes
</span><span style='display:block; white-space:pre;color:#404040;'> startupitems name mydaemon \
</span><span style='display:block; white-space:pre;color:#404040;'> executable ${prefix}/bin/mydaemon \
</span><span style='display:block; white-space:pre;color:#404040;'> name anotherthing \
</span><span style='display:block; white-space:pre;color:#404040;'> start "${prefix}/bin/another --someflag"
</span><span style='display:block; white-space:pre;color:#404040;'> stop "${prefix}/bin/another shutdown"
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> Fixes: https://trac.macports.org/ticket/44295
</span>---
src/macports1.0/macports.tcl | 14 ++-
src/port1.0/portactivate.tcl | 8 +-
src/port1.0/portdeactivate.tcl | 7 +-
src/port1.0/portdestroot.tcl | 6 +-
src/port1.0/portload.tcl | 23 ++--
src/port1.0/portreload.tcl | 6 +-
src/port1.0/portstartupitem.tcl | 257 +++++++++++++++++++++++++++-------------
src/port1.0/portunload.tcl | 8 +-
8 files changed, 215 insertions(+), 114 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/macports1.0/macports.tcl b/src/macports1.0/macports.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index da79b90..3f9d0db 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/macports1.0/macports.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/macports1.0/macports.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -4039,9 +4039,9 @@ proc macports::_upgrade {portname dspec variationslist optionslist {depscachenam
</span>
# check if the startupitem is loaded, so we can load again it after upgrading
# (deactivating the old version will unload the startupitem)
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set load_startupitem 0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set loaded_startupitems {}
</span> if {$portname eq $newname} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set load_startupitem [$workername eval {portstartupitem::is_loaded}]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set loaded_startupitems [$workername eval {portstartupitem::loaded}]
</span> }
# are we installing an existing version due to force or epoch override?
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -4108,9 +4108,13 @@ proc macports::_upgrade {portname dspec variationslist optionslist {depscachenam
</span> catch {mportclose $mport}
return 1
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {$load_startupitem && [catch {mportexec $mport load} result]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- ui_debug $::errorInfo
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- ui_warn "Error loading startupitem for ${newname}: $result"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$loaded_startupitems ne ""} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ $workername eval "set ::portstartupitem::load_only [list $loaded_startupitems]"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[catch {mportexec $mport load} result]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_debug $::errorInfo
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_warn "Error loading startupitem(s) for ${newname}: $result"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ $workername eval "unset ::portstartupitem::load_only"
</span> }
}
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/port1.0/portactivate.tcl b/src/port1.0/portactivate.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index 247302b..ef6930c 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/port1.0/portactivate.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/port1.0/portactivate.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -67,17 +67,19 @@ proc portactivate::activate_main {args} {
</span> }
proc portactivate::activate_finish {args} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- global subport startupitem.autostart PortInfo UI_PREFIX startupitem_autostart
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ global subport PortInfo startupitem_autostart
</span>
# Do this _after_ activate_main, because post-activate hooks might create
# the files needed for this
# The option from macports.conf can override the portfile here.
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[tbool startupitem.autostart] && [tbool startupitem_autostart]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- ui_notice "$UI_PREFIX [format [msgcat::mc "Loading %s"] $subport]"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[tbool startupitem_autostart]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set ::portstartupitem::autostart_only yes
</span> if {[eval_targets "load"]} {
ui_error [format [msgcat::mc "Failed to load %s"] $subport]
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ unset ::portstartupitem::autostart_only
</span> return 1
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ unset ::portstartupitem::autostart_only
</span> }
# Save notes for display by the port client
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/port1.0/portdeactivate.tcl b/src/port1.0/portdeactivate.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index 5941e5a..00c682f 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/port1.0/portdeactivate.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/port1.0/portdeactivate.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -56,12 +56,11 @@ proc portdeactivate::deactivate_start {args} {
</span> }
proc portdeactivate::deactivate_main {args} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- global subport version revision portvariants user_options UI_PREFIX
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ global subport version revision portvariants user_options
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[portstartupitem::is_loaded]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- ui_notice "$UI_PREFIX [format [msgcat::mc "Unloading startupitem for %s"] $subport]"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[portstartupitem::loaded] ne ""} {
</span> if {[eval_targets "unload"]} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- ui_warn [format [msgcat::mc "Failed to unload startupitem for %s (continuing anyway)"] $subport]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_warn [format [msgcat::mc "Failed to unload startupitem(s) for %s (continuing anyway)"] $subport]
</span> }
}
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/port1.0/portdestroot.tcl b/src/port1.0/portdestroot.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index 5c4a302..26b4d2e 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/port1.0/portdestroot.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/port1.0/portdestroot.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -126,15 +126,13 @@ proc portdestroot::destroot_main {args} {
</span> }
proc portdestroot::destroot_finish {args} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- global UI_PREFIX destroot prefix subport startupitem.create destroot.violate_mtree \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ global UI_PREFIX destroot prefix subport destroot.violate_mtree \
</span> applications_dir frameworks_dir destroot.keepdirs destroot.delete_la_files \
os.platform os.version
variable oldmask
# Create startup-scripts/items
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[tbool startupitem.create]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- portstartupitem::startupitem_create
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ portstartupitem::startupitem_create
</span>
foreach fileToDelete {share/info/dir lib/charset.alias} {
if {[file exists "${destroot}${prefix}/${fileToDelete}"]} {
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/port1.0/portload.tcl b/src/port1.0/portload.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index 12eba2f..7003c9b 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/port1.0/portload.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/port1.0/portload.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -48,18 +48,23 @@ default load.asroot yes
</span> set_ui_prefix
proc portload::load_main {args} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- global startupitem.location startupitem.plist
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ global UI_PREFIX subport
</span> set launchctl_path ${portutil::autoconf::launchctl_path}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- foreach { path } "/Library/${startupitem.location}/${startupitem.plist}" {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {$launchctl_path eq ""} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return -code error [format [msgcat::mc "launchctl command was not found by configure"]]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- } elseif {![file exists $path]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return -code error [format [msgcat::mc "Launchd plist %s was not found"] $path]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- } else {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- exec -ignorestderr $launchctl_path load -w $path
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ portstartupitem::foreach_startupitem {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {(![info exists ::portstartupitem::load_only] || $si_name in ${::portstartupitem::load_only})
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ && (![info exists ::portstartupitem::autostart_only] || !$::portstartupitem::autostart_only || $si_autostart)} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_notice "$UI_PREFIX [format [msgcat::mc "Loading startupitem '%s' for %s"] $si_name $subport]"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set path /Library/${si_location}/${si_plist}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$launchctl_path eq ""} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return -code error [format [msgcat::mc "launchctl command was not found by configure"]]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } elseif {![file exists $path]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return -code error [format [msgcat::mc "Launchd plist %s was not found"] $path]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ exec -ignorestderr $launchctl_path load -w $path
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span> }
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> return
}
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/port1.0/portreload.tcl b/src/port1.0/portreload.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index 59424dc..c17301c 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/port1.0/portreload.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/port1.0/portreload.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -47,10 +47,12 @@ default reload.asroot yes
</span> set_ui_prefix
proc portreload::reload_main {args} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- global startupitem.location startupitem.plist
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ global UI_PREFIX subport
</span> set launchctl_path ${portutil::autoconf::launchctl_path}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- foreach { path } "/Library/${startupitem.location}/${startupitem.plist}" {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ portstartupitem::foreach_startupitem {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_notice "$UI_PREFIX [format [msgcat::mc "Reloading startupitem '%s' for %s"] $si_name $subport]"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set path /Library/${si_location}/${si_plist}
</span> if {$launchctl_path eq ""} {
return -code error [format [msgcat::mc "launchctl command was not found by configure"]]
} elseif {![file exists $path]} {
<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 6e9e442..2a9d54e 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;'>@@ -74,8 +74,8 @@ package require portutil 1.0
</span> namespace eval portstartupitem {
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>-options startupitem.autostart startupitem.debug startupitem.create \
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- startupitem.executable \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+options startupitems startupitem.autostart startupitem.debug \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ startupitem.create startupitem.executable \
</span> startupitem.init startupitem.install startupitem.location \
startupitem.logevents startupitem.logfile startupitem.name \
startupitem.netchange startupitem.pidfile startupitem.plist \
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -128,52 +128,138 @@ proc portstartupitem::get_startupitem_type {} {
</span> return $type
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+# run a loop body with variables set up representing the attributes of
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# each startupitem that has been defined in the portfile
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+proc portstartupitem::foreach_startupitem {body} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ global startupitems
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set vars [list autostart debug create executable init install location \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ logevents logfile name netchange pidfile plist requires \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ restart start stop type uniquename daemondo.verbosity]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ array set startupitems_dict {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[info exists startupitems] && $startupitems ne ""} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach {key val} $startupitems {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$key eq "name"} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set curname $val
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # these have defaults based on the name
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set uniquename org.macports.${val}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lappend startupitems_dict($curname) uniquename $uniquename
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lappend startupitems_dict($curname) plist ${uniquename}.plist
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lappend startupitems_dict($curname) $key [list $val]
</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;'>+ global startupitem.name
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach var $vars {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ global startupitem.${var}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[info exists startupitem.${var}]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lappend startupitems_dict(${startupitem.name}) $var [set startupitem.${var}]
</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;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ uplevel 1 "set si_vars [list $vars]"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach item [array names startupitems_dict] {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ 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 {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach si_var $si_vars {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[info exists si_dict($si_var)]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set si_${si_var} $si_dict($si_var)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ global startupitem.${si_var}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[info exists startupitem.${si_var}]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set si_${si_var} [set startupitem.${si_var}]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set si_dict($si_var) [set startupitem.${si_var}]
</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;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ uplevel 1 $body
</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> # Add user notes regarding any installed startupitem
proc portstartupitem::add_notes {} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- global startupitem.type startupitem.autostart subport startupitem_autostart
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {${startupitem.type} eq "none"} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[exists notes]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # leave a blank line after the existing notes
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- notes-append ""
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ global subport startupitem_autostart
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set autostart_names {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set normal_names {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach_startupitem {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$si_type eq "none"} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ continue
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # Add some information for the user to the port's notes
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$si_autostart && [tbool startupitem_autostart]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lappend autostart_names $si_name
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lappend normal_names $si_name
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span> }
<span style='display:block; white-space:pre;background:#ffe0e0;'>- # Add some information for the user to the port's notes
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[tbool startupitem.autostart] && [tbool startupitem_autostart]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- notes-append \
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- "A startup item has been generated that will aid in\
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- starting ${subport} with launchd. It will be enabled\
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- automatically on activation. Execute the following\
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- command to manually _disable_ it:
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>- sudo port unload ${subport}"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$normal_names ne ""} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[exists notes]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # leave a blank line after the existing notes
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ notes-append ""
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[llength $normal_names] == 1} {
</span> notes-append \
<span style='display:block; white-space:pre;background:#ffe0e0;'>- "A startup item has been generated that will aid in\
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- starting ${subport} with launchd. It is disabled\
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- by default. Execute the following command to start it,\
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- and to cause it to launch at startup:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "A startup item has been generated that will aid in\
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ starting ${subport} with launchd. It is disabled\
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ by default. Execute the following command to start it,\
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ and to cause it to launch at startup:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ sudo port load ${subport}"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set namelist [join $normal_names ", "]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ notes-append \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "Startup items (named '$namelist') have been generated that will aid in\
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ starting ${subport} with launchd. They are disabled\
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ by default. Execute the following command to start them,\
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ and to cause them to launch at startup:
</span>
sudo port load ${subport}"
<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 {$autostart_names ne ""} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[exists notes]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # leave a blank line after the existing notes
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ notes-append ""
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[llength $autostart_names] == 1} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ notes-append \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "A startup item has been generated that will\
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ start ${subport} with launchd, and will be enabled\
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ automatically on activation. Execute the following\
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ command to manually _disable_ it:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ sudo port unload ${subport}"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set namelist [join $autostart_names ", "]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ notes-append \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "Startup items (named '$namelist') have been generated that will\
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ start ${subport} with launchd, and will be enabled\
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ automatically on activation. Execute the following\
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ command to manually _disable_ them:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ sudo port unload ${subport}"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span> }
}
# Register the above procedure as a callback after Portfile evaluation
port::register_callback portstartupitem::add_notes
<span style='display:block; white-space:pre;background:#ffe0e0;'>-proc portstartupitem::startupitem_create_darwin_launchd {args} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- global UI_PREFIX prefix destroot destroot.keepdirs subport macosx_deployment_target \
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- startupitem.name startupitem.uniquename startupitem.plist startupitem.location \
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- startupitem.init startupitem.start startupitem.stop startupitem.restart startupitem.executable \
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- startupitem.pidfile startupitem.logfile startupitem.logevents startupitem.netchange \
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- startupitem.install startupitem.debug
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+proc portstartupitem::startupitem_create_darwin_launchd {attrs} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ global UI_PREFIX prefix destroot destroot.keepdirs subport macosx_deployment_target
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ array set si $attrs
</span>
set scriptdir ${prefix}/etc/startup
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set itemname ${startupitem.name}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set uniquename ${startupitem.uniquename}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set plistname ${startupitem.plist}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set daemondest ${startupitem.location}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set itemname $si(name)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set uniquename $si(uniquename)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set plistname $si(plist)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set daemondest $si(location)
</span> set itemdir ${prefix}/etc/${daemondest}/${uniquename}
set args [list \
"${prefix}/bin/daemondo" \
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -185,15 +271,15 @@ proc portstartupitem::startupitem_create_darwin_launchd {args} {
</span> file attributes ${destroot}${itemdir} -owner root -group wheel
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[llength ${startupitem.executable}] &&
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- ![llength ${startupitem.init}] &&
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- ![llength ${startupitem.start}] &&
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- ![llength ${startupitem.stop}] &&
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- ![llength ${startupitem.restart}]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$si(executable) ne "" &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ $si(init) eq "" &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ $si(start) eq "" &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ $si(stop) eq "" &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ $si(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" ${startupitem.executable} ";"]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set args [concat $args "--start-cmd" $si(executable) ";"]
</span>
} else {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -203,14 +289,14 @@ proc portstartupitem::startupitem_create_darwin_launchd {args} {
</span> set wrappername ${itemname}.wrapper
set wrapper "${itemdir}/${wrappername}"
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {![llength ${startupitem.start}]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set startupitem.start [list "sh ${scriptdir}/${subport}.sh start"]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$si(start) eq ""} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set si(start) [list "sh ${scriptdir}/${subport}.sh start"]
</span> }
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {![llength ${startupitem.stop}]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set startupitem.stop [list "sh ${scriptdir}/${subport}.sh stop"]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$si(stop) eq ""} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set si(stop) [list "sh ${scriptdir}/${subport}.sh stop"]
</span> }
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {![llength ${startupitem.restart}]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set startupitem.restart [list Stop Start]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$si(restart) eq ""} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set si(restart) [list Stop Start]
</span> }
lappend args \
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -234,7 +320,7 @@ proc portstartupitem::startupitem_create_darwin_launchd {args} {
</span> puts ${item} "# Init"
puts ${item} "#"
puts ${item} "prefix=$prefix"
<span style='display:block; white-space:pre;background:#ffe0e0;'>- foreach line ${startupitem.init} { puts ${item} ${line} }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach line $si(init) { puts ${item} ${line} }
</span> puts ${item} ""
puts ${item} "#"
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -242,7 +328,7 @@ proc portstartupitem::startupitem_create_darwin_launchd {args} {
</span> puts ${item} "#"
puts ${item} "Start()"
puts ${item} "\{"
<span style='display:block; white-space:pre;background:#ffe0e0;'>- foreach line ${startupitem.start} { puts ${item} "\t${line}" }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach line $si(start) { puts ${item} "\t${line}" }
</span> puts ${item} "\}"
puts ${item} ""
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -251,7 +337,7 @@ proc portstartupitem::startupitem_create_darwin_launchd {args} {
</span> puts ${item} "#"
puts ${item} "Stop()"
puts ${item} "\{"
<span style='display:block; white-space:pre;background:#ffe0e0;'>- foreach line ${startupitem.stop} { puts ${item} "\t${line}" }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach line $si(stop) { puts ${item} "\t${line}" }
</span> puts ${item} "\}"
puts ${item} ""
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -260,7 +346,7 @@ proc portstartupitem::startupitem_create_darwin_launchd {args} {
</span> puts ${item} "#"
puts ${item} "Restart()"
puts ${item} "\{"
<span style='display:block; white-space:pre;background:#ffe0e0;'>- foreach line ${startupitem.restart} { puts ${item} "\t${line}" }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach line $si(restart) { puts ${item} "\t${line}" }
</span> puts ${item} "\}"
puts ${item} ""
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -287,12 +373,12 @@ proc portstartupitem::startupitem_create_darwin_launchd {args} {
</span> close ${item}
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[tbool startupitem.netchange]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$si(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 {[tbool startupitem.logevents]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$si(logevents)} {
</span> lappend args "--verbosity=[option startupitem.daemondo.verbosity]"
}
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -304,13 +390,15 @@ proc portstartupitem::startupitem_create_darwin_launchd {args} {
</span> # (3) clean [pidfilename]
# (4) manual [pidfilename]
#
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set pidfileArgCnt [llength ${startupitem.pidfile}]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set pidfileArgCnt [llength $si(pidfile)]
</span> if {${pidfileArgCnt} > 0} {
if { $pidfileArgCnt == 1 } {
set pidFile "${prefix}/var/run/${itemname}.pid"
<span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend destroot.keepdirs "${destroot}${prefix}/var/run"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {"${destroot}${prefix}/var/run" ni ${destroot.keepdirs}} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lappend destroot.keepdirs "${destroot}${prefix}/var/run"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span> } else {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set pidFile [lindex ${startupitem.pidfile} 1]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set pidFile [lindex $si(pidfile) 1]
</span> }
if {${pidfileArgCnt} > 2} {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -318,7 +406,7 @@ proc portstartupitem::startupitem_create_darwin_launchd {args} {
</span> }
# Translate into appropriate arguments to daemondo
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set pidStyle [lindex ${startupitem.pidfile} 0]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set pidStyle [lindex $si(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;'>@@ -329,7 +417,7 @@ proc portstartupitem::startupitem_create_darwin_launchd {args} {
</span> }
}
} else {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[llength ${startupitem.executable}]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$si(executable) ne ""} {
</span> lappend args "--pid=exec"
} else {
lappend args "--pid=none"
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -359,11 +447,11 @@ proc portstartupitem::startupitem_create_darwin_launchd {args} {
</span> puts ${plist} "<key>OnDemand</key><false/>"
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[llength ${startupitem.logfile}]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- puts ${plist} "<key>StandardOutPath</key><string>${startupitem.logfile}</string>"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$si(logfile) ne ""} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ puts ${plist} "<key>StandardOutPath</key><string>$si(logfile)</string>"
</span> }
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[tbool startupitem.debug]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$si(debug)} {
</span> puts ${plist} "<key>Debug</key><true/>"
}
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -372,56 +460,57 @@ proc portstartupitem::startupitem_create_darwin_launchd {args} {
</span>
close ${plist}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[getuid] == 0 &&
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- ${startupitem.install} ne "no"} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[getuid] == 0 && $si(install)} {
</span> file mkdir "${destroot}/Library/${daemondest}"
ln -sf "${itemdir}/${plistname}" "${destroot}/Library/${daemondest}"
}
}
proc portstartupitem::startupitem_create {} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- global UI_PREFIX startupitem.type
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ global UI_PREFIX
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {${startupitem.type} eq "none"} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- ui_notice "$UI_PREFIX [msgcat::mc "Skipping creation of control script"]"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- } else {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- ui_notice "$UI_PREFIX [msgcat::mc "Creating ${startupitem.type} control script"]"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach_startupitem {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {${si_type} ne "none"} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_notice "$UI_PREFIX [msgcat::mc "Creating ${si_type} control script '$si_name'"]"
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>- switch -- ${startupitem.type} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- launchd { startupitem_create_darwin_launchd }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- default { ui_error "$UI_PREFIX [msgcat::mc "Unrecognized startupitem type %s" ${startupitem.type}]" }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ switch -- ${si_type} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ launchd { startupitem_create_darwin_launchd [array get si_dict] }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ default { ui_error "$UI_PREFIX [msgcat::mc "Unrecognized startupitem type %s" ${si_type}]" }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span> }
}
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>-# Check if this port's startupitem is loaded
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-# Returns: 1 if loaded, 0 otherwise
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-proc portstartupitem::is_loaded {} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[option startupitem.type] eq "launchd"} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set launchctl_path ${portutil::autoconf::launchctl_path}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {$launchctl_path eq ""} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # assuming not loaded if there's no launchctl
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return 0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# Check if this port's startupitems are loaded
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# Returns: list of loaded startupitems
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+proc portstartupitem::loaded {} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set launchctl_path ${portutil::autoconf::launchctl_path}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$launchctl_path eq ""} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # assuming not loaded if there's no launchctl
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set ret {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ global os.major
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach_startupitem {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$si_type ne "launchd"} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ continue
</span> }
<span style='display:block; white-space:pre;background:#ffe0e0;'>- global os.major startupitem.uniquename
</span> if {${os.major} >= 14} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {![catch {exec -ignorestderr $launchctl_path print system/${startupitem.uniquename} >&/dev/null}]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return 1
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {![catch {exec -ignorestderr $launchctl_path print system/${si_uniquename} >&/dev/null}]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lappend ret $si_name
</span> }
} else {
if {[getuid] == 0} {
elevateToRoot "launchctl list"
set elevated 1
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set ret 0
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {![catch {exec -ignorestderr $launchctl_path list ${startupitem.uniquename} >&/dev/null}]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set ret 1
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {![catch {exec -ignorestderr $launchctl_path list ${si_uniquename} >&/dev/null}]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lappend ret $si_name
</span> }
if {[info exists elevated]} {
dropPrivileges
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- return $ret
</span> }
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- return 0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return $ret
</span> }
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/port1.0/portunload.tcl b/src/port1.0/portunload.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index 91290cb..c248427 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/port1.0/portunload.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/port1.0/portunload.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -48,10 +48,12 @@ default unload.asroot yes
</span> set_ui_prefix
proc portunload::unload_main {args} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- global startupitem.location startupitem.plist
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ global UI_PREFIX subport
</span> set launchctl_path ${portutil::autoconf::launchctl_path}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- foreach { path } "/Library/${startupitem.location}/${startupitem.plist}" {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ portstartupitem::foreach_startupitem {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_notice "$UI_PREFIX [format [msgcat::mc "Unloading startupitem '%s' for %s"] $si_name $subport]"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set path /Library/${si_location}/${si_plist}
</span> if {$launchctl_path eq ""} {
return -code error [format [msgcat::mc "launchctl command was not found by configure"]]
} elseif {![file exists $path]} {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -60,6 +62,6 @@ proc portunload::unload_main {args} {
</span> exec -ignorestderr $launchctl_path unload -w $path
}
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> return
}
</pre><pre style='margin:0'>
</pre>