Munki command-line tools in Swift

161 views
Skip to first unread message

Gregory Neagle

unread,
Jul 1, 2024, 12:19:52 PMJul 1
to munki-dev
A beginning of an exploration into porting the Munki command-line tools to Swift is here:


This is a work-in-progress, and is not a commitment that all of the command-line tools will be ported to Swift.

Currently, makecatalogs is functional. FileRepo and GitFileRepo are supported; no other repo plugins are supported.

Do not test the makecatalogs tool from this project against a production Munki repo unless you have a backup!

-Greg

Alan

unread,
Jul 1, 2024, 12:35:12 PMJul 1
to munk...@googlegroups.com
This is great, Greg!

Are there any concerns that if makecatalogs is in Swift, it won't run with certain CI/CD pipelines that use Linux (and thus can leverage Python)? Or is the idea that the makecatalogs logic won't really change drastically across versions, and so Linux could just run an older version of makecatalogs, even if manual runs will typically happen on macOS?

--
Find related discussion groups here:
https://github.com/munki/munki/wiki/Discussion-Group
---
You received this message because you are subscribed to the Google Groups "munki-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to munki-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/munki-dev/4110AC1D-EFFF-4BD1-8273-06E02BD19A2E%40mac.com.

Gregory Neagle

unread,
Jul 1, 2024, 12:53:52 PMJul 1
to munki-dev
I think we’ll need to maintain a (simplified, maybe) Python version of makecatalogs for use in alternate scenarios such as this. The Python version of makecatalogs has not changed much in years.

Alan

unread,
Jul 1, 2024, 1:00:57 PMJul 1
to munk...@googlegroups.com
Sounds good! I can't think of any other weird edge cases like that, but maybe someone else will pipe up about another.

Nate Walck

unread,
Jul 1, 2024, 1:01:55 PMJul 1
to munk...@googlegroups.com
I believe it’s possible to compile binaries for Linux, but I’ve never tried that. Something to look into as this is a very good point. 

Nate

Jim Zajkowski

unread,
Jul 1, 2024, 4:10:53 PMJul 1
to munk...@googlegroups.com
I was able to get makecatalogs cross-compiled to x86-64-linux:

Swift-on-Linux works with SwiftPM and not Xcodeproj. I was able to make a Package.swift for makecatalogs, and got it compiling to macOS successfully.

Then I switched to the Linux SDK and:

a) CryptoKit doesn’t exist, so I used tayloraswift/swift-hash for SHA256 icon hashing.

b) NetFS doesn’t exist, so FileRepo.swift needed some munging. I just bypassed GitFileRepo for this POC.

c) CFString isn’t present, so a few CFStrings needed handling. The adminPref() call can be bypassed (CFPreferences also not a thing) and prefs.swift not included in the source list, that cuts down a large number of issues.

d) A few other minor changes that are probably more Swift 6 / Foundation changes...

and I have a binary that actually worked on my Linux package server, generating catalogs and icon hashes!

I can submit this as a PR with some cleaning. I don’t know if this is the stage you’re looking for such things or not.

—Jim


--
Jim Zajkowski
MiWorkspace DevOps Architect & Mac Platform Lead
University of Michigan



Reply all
Reply to author
Forward
0 new messages