Displaying a message dialog from a preinstall script.

297 views
Skip to first unread message

Bart Reardon

unread,
Jul 1, 2014, 8:20:55 PM7/1/14
to munk...@googlegroups.com
Just wondering if it's currently possible to display a dialog within MSC from a pre or post install script or otherwise have MSC display a generated error message?

for example, I have some optional installs that perform some pre install checks and setup. If any of those fail it would be nice to have a meaningful error message based on the context of the failure rather than a generic "something bad happened, see your administrator". I'm writing the scripts in python and while I could use something like Tkinter it would be nice to have MSC display the alert (besides, doing that would also display the generic error in MSC in addition to the Tkinter dialog...bleh).

Bart

Gregory Neagle

unread,
Jul 1, 2014, 8:49:14 PM7/1/14
to munk...@googlegroups.com
On Jul 1, 2014, at 5:20 PM, Bart Reardon <bart.r...@gmail.com> wrote:

> Just wondering if it's currently possible to display a dialog within MSC from a pre or post install script or otherwise have MSC display a generated error message?

Not currently.

It's not completely clear how something like should work.

Let's say there are ten items to be installed/removed. If there is an issue with item #2, should the install/removal of items 3-10 be held up/delayed/aborted because we are displaying a dialog? Or should we wait until all the installs and removals are done and then display any errors? What should happen if the user has quit MSC.app while the install/removal has taken place? Should we interrupt whatever they are doing? Is there actually anything the user can do about the situation (this answer probably depends on several factors).

How would this work if the install failure happens at the loginwindow? I doubt we'd want any sort of error dialog there.

What is the expected behavior if the item is also marked for unattended_install? A dialog showing up unbidden and untriggered is not what I would want/expect to happen.

> for example, I have some optional installs that perform some pre install checks and setup.
> If any of those fail it would be nice to have a meaningful error message based on the context of the failure rather than a generic "something bad happened, see your administrator".

I'm not even certain MSU/MSC even gives you that much feedback.

> I'm writing the scripts in python and while I could use something like Tkinter it would be nice to have MSC display the alert (besides, doing that would also display the generic error in MSC in addition to the Tkinter dialog...bleh).

More detail on your scenario(s) might lead to more possibilities.

>
> Bart

Bart Reardon

unread,
Jul 1, 2014, 9:24:31 PM7/1/14
to munk...@googlegroups.com
> I'm not even certain MSU/MSC even gives you that much feedback. 

I don't think there is a popup come to think of it. In MSC the update still appears in the updates tab but with an error if pre-install for a particular pkginfo hits exit(1). To refine the question then, can we specify error text to display next to a failed install. I presume the behaviour would be to continue with other installs and the user would then have the results/reasons in the updates tab.

So...no popups, but custom error text (if it's possible)

> More detail on your scenario(s) might lead to more possibilities. 

We have some limited seat licensed software that we charge back to people that want it. This is managed with a conditional manifest and works fine. The pre-install check is just to verify that the machine is recorded as having a valid license to cover the scenario where a licence is removed or the assigned to the wrong machine. So rather than just say "the install didn't work, see admin" it would be nice to specify a message like "this machine isn't licensed for this software" or something to that effect. Generally it shouldn't happen as in theory the only way someone will even see the software as an optional install is if it's assigned to the machine. However I can imagine future scenarios where having the ability to specify an error message would be handy (like the enhancement request that I put forward in april https://code.google.com/p/munki/issues/detail?id=310 but on a per package basis)

Bart

Bart Reardon

unread,
Jul 4, 2014, 1:07:36 AM7/4/14
to munk...@googlegroups.com
So, having a look through the code I think I know how to get it implemented...

in installer.py after setting install_error to true add a new key error_msg and set it to the text of the message

in MunkiItems.py , after if self.get('install_error') pull the text of error_msg if any and use that as warning_text otherwise use the default.

The tricky bit is a nice way to get a custom error message from the pre-install script into somewhere so installer.py can add it to InstallInfo.plist. Are there any environment variables available within preinstall scripts (e.g. pkg name)? I'm thinking the best option would be to write a tmp file with the error using pkg name that installer.py can pick up and write to InstallInfo.plist (environment variables aren't necessary but make it easier to set and find temp files on a per package basis using a common name). This should make custom error messages available for use without breakage anything. 

That's presuming this is a thing that people other than me would use. I can anticipate some cases (in my munki implementation) where the error message displayed could change depending on what pre-install check fails but may not be that useful for quick and dirty pre-install scripts.

On Wednesday, 2 July 2014 10:49:14 UTC+10, gregn...@mac.com wrote:

yagmot

unread,
Jul 4, 2014, 1:13:02 AM7/4/14
to munk...@googlegroups.com
Why not make the optional install item a conditional item whose condition is that the machine has a valid license? If the condition is met, it shouldn't be offered.

yagmot

unread,
Jul 4, 2014, 1:13:42 AM7/4/14
to munk...@googlegroups.com
Correction: if the condition is *not* met, it shouldn't be offered.

Bart Reardon

unread,
Jul 4, 2014, 1:29:38 AM7/4/14
to munk...@googlegroups.com
it already is. This is just another level of checks (the app doesn't appear at all based on conditions).

There are a number of reasons why an optional_install might fail or not be shown, but if the end user can provide info as to why an install failed then that's better for me. Hypothetically if you have "There's an error that says...." vs "I can't see the app at all?" the former cuts out a lot of diagnosis.
Reply all
Reply to author
Forward
0 new messages