Re: [31500] trunk/base/src/port
Is there a good reason not to do this in the MacPorts API? On 26 Nov 2007, at 00:47, jberry@macports.org wrote:
Revision 31500 Author jberry@macports.org Date 2007-11-25 21:47:26 -0800 (Sun, 25 Nov 2007) Log Message Initial support for port load and port unload actions. These actions call invoke launchctl to load or unload the startupitem.plist for the specified port(s). Modified Paths trunk/base/src/port/port.tcl trunk/base/src/port1.0/Makefile trunk/base/src/port1.0/port.tcl trunk/base/src/port1.0/portdestroot.tcl trunk/base/src/port1.0/portstartupitem.tcl Added Paths trunk/base/src/port1.0/portload.tcl trunk/base/src/port1.0/portunload.tcl Diff Modified: trunk/base/src/port/port.tcl (31499 => 31500) --- trunk/ base/src/port/port.tcl 2007-11-26 05:41:11 UTC (rev 31499) +++ trunk/base/src/port/port.tcl 2007-11-26 05:47:26 UTC (rev 31500) @@ -2164,6 +2164,8 @@ livecheck action_target distcheck action_target mirror action_target + load action_target + unload action_target archive action_target unarchive action_target Modified: trunk/base/src/port1.0/Makefile (31499 => 31500) --- trunk/base/src/port1.0/Makefile 2007-11-26 05:41:11 UTC (rev 31499) +++ trunk/base/src/port1.0/Makefile 2007-11-26 05:47:26 UTC (rev 31500) @@ -3,9 +3,9 @@ SRCS= port.tcl portchecksum.tcl portconfigure.tcl portextract.tcl \ portfetch.tcl portmain.tcl portbuild.tcl portpatch.tcl portutil.tcl \ portinstall.tcl portdepends.tcl portdestroot.tcl portlint.tcl \ - portclean.tcl porttest.tcl portactivate.tcl portsubmit.tcl \ + portclean.tcl porttest.tcl portactivate.tcl portsubmit.tcl \ port_autoconf.tcl portstartupitem.tcl porttrace.tcl portlivecheck.tcl \ - portdistcheck.tcl portmirror.tcl + portdistcheck.tcl portmirror.tcl portload.tcl portunload.tcl SUBDIR= resources Modified: trunk/base/src/port1.0/port.tcl (31499 => 31500) --- trunk/base/src/port1.0/port.tcl 2007-11-26 05:41:11 UTC (rev 31499) +++ trunk/base/src/port1.0/port.tcl 2007-11-26 05:47:26 UTC (rev 31500) @@ -52,3 +52,5 @@ package require portdistcheck 1.0 package require portlivecheck 1.0 package require portmirror 1.0 +package require portload 1.0 +package require portunload 1.0 Modified: trunk/base/src/port1.0/portdestroot.tcl (31499 => 31500) --- trunk/base/src/port1.0/portdestroot.tcl 2007-11-26 05:41:11 UTC (rev 31499) +++ trunk/base/src/port1.0/portdestroot.tcl 2007-11-26 05:47:26 UTC (rev 31500) @@ -47,6 +47,7 @@ options startupitem.name startupitem.start startupitem.stop startupitem.restart options startupitem.type startupitem.executable options startupitem.pidfile startupitem.logfile startupitem.logevents startupitem.netchange +options startupitem.uniquename startupitem.plist startupitem.location commands destroot # Set defaults @@ -62,6 +63,9 @@ default destroot.violate_mtree no default startupitem.name {${portname}} +default startupitem.uniquename {org.macports.${startupitem.name}} +default startupitem.plist {${startupitem.uniquename}.plist} +default startupitem.location LaunchDaemons default startupitem.init "" default startupitem.start "" default startupitem.stop "" Added: trunk/base/src/port1.0/portload.tcl (0 => 31500) --- trunk/ base/src/port1.0/portload.tcl (rev 0) +++ trunk/base/src/port1.0/ portload.tcl 2007-11-26 05:47:26 UTC (rev 31500) @@ -0,0 +1,59 @@ +# et:ts=4 +# portsubmit.tcl +# $Id: portsubmit.tcl 26177 2007-06-15 10:11:22Z jmpp@macports.org $ +# +# Copyright (c) 2007 MacPorts Project +# Copyright (c) 2007 James D. Berry +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +package provide portload 1.0 +package require portutil 1.0 + +set org.macports.load [target_new org.macports.load load_main] +target_runtype ${org.macports.load} always +target_provides ${org.macports.load} load +target_requires $ {org.macports.load} main + +set_ui_prefix + +proc load_main {args} { + global startupitem.type startupitem.name startupitem.location startupitem.plist + set launchctl_path $ {portutil::autoconf::launchctl_path} + + foreach { path } "/Library/ ${startupitem.location}/${startupitem.plist}" { + if {[string length $launchctl_path] == 0} { + return -code error [format [msgcat::mc "launchctl command was not found by configure"]] + } elseif {![file exists $path]} { + return -code error [format [msgcat::mc "Launchd plist %s was not found"] $path] + } else { + exec $launchctl_path load -w $path + } + } + + return +} Modified: trunk/base/src/port1.0/portstartupitem.tcl (31499 => 31500) --- trunk/base/src/port1.0/portstartupitem.tcl 2007-11-26 05:41:11 UTC (rev 31499) +++ trunk/base/src/port1.0/ portstartupitem.tcl 2007-11-26 05:47:26 UTC (rev 31500) @@ -3,8 +3,9 @@ # # $Id$ # -# Copyright (c) 2004, 2005 Markus W. Weissman <mww@macports.org>, -# Copyright (c) 2005 Robert Shaw <rshaw@opendarwin.org>, +# Copyright (c) 2004-2007 MacPorts Project +# Copyright (c) 2006-2007 James D. Berry +# Copyright (c) 2004,2005 Markus W. Weissman <mww@macports.org> # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -390,9 +391,9 @@ set scriptdir ${prefix}/etc/ startup set itemname ${startupitem.name} - set uniquename org.macports.${itemname} - set plistname ${uniquename}.plist - set daemondest LaunchDaemons + set uniquename ${startupitem.uniquename} + set plistname ${startupitem.plist} + set daemondest $ {startupitem.location} set itemdir ${prefix}/etc/${daemondest}/$ {uniquename} set args [list \ "${prefix}/bin/daemondo" \ Added: trunk/base/src/port1.0/portunload.tcl (0 => 31500) --- trunk/ base/src/port1.0/portunload.tcl (rev 0) +++ trunk/base/src/port1.0/ portunload.tcl 2007-11-26 05:47:26 UTC (rev 31500) @@ -0,0 +1,59 @@ +# et:ts=4 +# portsubmit.tcl +# $Id: portsubmit.tcl 26177 2007-06-15 10:11:22Z jmpp@macports.org $ +# +# Copyright (c) 2007 MacPorts Project +# Copyright (c) 2007 James D. Berry +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +package provide portunload 1.0 +package require portutil 1.0 + +set org.macports.unload [target_new org.macports.unload unload_main] +target_runtype $ {org.macports.unload} always +target_provides $ {org.macports.unload} unload +target_requires $ {org.macports.unload} main + +set_ui_prefix + +proc unload_main {args} { + global startupitem.type startupitem.name startupitem.location startupitem.plist + set launchctl_path $ {portutil::autoconf::launchctl_path} + + foreach { path } "/Library/ ${startupitem.location}/${startupitem.plist}" { + if {[string length $launchctl_path] == 0} { + return -code error [format [msgcat::mc "launchctl command was not found by configure"]] + } elseif {![file exists $path]} { + return -code error [format [msgcat::mc "Launchd plist %s was not found"] $path] + } else { + exec $launchctl_path unload -w $path + } + } + + return +} _______________________________________________ macports-changes mailing list macports-changes@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo/macports-changes
Randall Wood rhwood@mac.com http://shyramblings.blogspot.com "The rules are simple: The ball is round. The game lasts 90 minutes. All the rest is just philosophy."
Hi Randall, On Nov 26, 2007, at 1:40 AM, Randall Wood wrote:
Is there a good reason not to do this in the MacPorts API?
I'm happy to have any thoughts on the approach. I tend to think this is in the "API" layer, since it's implemented as a target. So in other words, it's on parr with clean, lint, trace, activate, etc. But I'm clearly missing the intent behind your words. How do you think it should be implemented, and why? James
On 26 Nov 2007, at 00:47, jberry@macports.org wrote:
Revision 31500 Author jberry@macports.org Date 2007-11-25 21:47:26 -0800 (Sun, 25 Nov 2007) Log Message Initial support for port load and port unload actions. These actions call invoke launchctl to load or unload the startupitem.plist for the specified port(s). Modified Paths trunk/base/src/port/port.tcl trunk/base/src/port1.0/Makefile trunk/base/src/port1.0/port.tcl trunk/base/src/port1.0/portdestroot.tcl trunk/base/src/port1.0/portstartupitem.tcl Added Paths trunk/base/src/port1.0/portload.tcl trunk/base/src/port1.0/portunload.tcl
On 26 Nov 2007, at 09:54, James Berry wrote:
Hi Randall,
On Nov 26, 2007, at 1:40 AM, Randall Wood wrote:
Is there a good reason not to do this in the MacPorts API?
I'm happy to have any thoughts on the approach. I tend to think this is in the "API" layer, since it's implemented as a target. So in other words, it's on parr with clean, lint, trace, activate, etc.
If its a target implemented by calling "mportexec foo [un]load" then I'm happy. I guess I'm not as familiar with the code as I thought I was, but I don't see where or how something using the MacPorts API (base/src/macports1.0) gets the port API.
But I'm clearly missing the intent behind your words. How do you think it should be implemented, and why?
Looking at the MacPorts API, I just don't see where the port API comes into play. I guess I'm just confused.
James
On 26 Nov 2007, at 00:47, jberry@macports.org wrote:
Revision 31500 Author jberry@macports.org Date 2007-11-25 21:47:26 -0800 (Sun, 25 Nov 2007) Log Message Initial support for port load and port unload actions. These actions call invoke launchctl to load or unload the startupitem.plist for the specified port(s). Modified Paths trunk/base/src/port/port.tcl trunk/base/src/port1.0/Makefile trunk/base/src/port1.0/port.tcl trunk/base/src/port1.0/portdestroot.tcl trunk/base/src/port1.0/portstartupitem.tcl Added Paths trunk/base/src/port1.0/portload.tcl trunk/base/src/port1.0/portunload.tcl
Randall Wood rhwood@mac.com http://shyramblings.blogspot.com "The rules are simple: The ball is round. The game lasts 90 minutes. All the rest is just philosophy."
Hi Randall, On Nov 26, 2007, at 5:47 PM, Randall Wood wrote:
On 26 Nov 2007, at 09:54, James Berry wrote:
On Nov 26, 2007, at 1:40 AM, Randall Wood wrote:
Is there a good reason not to do this in the MacPorts API?
I'm happy to have any thoughts on the approach. I tend to think this is in the "API" layer, since it's implemented as a target. So in other words, it's on parr with clean, lint, trace, activate, etc.
If its a target implemented by calling "mportexec foo [un]load" then I'm happy. I guess I'm not as familiar with the code as I thought I was, but I don't see where or how something using the MacPorts API (base/src/macports1.0) gets the port API.
Yes, see action_target in port.tcl from port(1). It calls mportopen, mportexec, mportclose.
But I'm clearly missing the intent behind your words. How do you think it should be implemented, and why?
Looking at the MacPorts API, I just don't see where the port API comes into play. I guess I'm just confused.
I don't blame you for being confused. I'm confused every time I look at that code. It's a ball of worms. The more I know about it the more I want to rewrite it ;) But time, alas, intervenes. James
James
On 26 Nov 2007, at 00:47, jberry@macports.org wrote:
Revision 31500 Author jberry@macports.org Date 2007-11-25 21:47:26 -0800 (Sun, 25 Nov 2007) Log Message Initial support for port load and port unload actions. These actions call invoke launchctl to load or unload the startupitem.plist for the specified port(s). Modified Paths trunk/base/src/port/port.tcl trunk/base/src/port1.0/Makefile trunk/base/src/port1.0/port.tcl trunk/base/src/port1.0/portdestroot.tcl trunk/base/src/port1.0/portstartupitem.tcl Added Paths trunk/base/src/port1.0/portload.tcl trunk/base/src/port1.0/portunload.tcl
Randall Wood rhwood@mac.com http://shyramblings.blogspot.com
"The rules are simple: The ball is round. The game lasts 90 minutes. All the rest is just philosophy."
Hi Randall and James,
Looking at the MacPorts API, I just don't see where the port API comes into play. I guess I'm just confused.
I don't blame you for being confused. I'm confused every time I look at that code. It's a ball of worms. The more I know about it the more I want to rewrite it ;) But time, alas, intervenes.
That makes me feel a lot better; I thought I was just too dim-witted to understand it. Perhaps, as a first step towards rewriting the source, those who understand some of it can start documenting it? No need to do it all at once; one function at a time would do, explaining what it's supposed to do, how it goes about it and where it fits in the scheme of things. That way it'll make it more likely that someone will turn up with time to attempt a rewrite without being intimidated out of the idea. Anders has put a port of tcldoc into the tree, so that should be a useful format to start with. Kind regards, Maun Suang -- Boey Maun Suang (Boey is my surname) Email: boeyms at macports dot org
participants (3)
-
Boey Maun Suang
-
James Berry
-
Randall Wood