Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

munkipkg --sync error with empty payload directory #57

Open
ProjectTermina opened this issue Nov 19, 2021 · 3 comments
Open

munkipkg --sync error with empty payload directory #57

ProjectTermina opened this issue Nov 19, 2021 · 3 comments

Comments

@ProjectTermina
Copy link

I am trying to use the --export-bom-info and --sync workflow described in the munkipkg documentation in order to track pseudo-payload-free munkipkg projects using git. My version of munkipkg is 0.8 and my version of Mac OS is 12.0.1. I have a project with a postinstall script and an empty payload directory. My working directory is the project directory. I run "munkipkg --export-bom-info ." to build the current directory. Output:

pkgbuild: Inferring bundle components from contents of ./payload
pkgbuild: Writing new component property list to /var/folders/q2/9hr7dsmj6rbbgm_b3373kxghw9630x/T/tmp3e8Gml/component.plist
pkgbuild: Reading components from /var/folders/q2/9hr7dsmj6rbbgm_b3373kxghw9630x/T/tmp3e8Gml/component.plist
pkgbuild: Adding top-level postinstall script
pkgbuild: Wrote package to ./build/PROJECTNAME-1.0.pkg
munkipkg: Extracting bom file from ./build/PROJECTNAME-1.0.pkg
munkipkg: Exporting bom info to ./Bom.txt

Bom.txt contains one line:

.\t40755\t0/0\n

Then, I clone the git repo that contains this project. As expected, the cloned project is missing the payload directory. From within the cloned munkipkg project directory, I run "munkipkg --sync ." Output:

munkipkg: Creating ./payload/. with mode 0755
ERROR: [Errno 2] No such file or directory: './payload/.'

The payload directory is not recreated.

On line 392, payload_path is set to "./payload/." When that directory is found to not exist on line 403, line 417 attempts to create it by running "mkdir ./payload/.". This throws an error because the parent directory of payload/., payload, does not exist. It sounds stupid, but it is technically true. This can be fixed by adding the -p flag to the mkdir command, which causes it to create intermediate parent directories as needed. The end result is that ./payload is created, then nothing happens when ./payload/. is created. Success!

@ProjectTermina
Copy link
Author

created pull request #58

@gregneagle
Copy link
Contributor

This is interesting but I wonder why you even feel the need to run —sync when there is no payload!

@ProjectTermina
Copy link
Author

This section from README.md describes my use case:

If the payload folder exists, but is empty, you'll get a "pseudo-payload-free" package. No files will be installed, but a receipt will be left. This is often the more useful option if you need to track if the package has been installed on machines you manage.

The problem is, because I am using git, which does not track empty directories, when I clone the project it doesn't have a payload directory. No big deal, here is what README.md says to do in this situation:

The solution to this problem is the Bom.txt file, which lists all the files and directories in the package, along with their mode, owner and group.

After doing a git clone or git pull operation, you can then use munkipkg --sync project_name to cause munkipkg to read the Bom.txt file and use the info within to create any missing directories and to set file and directory modes to those recorded in the bom.

I tried to go this route because it is what the readme prescribed, and because hey, it might be useful if this package ever does have a payload. Because the code as is does not do what the documentation says it does in this situation, I submitted this issue and pull request.

Running "mkdir payload" after cloning my projects is also an option. Another nice solution would be if I could specify in the build-info that the project does not have a payload, but should leave a receipt anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants