Package that includes a script, a .pkg, and dripping a .cfg file

gspiese
New Contributor III

I want to create a self-contained Package that does the following in this order:

1)Run a script that deletes unneeded files;
2)Runs a separate .pkg;
3)Places a modified mms.cfg file into /Library/Application Support/Macromedia

I have placed these items in Composer, converted the .pkg to source. In composer I see all three items under Sources but I don't see where I can tell it to order these items (run the script, run the .pkg, then drop the file where I want it). How do I order the items and make a single .pkg file so I can deploy as a self-contained package? Or, is there a better way to do what I want?

I plan to deploy the final package with a Policy or Casper Remote.

I read the Admin Guide/Composer, searched the Discussions, and KB articles but don't see anything that details the steps needed to accomplish this.

1 ACCEPTED SOLUTION

gspiese
New Contributor III

First, I appologize for the title... it's not dripping! I meant DROPPING

With the help of so many Nationer's I can't thank everyone, but thanks everyone! I did ake this Q of lis tot he apple-installer-dev list and after discussions there moed from PackageMaker back to Casper Composer. I just want to try to use the tool-set that Casper provides if at all posible. Creating the pkg that did all that I wanted:

•Deleted unneeded files from a previously poorly designed dmg installer;
•Installing Flash Player "Plugin" that incuded the first SUS Daemon fpsaud
•Revised the fpsaud fonfig file mms.cfg to turn off the automatic and silent updates of future FP

Just learning to do those theree exposed me to most of the basic tools used to make pkg file sfor Casper Deployment. I've written an internal How do Doc that's too lenghty (and ha screen shots) to post here. But I did want to give a quick start wuide for any newbies that might find this a helpfuld post for helping grasp to tool and how it likes things presented so it does what you want. Here is te qick start, and please correct me or add to this as you see it fitting:

1) Double-Click the Flash Player .dmg file

2) Right-Click the Installer Icon and select “Show Package Contents”

3) Expand the Contents folder then the Resources folder and drag the Adobe Flash Player.pkg file to where you want it.

4) Launch Casper Composer and drag the Adobe Flash Player.pkg (from step #3 above) into the left pane of Composer. It will appear under the heading “PACKAGES”

5) Click on the Adobe Flash Player.pkg in the left pane and on the right will be an option in the right pane to Convert to Source. Click the Convert to Source button.

6) The Package is converted to Source and appears under the SOURCES heading in the left pane.

7) Next, we want to place one file onto the Macs that the package runs to. That file is the mms.cfg file that we changed to the settings we want instead of the default settings. To tell Composer where you want the file to be placed, click on the name of the SOURCES file in the left pane. You will now see a folder named Library in the right pane. We want to add a new directory path to where we want the file placed then place it there in Composer.

8) Click the triangle to the left of the Library folder to expand it. Since we want to place our mms.cfg file into Library/Application Support/Macromedia and there is already a Library folder with an Application Support folder in it we only need to create the missing Macromedia folder inside the Application Support folder then place the mms.cfg file in that folder.

To create the Macromedia folder exand the Application Support folder and right-click on the name “Application Support” and select Create New Directory. A new Untitled Folder appears, just type the name you want it to be. In this case “Macromedia”, then hit Enter on your keyboard. Find the file mms.cfg on your computer and drag it on top of the Macromedia folder and Composer places it there.

9) Finally, we want to place our script into the package we are creating in Composer. The script deletes files that were incorrectly placed when the previous version of the Flash Player Installer ran. We want the files to be deleted before the new Flash Player plugin gets installed. We then want to run the script as a PREFLIGHT Script. To Create a place to put our preflight script, in Composer ‘s left pane, expand the triangle to the left of our Source file. Doing so reveals three folders: Scripts; Settings; Snapshots. Expand the Scripts folder and you’ll see a postflight script already there. To create a preflight script, right-click (or Command-click) the Scripts folder and select Add Shell Script then select preflight.

10) Click on the preflight script in the left pane. Look at the script that was automatically created in the right pane. Since we want to use our own script, select the text as shown in figure X and delete it. Now using a text editor open the script you created and copy the script and paste it into the area where you deleted the text in the preflight script of Composer.

11) Figure X shows the preflight script with our script in it. To save your script you must fo to Composer’s Main Menu and select File/save (Command-S). If you click anywhere else before saving, then your script will not be saved and you’ll need to repeat step #10, then remember to SAVE before clicking on anything else.

