autopkg / n8felton-recipes

Recipes for Autopkg
28 stars 35 forks source link

KeePassXC.munki ARM64 override keeps insisting download exists which doesn't #196

Open fseesink opened 6 months ago

fseesink commented 6 months ago

I believe this is one of those cases where if you create 2 overrides of a .munki recipe, one for the x86_64 and another for the arm64 version of the app, the second one that runs sees the first one's download as matching what the second one has pulled down, but not sure.

So I have had a Munki setup for awhile now. I leverage AutoPkgr and MunkiAdmin in my setup. But for reasons I'm not 100% sure of, this recipe is giving me no end of grief.

First, some basics. I used this recipe and, as mentioned, created 2 overrides. I adjusted the settings as needed for each; e.g., changing the name of each, adjusting the arch, etc. (And this is something I have done with various recipes, as I now have both Intel and Apple Silicon Macs that I support).

To test, as usual, from Terminal I then first ran the override for the x86_64 version autopkg run -vv KeePassXC.munki. The output indicated that it pulled down the appropriate file and placed it in the repo. I checked and found the .dmg and pkgsinfo .plist file in the expected location.

Next I did the same for the second override, running autopkg run -vv KeePassXC-arm64.munki. It also ran but it indicated in its output the following:

...
MunkiImporter: Item KeePassXC-2.7.6-arm64.dmg already exists in the munki repo as pkgs/Applications/Tools/KeePassXC.arm64/KeePassXC-2.7.6-arm64-2.7.6__1.dmg.
{'Output': {'pkg_repo_path': '/Users/Shared/munki/pkgs/Applications/Tools/KeePassXC.arm64/KeePassXC-2.7.6-arm64-2.7.6__1.dmg'}}
Receipt written to /Users/frank/Library/AutoPkg/Cache/local.munki.KeePassXC-arm64/receipts/KeePassXC-arm64.munki-receipt-20240309-160247.plist

The following new items were downloaded:
    Download Path                                                                                       
    -------------                                                                                       
    /Users/frank/Library/AutoPkg/Cache/local.munki.KeePassXC-arm64/downloads/KeePassXC-2.7.6-arm64.dmg 

Now no such file /Users/Shared/munki/pkgs/Applications/Tools/KeePassXC.arm64/KeePassXC-2.7.6-arm64-2.7.6__1.dmg exists.

Now mind you, when this occurred, I went in and deleted all references to KeePassXC from both the munki repo itself as well as the AutoPkg cache. But any time I re-ran these, I got the same results.

Now I believe this may be due to something I have run into in the past. It seems that MunkiImporter somehow sees the x64 version as matching the arm64 version. It's been awhile so I'm a bit rusty on why that is. But there's a whole sequence MunkiImporter runs through to ascertain whether an installer already exists in the repo. But it's clearly incorrect, and I'm wondering if there's a way to fix this.

Another oddity about this recipe is that, unlike most I run, for reasons I can't quite understand, when I use MunkiAdmin, it does NOT show this app at all in the list. My understanding is that MunkiAdmin, upon initial launch, loads up the munki repo info and builds its list of apps, catalogs, etc. So here again I am at a loss as to why KeePassXC doesn't show. This one is truly unique to this recipe.

fseesink commented 6 months ago

Ok, now I am thoroughly confused. I reset things once again, removing any reference to KeePassXC from my munki repo as well as removing all the relevant AutoPkg cache files/directories. I then ran autopkg run -vv KeePassXC-arm64.munki FIRST, figuring this would now download and that when I ran the second command for the x86 version, that one would fail to import.

But NO! In fact, I got the EXACT.SAME.MESSAGE as before!

...
MunkiImporter: Item KeePassXC-2.7.6-arm64.dmg already exists in the munki repo as pkgs/Applications/Tools/KeePassXC.arm64/KeePassXC-2.7.6-arm64-2.7.6__1.dmg.
{'Output': {'pkg_repo_path': '/Users/Shared/munki/pkgs/Applications/Tools/KeePassXC.arm64/KeePassXC-2.7.6-arm64-2.7.6__1.dmg'}}
Receipt written to /Users/frank/Library/AutoPkg/Cache/local.munki.KeePassXC-arm64/receipts/KeePassXC-arm64.munki-receipt-20240309-162104.plist

The following new items were downloaded:
    Download Path                                                                                       
    -------------                                                                                       
    /Users/frank/Library/AutoPkg/Cache/local.munki.KeePassXC-arm64/downloads/KeePassXC-2.7.6-arm64.dmg  

???

What is AutoPkg matching against?!? I can't figure this one out. There is NO KeePassXC file of ANY kind in the repo nor in the AutoPkg cache.

This one is a real head scratcher for me. If you have any idea where I need to look for this, I am all ears.

n8felton commented 6 months ago

I probably won't have time to look at this until Monday, but it would be helpful if you could attach your full override files to help troubleshoot.

chelming commented 6 months ago

are you sure makecatalogs is running 👀

fseesink commented 6 months ago

Actually, was just going to write that for part of this, I'm an idiot. I forgot after removing all vestiges of KeePassXC to run makecatalogs on the repo. So yes, that fixed the download part.

However, the one thing I still can't figure out is why neither package, even though AutoPkg indicates now that it downloaded and added them to the munki repo, show up in MunkiAdmin. I have not had that issue before.

fseesink commented 6 months ago

Found the issue.

So in your .munki recipe, you have

...
                        <key>supported_architectures</key>
                        <string>%SUPPORTED_ARCH%</string>
...

This appears to be incorrect. I checked this against various other recipes I have, and looks like it should be an <array> as follows:

...
            <key>supported_architectures</key>
            <array>
                <string>%SUPPORTED_ARCH%</string>
            </array>
...

As soon as I made that adjustment, everything popped in MunkiAdmin as I'd expect.

Oh, while on the subject, also note I had to make another adjustment (had done this earlier so only now remembered in light of this). Earlier in the same recipe, you have

                <key>SUPPORTED_ARCH</key>
                <string>x64</string> <!-- or arm64-->

Again, this is incorrect. It should be

                <key>SUPPORTED_ARCH</key>
                <string>x86_64</string> <!-- or arm64-->

I had made that change already as when I saw it, I thought, "Wait, the supported_architectures attribute is rather specific about what it takes." And then I went looking. And yep, it needs to be x86_64, not simply x64, for the Intel binary, as shown here. Just FYI.

fseesink commented 6 months ago

With those tweaks, everything works now. So thanks for the recipe. This was one of the apps I had left to add to my repo. So I'm glad I was able to get that working.