Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Aug 23, 2013, 11:30 AM   #1
Goftrey
macrumors 68000
 
Goftrey's Avatar
 
Join Date: May 2011
Location: Kepler 186F
Adding Command (Script) to Packagemaker Installer?

Hey guys, I've always been one to tinker around in Photoshop, creating icons/themes etc. for personal use. And it occurred to me that maybe some other people may enjoy them too - so I decided to put together an installer.

PackageMaker makes putting a .mpkg together incredibly simple. It's pretty much a drag & drop process all the way.

However - I've hit a little issue. I've made the installer require a restart (instead of making the user jump in to terminal & 'killall' everything manually), but for whatever reason this doesn't refresh the icons in the dock. The remain in the same state as they were in prior to the install. You can get around this by simply dragging the app out of the dock & re-adding it again. But that defeats the whole point of the 'automated' installer. I figured out this happens because the icon cache isn't updated.

After installing the theme, typing these commands 'refreshes' the dock & changes the icons, eliminating the need to drag the icons out of the dock & re-add them;

Code:
sudo find /private/var/folders/ -name com.apple.dock.iconcache

*Enter admin password*

sudo find /private/var/folders/ -name com.apple.dock.iconcache -exec rm {} \; 2>/dev/null

killall Dock
My question is - how do I add this script into the installer itself?

Thanks.

PS. The same issue applies when uninstalling the theme & returning to the original OS X icons.
__________________
Mac Pro 4x 2.66GHz, 6GB, 750GB HDD, HD5770 | PowerBook G4 1.67GHz, 2GB, 32GB SSD, 9700 | 20" Alu Cinema Display
PowerMac G4 2x 1.42GHz | PowerMac G5 2x 2.3GHz | HTC One 32GB | Canon EOS 500D
Goftrey is offline   0 Reply With Quote
Old Aug 23, 2013, 04:58 PM   #2
Goftrey
Thread Starter
macrumors 68000
 
Goftrey's Avatar
 
Join Date: May 2011
Location: Kepler 186F
Come on guys! 500 views & not one of you know?
__________________
Mac Pro 4x 2.66GHz, 6GB, 750GB HDD, HD5770 | PowerBook G4 1.67GHz, 2GB, 32GB SSD, 9700 | 20" Alu Cinema Display
PowerMac G4 2x 1.42GHz | PowerMac G5 2x 2.3GHz | HTC One 32GB | Canon EOS 500D
Goftrey is offline   0 Reply With Quote
Old Aug 23, 2013, 05:57 PM   #3
chown33
macrumors 603
 
Join Date: Aug 2009
Quote:
Originally Posted by Goftrey View Post
Come on guys! 500 views & not one of you know?
Just so you know, not all "views" are humans. Some will be web-crawlers, such as for search engines.

And speaking of search engines, when I google the search terms packagemaker script I find a lot of articles that mention the different places where a script can be placed in an installer package. Which leads me to ask the question: What have you tried?

If you tried searching, what terms did you search for (post actual search terms)? What did you find (post typical URLs)? Why was what you found unable to answer your question?

Did you consider asking your question in a forum where more PackageMaker expertise might be available, such as one of Apple's discussions?


I should also point out that there's no chance that the 'sudo' command in an installer script will be able to prompt for an admin password. The install needs to run in its entirety with elevated privileges (i.e. as root). The installer will then have the responsibility to prompt for the admin password, and the installation will then run as root. If you don't know how to do that in PackageMaker, try googling packagemaker admin authorization.

Also, there's no need to use this in 'find':
Code:
-exec rm {} \;
when there's this:
Code:
-delete
unless you're using a really old version of 'find', which makes me wonder what OS version you're targeting.
chown33 is offline   0 Reply With Quote
Old Aug 23, 2013, 06:59 PM   #4
Goftrey
Thread Starter
macrumors 68000
 
Goftrey's Avatar
 
Join Date: May 2011
Location: Kepler 186F
Quote:
Originally Posted by chown33 View Post
Just so you know, not all "views" are humans. Some will be web-crawlers, such as for search engines.

And speaking of search engines, when I google the search terms packagemaker script I find a lot of articles that mention the different places where a script can be placed in an installer package. Which leads me to ask the question: What have you tried?

If you tried searching, what terms did you search for (post actual search terms)? What did you find (post typical URLs)? Why was what you found unable to answer your question?

Did you consider asking your question in a forum where more PackageMaker expertise might be available, such as one of Apple's discussions?
If you want search terms, then here's just a few;
PackageMaker AppleScript
Add Terminal Command PackageMaker
Post Install Script PackageMaker

There's about 2 dozen of those types of searches with the words played around with, amounting to the same results. I've looked in the Apple Support forums, and decided to post here before going there. As the experiences I've found on that site have are, well - not helpful to say the least.

Quote:
I should also point out that there's no chance that the 'sudo' command in an installer script will be able to prompt for an admin password. The install needs to run in its entirety with elevated privileges (i.e. as root). The installer will then have the responsibility to prompt for the admin password, and the installation will then run as root. If you don't know how to do that in PackageMaker, try googling packagemaker admin authorization.

