Don't print messages inside platform directives
A user on macports-users reported this problem, which I can confirm: On May 25, 2007, at 15:03, Valentin Kuznetsov wrote:
When I run portindex I've got 0 errors, but along the output lines I saw:
Error: ==== ATTENTION!!!! ==== Error: Sockstat is not working under darwin 8 nor tiger. Please use Error: lsof -i6/lsof -i4/lsof -U instead. Error: ==== ATTENTION!!!! ====
I also see the message just by typing "port info sockstat", which is likely due to recent changes to "port info": $ port info sockstat Error: ==== ATTENTION!!!! ==== Error: Sockstat is not working under darwin 8 nor tiger. Please use Error: lsof -i6/lsof -i4/lsof -U instead. Error: ==== ATTENTION!!!! ==== Error: Please sudo port uninstall sockstat sockstat 1.6.2.6, sysutils/sockstat (Variants: universal, darwin_8) http://www.freebsd.org/cgi/cvsweb.cgi/src/usr.bin/sockstat/? hideattic=0&only_with_tag=RELENG_4_9 The sockstat command lists open Internet or UNIX domain sockets. Current version of sockstat from FreeBSD is written in C while this old version is still in Perl. This program is from FreeBSD's source tree. Platforms: darwin Maintainers: mjhsieh@yahoo.com sysutils/sockstat does this: platform darwin 8 { ui_error "==== ATTENTION!!!! ====" ui_error "Sockstat is not working under darwin 8 nor tiger. Please use" ui_error "lsof -i6/lsof -i4/lsof -U instead." ui_error "==== ATTENTION!!!! ====" ui_error "Please sudo port uninstall sockstat" } I don't think we should be outputting any messages of any kind in platform variants which MacPorts auto-selects, because they get executed at all sorts of times where outputting messages is not appropriate. Instead, I believe the port should do something like this if it wants to output a message: platform darwin 8 {} pre-fetch { if { [variant_isset darwin_8] } { ui_error "==== ATTENTION!!!! ====" ui_error "Sockstat is not working under darwin 8 nor tiger. Please use" ui_error "lsof -i6/lsof -i4/lsof -U instead." ui_error "==== ATTENTION!!!! ====" ui_error "Please sudo port uninstall sockstat" } } I'm also concerned that the port would output a message saying that the port is not compatible with Tiger, yet not prevent installation on Tiger. It should exit after printing that message. Well, the message should be reworded too, since it's not a forgone conclusion that the user already has sockstat installed at the point that they see the message. The user may be trying to install it for the first time, in which case an uninstall is not necessary or possible. Finally, it's not clear why we are preventing the port from installing on 10.4. Will it work on earlier OS versions like 10.3 or 10.2? I assume yes. What about later OS versions like 10.5? I assume no, but I don't know for sure. The port description, or at least a comment in the portfile, should explain this, and if it's expected that the port won't work on 10.5 either, then darwin 9 should be excluded also.
Hello, there's just something bothering me with platform/variant directives i've seen here and there. Why do you use a dummy platform and use variant_isset in the stage directive? From what i've seen (and coded, of course), every stage in every activated variant/platform is executed. Le 25 mai 07 à 23:44, Ryan Schmidt a écrit :
...
platform darwin 8 {} pre-fetch { if { [variant_isset darwin_8] } { ui_error "==== ATTENTION!!!! ====" ui_error "Sockstat is not working under darwin 8 nor tiger. Please use" ui_error "lsof -i6/lsof -i4/lsof -U instead." ui_error "==== ATTENTION!!!! ====" ui_error "Please sudo port uninstall sockstat" } }
...
-- Anthony Ramine, a lazy french student. nox@macports.org
On May 25, 2007, at 16:49, N_Ox wrote:
Le 25 mai 07 à 23:44, Ryan Schmidt a écrit :
platform darwin 8 {} pre-fetch { if { [variant_isset darwin_8] } { ui_error "==== ATTENTION!!!! ====" ui_error "Sockstat is not working under darwin 8 nor tiger. Please use" ui_error "lsof -i6/lsof -i4/lsof -U instead." ui_error "==== ATTENTION!!!! ====" ui_error "Please sudo port uninstall sockstat" } }
there's just something bothering me with platform/variant directives i've seen here and there. Why do you use a dummy platform and use variant_isset in the stage directive?
From what i've seen (and coded, of course), every stage in every activated variant/platform is executed.
If you don't declare "platform darwin 8" to be *something*, even an empty "{}", then "[variant_isset _darwin_8]" will be false and the message will not be printed. Try it out. I just did. Further observation: the output from ui_error is not printed for example if I do "sudo port fetch sockstat"; it needs to be ui_msg instead. Taking all of my observations into account, I propose the following patch to the sockstat portfile. Any comments? Maintainer? Index: Portfile =================================================================== --- Portfile (revision 25597) +++ Portfile (working copy) @@ -19,12 +19,21 @@ use_configure no -platform darwin 8 { - ui_error "==== ATTENTION!!!! ====" - ui_error "Sockstat is not working under darwin 8 nor tiger. Please use" - ui_error "lsof -i6/lsof -i4/lsof -U instead." - ui_error "==== ATTENTION!!!! ====" - ui_error "Please sudo port uninstall sockstat" +platform darwin 8 {} +platform darwin 9 {} +pre-fetch { + if { [variant_isset darwin_8] } { + ui_msg "Sockstat does not work under Mac OS X 10.4 Tiger. Please use" + ui_msg "lsof -i6/lsof -i4/lsof -U" + ui_msg "instead." + exit 1 + } + if { [variant_isset darwin_9] } { + ui_msg "Sockstat does not work under Mac OS X 10.5 Leopard. Please use" + ui_msg "lsof -i6/lsof -i4/lsof -U" + ui_msg "instead." + exit 1 + } } destroot {
On May 25, 2007, at 17:14, Ryan Schmidt wrote:
On May 25, 2007, at 16:49, N_Ox wrote:
Le 25 mai 07 à 23:44, Ryan Schmidt a écrit :
platform darwin 8 {} pre-fetch { if { [variant_isset darwin_8] } { ui_error "==== ATTENTION!!!! ====" ui_error "Sockstat is not working under darwin 8 nor tiger. Please use" ui_error "lsof -i6/lsof -i4/lsof -U instead." ui_error "==== ATTENTION!!!! ====" ui_error "Please sudo port uninstall sockstat" } }
there's just something bothering me with platform/variant directives i've seen here and there. Why do you use a dummy platform and use variant_isset in the stage directive?
From what i've seen (and coded, of course), every stage in every activated variant/platform is executed.
If you don't declare "platform darwin 8" to be *something*, even an empty "{}", then "[variant_isset _darwin_8]" will be false and the message will not be printed. Try it out. I just did.
Or perhaps it would be better and clearer to use the syntax shown in the ipcs portfile: platform darwin 8 { pre-fetch { ui_msg "\n This port is broken on OS X 10.4, but not necessary on 10.4 either because beginning with 10.4, Apple includes the ipcs and ipcrm utilities as standard.\n" exit 1 } }
Le 26 mai 07 à 00:14, Ryan Schmidt a écrit :
On May 25, 2007, at 16:49, N_Ox wrote:
Le 25 mai 07 à 23:44, Ryan Schmidt a écrit :
platform darwin 8 {} pre-fetch { if { [variant_isset darwin_8] } { ui_error "==== ATTENTION!!!! ====" ui_error "Sockstat is not working under darwin 8 nor tiger. Please use" ui_error "lsof -i6/lsof -i4/lsof -U instead." ui_error "==== ATTENTION!!!! ====" ui_error "Please sudo port uninstall sockstat" } }
there's just something bothering me with platform/variant directives i've seen here and there. Why do you use a dummy platform and use variant_isset in the stage directive?
From what i've seen (and coded, of course), every stage in every activated variant/platform is executed.
If you don't declare "platform darwin 8" to be *something*, even an empty "{}", then "[variant_isset _darwin_8]" will be false and the message will not be printed. Try it out. I just did.
Sorry, you haven't understood me, i meant: platform darwin 8 { pre-fetch { if { [variant_isset darwin_8] } { ui_error "==== ATTENTION!!!! ====" ui_error "Sockstat is not working under darwin 8 nor tiger. Please use" ui_error "lsof -i6/lsof -i4/lsof -U instead." ui_error "==== ATTENTION!!!! ====" ui_error "Please sudo port uninstall sockstat" } } } -- Anthony Ramine, a lazy french student. nox@macports.org
On May 25, 2007, at 16:44, Ryan Schmidt wrote:
sysutils/sockstat does this:
platform darwin 8 { ui_error "==== ATTENTION!!!! ====" ui_error "Sockstat is not working under darwin 8 nor tiger. Please use" ui_error "lsof -i6/lsof -i4/lsof -U instead." ui_error "==== ATTENTION!!!! ====" ui_error "Please sudo port uninstall sockstat" }
I don't think we should be outputting any messages of any kind in platform variants which MacPorts auto-selects, because they get executed at all sorts of times where outputting messages is not appropriate. Instead, I believe the port should do something like this if it wants to output a message:
platform darwin 8 {} pre-fetch { if { [variant_isset darwin_8] } { ui_error "==== ATTENTION!!!! ====" ui_error "Sockstat is not working under darwin 8 nor tiger. Please use" ui_error "lsof -i6/lsof -i4/lsof -U instead." ui_error "==== ATTENTION!!!! ====" ui_error "Please sudo port uninstall sockstat" } }
I'm also concerned that the port would output a message saying that the port is not compatible with Tiger, yet not prevent installation on Tiger. It should exit after printing that message. Well, the message should be reworded too, since it's not a forgone conclusion that the user already has sockstat installed at the point that they see the message. The user may be trying to install it for the first time, in which case an uninstall is not necessary or possible.
Several other ports have the same problem and should be corrected. Looks like this mechanism is really only used to say to the user that a port is not supported on a particular OS version. There's also a few ports where we need to do similar for ports that only work on PowerPC or Intel but not the other. Do we have a better way that we could handle this at the MacPorts level -- a way to indicate which kinds of darwin platforms a port works with? I know we can already say "platforms darwin" but can we say something like "platforms darwin_8_ppc"? Maybe we even need to mechanisms: one to specify OS versions / CPU architectures on which the port works, and another to specify OS versions / CPU architectures where the port does not work, and the port could choose one or the other as appropriate. For example, a port that works on 10.2 but not 10.3 or later would choose the former and would specify only 10.2. A port that works with 10.4 or later would use the latter and would specify that 10.2 and 10.3 don't work. And MacPorts would have friendly and consistent messages to the user. gwright: ghc: platform darwin 6 { ui_msg "GHC is not supported on Jaguar (OS X 10.2.x)" exit 1 } mww: hugs98: platform darwin 6 { ui_msg "Hugs is not supported on Jaguar (10.2.x). Sorry." exit 0 } nomaintainer: clips: platform darwin 6 { ui_msg "clisp is not supported on Jaguar (OS X 10.2.x)" exit 1 } nomaintainer: cln: platform darwin 6 { ui_msg "cln is not supported on Jaguar (OS X 10.2.x)" exit 1 } platform darwin 7 { ui_msg "cln is not supported on Panther (OS X 10.3.x)" exit 1 } nomaintainer: kdelibs3: platform darwin 6 { ui_msg "Sorry, your platform is no longer supported." exit 1 } nomaintainer: qt3: platform darwin 6 { ui_msg "Sorry, your platform is no longer supported." exit 1 } nomaintainer: xloops: platform darwin 6 { ui_msg "xloops is not supported on Jaguar (OS X 10.2.x)" exit 1 }
participants (2)
-
N_Ox
-
Ryan Schmidt