12) We have all our elements in the Source file of Composer and are ready to Build the Package that will be sent to each computer that needs the update. Click the triangle to the left of the Source file in Composer to collapse all the folders under it, and click the source file. With the source file selected, click the Build as PKG icon in the upper part of the Composer window.

13) You will be presented with a dialog box asking where you want to save the PKG file that’s about to be created. Navigate to where you want it save and click Save.

14) When the Unsupported scripts for flat packages warning appears, click the Build as Non-flat PKG button. Your PKG file is saved in the location you indicated.

15) Your PKG file is now ready for testing and eventual deployment.

View solution in original post

8 REPLIES 8

justinrummel
Contributor III

You want to run your script as a preflight script
external image link

You can add your mms.cfg as a second package, then have your policy install both pkg files.

- Justin

rockpapergoat
Contributor III

here's how i do all that with one pkg:

https://gist.github.com/2938089

requires installing dev tools and luggage. every mac admin should get acquainted with both.

mm2270
Legendary Contributor III

Add a Preinstall script into the Composer source.

1- Turn down the disclosure arrow on your source in Composer, right click on Scripts and choose "Add Shell Script" or "Add Perl Script" (whichever you're more comfortable with) and choose Preinstall from the menu.

2-Copy/paste your script content into the newly created script that now shows up. Make sure to double check everything (i.e, that you don't have 2 shebangs)

3- (Optionally) you can add a line in your preinstall script that would run your second package install after it does the cleanup/delete stuff, provided the target pkg exists on the system.

4- Your dropped item can just be part of the regular Composer pkg and it should drop it in the same path when the install runs.

You have to build this all as a .pkg format, since scripts aren't supported in DMG.

gspiese
New Contributor III

@mm2270 As you suggested I pasted my Script in the Scripts Directory of the pkg file I converted to source. But am not sure what you mean by:

Your dropped item can just be part of the regular Composer pkg and it should drop it in the same path when the install runs.

Where to I place the file so it's part of the same single package? The Snapshots Directly shows paths to files that the main .pkg will place but I don't see where I can place an additional item.

My goal is to make this payload a single .pkg file, if that's at all possible.

gspiese
New Contributor III

What's confusing to me is that in Composer when I look at the Snapshots Directory there is a file named Files For Package. In there it's got paths to files on my computer. Is that where Composer is going to go to get the files the package will install? I don't want it to do that. Instead I want it to install the items in the Adobe Package. Because what's on my Mac isn't the same version as what I want installed. It also has paths to files in my Users Directory, and again I don't want files from my computer placed in the package.

I prefer to manually build the .pkg file a preinstall script then an application.pkg, finally any config or other files I want placed in directories I specify. Is this not possible with Composer? It looks like a tool better for snapshotting, which isn't how I want to build my pakage in this case.

I want to try to use only Casper's tools to create the self contained package, and at least for now no third party tools... am I expecting Casper to do too much?

donmontalvo
Esteemed Contributor II

Ya, I'm not a fan of Casper Composer. Sorry JAMF...but it's really weak (heck, we've been asking for HW/SW check popups for some time now). I would use PackageMaker...it's mature and the right tool for PKG/MPKG format packages. Use Composer when you need to make DMG (we never ever do).

The list to bounce questions off of is Installer-Dev where all the Mac Packaging experts hang out.

https://lists.apple.com/mailman/listinfo/installer-dev

Apple have been working on their online documentation, you'll find PackageMaker documentation is pretty good:

http://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/PackageMakerUserGuid...

If the PKG you're deploying is the Adobe Flash Player PKG (extracted from Apple's silly installer application), I wouldn't suggest editing it since ya never know what might break.

That said, MPKG is a possibility. Using PackageMaker, create an MPKG and bring the PKG into it...then pull the other stuff. MPKG can be pushed just like PKG. As far as scripting goes, go with shell script (unless you're a Perl expert!)...easy enough to create scripts that find/kill process, remove old apps, etc.

Don

--
https://donmontalvo.com

mm2270
Legendary Contributor III

George, sorry for the delayed response. This thread dropped onto pg 2 so I didn't see it until just now.

Composer is best used for capturing files/folders that either have been installed, or you are installing on your Mac when building the package. If you want to have it use some other versions of files not present on your Mac, you'll have a harder time making a usable package. I'm not entirely clear what you're trying to achieve though. You say you want it to "install the items in the Adobe Package" Which Adobe package would that be? I think if you help to clarify what you're really aiming for it would help all of us to help you come up with a solution. You may need to get a little creative, but there's a possibility you can do what you're looking for with Composer.

gspiese
New Contributor III

First, I appologize for the title... it's not dripping! I meant DROPPING

With the help of so many Nationer's I can't thank everyone, but thanks everyone! I did ake this Q of lis tot he apple-installer-dev list and after discussions there moed from PackageMaker back to Casper Composer. I just want to try to use the tool-set that Casper provides if at all posible. Creating the pkg that did all that I wanted:

•Deleted unneeded files from a previously poorly designed dmg installer;
•Installing Flash Player "Plugin" that incuded the first SUS Daemon fpsaud
•Revised the fpsaud fonfig file mms.cfg to turn off the automatic and silent updates of future FP

Just learning to do those theree exposed me to most of the basic tools used to make pkg file sfor Casper Deployment. I've written an internal How do Doc that's too lenghty (and ha screen shots) to post here. But I did want to give a quick start wuide for any newbies that might find this a helpfuld post for helping grasp to tool and how it likes things presented so it does what you want. Here is te qick start, and please correct me or add to this as you see it fitting:

1) Double-Click the Flash Player .dmg file

2) Right-Click the Installer Icon and select “Show Package Contents”

3) Expand the Contents folder then the Resources folder and drag the Adobe Flash Player.pkg file to where you want it.