Also, there's no need to use this in 'find':
Code:
-exec rm {} \;
when there's this:
Code:
-delete
unless you're using a really old version of 'find', which makes me wonder what OS version you're targeting.
I'm pretty new to pretty anything terminal based so go easy on me!

I'm creating the installer individually for each version of OS X (as they use different icons in different places & use different formats in some cases). I'm supporting OS X 10.4 Tiger through OS X 10.9 Mavericks (when's it let loose).

So onto the admin quote - you're saying that as long as admin auth. is ticked (as it already is) the commands will execute straight off the bat?
__________________
Mac Pro 4x 2.66GHz, 6GB, 750GB HDD, HD5770 | PowerBook G4 1.67GHz, 2GB, 32GB SSD, 9700 | 20" Alu Cinema Display
PowerMac G4 2x 1.42GHz | PowerMac G5 2x 2.3GHz | HTC One 32GB | Canon EOS 500D
Goftrey is offline   0 Reply With Quote
Old Aug 23, 2013, 08:25 PM   #5
chown33
macrumors 603
 
Join Date: Aug 2009
Quote:
Originally Posted by Goftrey View Post
If you want search terms, then here's just a few;
PackageMaker AppleScript
Add Terminal Command PackageMaker
Post Install Script PackageMaker

There's about 2 dozen of those types of searches with the words played around with, amounting to the same results. I've looked in the Apple Support forums, and decided to post here before going there. As the experiences I've found on that site have are, well - not helpful to say the least.
What were these "same results"? Why were they unsatisfactory? Here's an example of what I'm looking for in your answer.

I googled packagemaker script. The top result was this article on Stack Overflow:
http://stackoverflow.com/questions/6...ipt-on-install

In that article, it says this (among other answers):
postinstall / postupgrade: This script is launched after the files in the package have been installed. See (preinstall / preupgrade) to see which one is launched.

postflight: This script is launched after the postinstall / postupgrade script or when the package has been installed.
To me, this seems to clearly identify three possible scripts that could be used to run a post-install, a post-upgrade, or a post-flight series of scripted actions. There are also links to other articles that explain exactly which of these scripts is run in which circumstances. The google results also have other articles, some on Stack Overflow and some on other sites.

To me, those three possible scripts cover exactly what you want to do: perform some actions after the main install has completed. So my question at this point is this: Why are those three possible scripted actions unsatisfactory?

Is it because you don't know which script is run when? The links to articles explaining packagemaker scripts would likely explain that.

Is it because you can't figure out how to tell packagemaker to use your script as the postflight script (or whatever position you choose to run your script in)?

Did you try any experiments? E.g. making a simple script, adding it to the package being built, and then test it simply to see what happens? For example, a script that uses the 'say' command to speak a distinct word, such as 'say post flight' in the postflight script?

In other words, I can't figure out exactly where the problem is. Are you stuck because you don't understand packagemaker scripts? Are you stuck because you don't know how to tell packagemaker to add a script?

Exactly what is unsatisfactory?


Quote:
I'm pretty new to pretty anything terminal based so go easy on me!
And you're learning these commands using what resource? A book? A tutorial? Random searches?


Quote:
I'm creating the installer individually for each version of OS X (as they use different icons in different places & use different formats in some cases). I'm supporting OS X 10.4 Tiger through OS X 10.9 Mavericks (when's it let loose).
Using the same version of packagemaker? Which would be what?

If it seems like I'm asking a lot of questions, it's because details can be important.
http://www.mikeash.com/getting_answers.html


Quote:
So onto the admin quote - you're saying that as long as admin auth. is ticked (as it already is) the commands will execute straight off the bat?
Have you tried something to see what happens? If not, do so, take careful notes, and post the results. If you're leery of damaging something, then use placeholder actions like 'say some text' to speak things, and see what it says.

I'll also suggest the 'id' command, which will output the current user id. I assume you already know how to read its man page (and what a man page is).

Some things are best learned by discovery, not least because you'll remember them better if you plot your own course and actually find out what works and what doesn't. You'll also probably learn more about what's really happening, rather than going by rote.

I find that the process of mapping out a systematic approach not only gives me a better idea of what to do and what to expect, it also gives me ideas of how to avoid making foolish mistakes, such as by using placeholders instead of actual 'rm' commands (or in addition to them).
chown33 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Tags
applescript, packagemager, postinstall, scripts, theme

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
disable sleep but turn off the display using command or script? appleluck iMac 10 Dec 30, 2013 09:14 AM
Need help on PackageMaker knb Mac Programming 0 Jun 9, 2013 12:03 AM
Can't find the script for purge command timer! DukeOfMapleton Mac Basics and Help 2 Apr 5, 2013 11:25 AM
Adding terminal command on start-up, Lion OSX Vegbrain Mac Applications and Mac App Store 18 Mar 19, 2013 02:33 AM
Issue with Packagemaker Installer on OS 10.8 arunsm OS X 10.8 Mountain Lion 0 Jul 10, 2012 07:04 AM

Forum Jump

All times are GMT -5. The time now is 03:01 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC