How do I create a .pkg that copies file folder to ~/Library/Preferences

jagstang94
New Contributor II

I'm very new to scripting and packaging, so go easy on me 😉

I'm wanting to create a .pkg that copies a file folder containing specific user app settings (payload) to ~/Library/Preferences. I've been scouring the web for tips on how to accomplish this via Jamf Composer, pkgbuild, and Packages, but have so far been unsuccessful with doing this on my own.

Each time I get an Installer error: The package is trying to install content to the system volume. Contact the software manufacturer for assistance.

The .pkg is signed using Jamf Composer, I'm using Jamf Pro to deploy the .pkg as a Policy. It fails regardless of installing it locally or using Jamf Pro. Target computers are a mix of Catalina and Big Sur OS.

Is this even possible? If so, what am I missing?

1 ACCEPTED SOLUTION

easyedc
Valued Contributor II

So there should be some scripting involved with something like this.  I've generally solved this by placing my config file in somewhere like 

/private/var/tmp/com.test.fil.plist

and a post install script or add a script to the deployment policy and give it an after run. A script would look something like this

#!/bin/zsh

#  script.sh
#  
## Get the user
MyUser=$( /usr/bin/stat -f "%Su" /dev/console )

## Heavy lifting
mv /path/to/file/com.test.fil.plist /Users/$MyUser/Library/Preferences

## Give it to the user
chown $MyUser /Users/$MyUser/Library/Preferences/com.test.fil.plist

## Confirm it's set right
chmod 600 /Users/$MyUser/Library/Preferences/com.test.fil.plist

exit 0

But if this is a setting you want to enforce, you may look at writing your own .plist file and pushing that as a configuration profile to the user. 

View solution in original post

5 REPLIES 5

easyedc
Valued Contributor II

So there should be some scripting involved with something like this.  I've generally solved this by placing my config file in somewhere like 

/private/var/tmp/com.test.fil.plist

and a post install script or add a script to the deployment policy and give it an after run. A script would look something like this

#!/bin/zsh

#  script.sh
#  
## Get the user
MyUser=$( /usr/bin/stat -f "%Su" /dev/console )

## Heavy lifting
mv /path/to/file/com.test.fil.plist /Users/$MyUser/Library/Preferences

## Give it to the user
chown $MyUser /Users/$MyUser/Library/Preferences/com.test.fil.plist

## Confirm it's set right
chmod 600 /Users/$MyUser/Library/Preferences/com.test.fil.plist

exit 0

But if this is a setting you want to enforce, you may look at writing your own .plist file and pushing that as a configuration profile to the user. 

jagstang94
New Contributor II

I ended up having to piecemeal this script suggestion with some other scripting, and it works perfectly now. Thanks for the insight about the config profile as well. I'm going to save that project for later on down the line.

Tribruin
Valued Contributor II

How are you building your package? You can't use relative paths ~/path/to/user in a standard package. You would need to specify the complete path. You could, in Composer, build as a DMG and use FUT/FEU to put these files in each user's ~/Library/Preferences. 

 

But, what are you trying to install in the user's preference folder? Are you just trying to set defaults that the user can change? Or do you need to force the settings on the user. If the latter, you might want to look at using Managed Preferences (through a Config profile) pushed from Jamf instead. 

jagstang94
New Contributor II

To be more specific, I'm building an SAP GUI for macOS .pkg and trying to include the SAPGUILandscape.xml file that displays our corp logon pad. The installation of the SAP GUI app itself works great, but can't seem to figure out how to include the .xml file in the payload when the .pkg runs. Copying the .xml locally works perfectly, but trying to automate this as much as possible.

 

I had the idea to create a separate .pkg containing the .xml file, then somehow script it to copy the file to ~/Library/Preferences/SAP. If it worked, I'd create a Jamf policy, then scope to an "SAPGUI" smart group. Didn't work, so I'm back to the drawing board with how to accomplish this.

easyedc
Valued Contributor II

if you're working with an .xml file then I suspect the intention is to load that via a configuration profile to enforce those settings.  you would format it as a property list, and assign it to the com.org.whatever you're trying to manage. 

 Screen Shot 2021-07-27 at 7.50.33 AM.png