4) Launch Casper Composer and drag the Adobe Flash Player.pkg (from step #3 above) into the left pane of Composer. It will appear under the heading “PACKAGES”

5) Click on the Adobe Flash Player.pkg in the left pane and on the right will be an option in the right pane to Convert to Source. Click the Convert to Source button.

6) The Package is converted to Source and appears under the SOURCES heading in the left pane.

7) Next, we want to place one file onto the Macs that the package runs to. That file is the mms.cfg file that we changed to the settings we want instead of the default settings. To tell Composer where you want the file to be placed, click on the name of the SOURCES file in the left pane. You will now see a folder named Library in the right pane. We want to add a new directory path to where we want the file placed then place it there in Composer.

8) Click the triangle to the left of the Library folder to expand it. Since we want to place our mms.cfg file into Library/Application Support/Macromedia and there is already a Library folder with an Application Support folder in it we only need to create the missing Macromedia folder inside the Application Support folder then place the mms.cfg file in that folder.

To create the Macromedia folder exand the Application Support folder and right-click on the name “Application Support” and select Create New Directory. A new Untitled Folder appears, just type the name you want it to be. In this case “Macromedia”, then hit Enter on your keyboard. Find the file mms.cfg on your computer and drag it on top of the Macromedia folder and Composer places it there.

9) Finally, we want to place our script into the package we are creating in Composer. The script deletes files that were incorrectly placed when the previous version of the Flash Player Installer ran. We want the files to be deleted before the new Flash Player plugin gets installed. We then want to run the script as a PREFLIGHT Script. To Create a place to put our preflight script, in Composer ‘s left pane, expand the triangle to the left of our Source file. Doing so reveals three folders: Scripts; Settings; Snapshots. Expand the Scripts folder and you’ll see a postflight script already there. To create a preflight script, right-click (or Command-click) the Scripts folder and select Add Shell Script then select preflight.

10) Click on the preflight script in the left pane. Look at the script that was automatically created in the right pane. Since we want to use our own script, select the text as shown in figure X and delete it. Now using a text editor open the script you created and copy the script and paste it into the area where you deleted the text in the preflight script of Composer.

11) Figure X shows the preflight script with our script in it. To save your script you must fo to Composer’s Main Menu and select File/save (Command-S). If you click anywhere else before saving, then your script will not be saved and you’ll need to repeat step #10, then remember to SAVE before clicking on anything else.

12) We have all our elements in the Source file of Composer and are ready to Build the Package that will be sent to each computer that needs the update. Click the triangle to the left of the Source file in Composer to collapse all the folders under it, and click the source file. With the source file selected, click the Build as PKG icon in the upper part of the Composer window.

13) You will be presented with a dialog box asking where you want to save the PKG file that’s about to be created. Navigate to where you want it save and click Save.

14) When the Unsupported scripts for flat packages warning appears, click the Build as Non-flat PKG button. Your PKG file is saved in the location you indicated.

15) Your PKG file is now ready for testing and eventual deployment.