And because you need to use a newer Xcode and Swift 5 to notarize the tool, it now requires the Swift 5 Runtime support for command line tools when you install it on versions of macOS older than 10.14.4. (On those older versions, you can also continue to use desktoppr-0.1)
Once again, I had the honor to present at MacSysAdmin in Gothenburg. My topic this year was “Moving to zsh.”
I have created a supporting page with a link to the Keynote slide deck and all the other links and notes. Once the session video is up, I will add the link there as well.
The release notes for Catalina also tell us that other built-in scripting runtimes, namely Python, Perl, and Ruby. Will not be included in future macOS releases (post-Catalina) any more.
This means, that if you want to use bash, Python, Perl, or Ruby on macOS, you will have to install, and maintain your own version in the future.
However, scripts in installation packages, cannot rely on any of these interpreters being available in future, post-Catalina versions of macOS. Installer pkgs can be run in all kinds of environments and at all times, and you would not want them to fail, because a dependency is missing.
The good news is that we still have time. All the runtimes mentioned above are still present in Catalina, so the packages will continue to work for now. But if you are building installation scripts, you need to check if any of the installation scripts use one of these interpreters and fix them.
I recommend to use /bin/sh for installation scripts, since that will run in any macOS context, even the Recovery system.
If you are using third-party installer packages, you may also want to check them for these interpreters, and notify the developer that these packages will break in future versions of macOS.
To check a flat installer package, you would expand it with pkgutil --expand and then look at script files in the Scripts folder. This will work fine for a package or two, but gets tedious really quickly, especially with large distribution pkgs with many components (e.g. Office).
So… I wrote a script to do it. The script should handle normal component pkgs, distribution pkgs and the legacy bundle pkgs and mpkgs.
Once I had written the code to inspect all these types of pkgs, I realized I could grab all other kinds of information, as well. The pkgcheck.sh script will check for:
Signature and Notarization
Type of Package: Component, Distribution, legacy bundle or mpkg
Identifier and version (when present)
Install-location
for Distribution and mpkg types, shows the information for all components as well
for every script in a pkg or component, checks the first line of the script for shebangs of the deprecated interpreters (/bin/bash, /usr/bin/python, /usr/bin/perl, and /usr/bin/ruby) and print a warning when found
How to run pkgcheck.sh
Run the script with the target pkg file as an argument:
% ./pkgcheck.sh sample.pkg
You can give more than one file:
% ./pkgcheck.sh file1.pkg file2.pkg ...
When you pass a directory, pkgcheck.sh will recursively search for all files or bundle directories with the pkg or mpkg extension in that directory:
% ./pkgcheck.sh SamplePkgs
Features and Errors
There are a few more things that I think might be useful to check in this script. Most of all, I want to add an indicator whether a component is enabled by default or not. If you can think of any other valuable data to display, let me know. (Issue or Pull Request or just ping me on MacAdmins Slack)
I have tested the script against many pkgs that I came across. However, there are likely edge cases that I haven’t anticipated, which might break the script. If you run into any of those, let me know. (File an Issue or Pull Request.) Having the troublesome pkg would of course be a great help.
Note: the script will create a scratch directory for temporary file extractions. The script doesn’t actually expand the entire pkg file, only the Scripts sub-archive. The scratch folder will be cleaned out at the beginning of the next run, but not when the script ends, as you might want to do some further inspections.
Sample outputs
This is a sample pkg I build in my book, it has pre- and postinstall scripts using a /bin/bash shebang:
Still a lot of fallout from the Zoom invulnerability. It took Apple three updates to MRT (so far) to eradicate all the differently branded varieties of the Zoom client web server. Makes me wonder how many Macs there were or are with multiple of these clients installed.
We also got new betas for 10.14.5 and 10.15 and the respective iOS versions. Some of the worst data-destroying bugs seem to be fixed or at least mitigated but I am still not comfortable moving my production devices to the betas. That’s what test devices are there for. I am getting quite excited about some of the features I have seen, both for end-users and administrators.
One of those features is that zsh will become the default shell for macOS. If you want to know what that means, how to transfer your shell configuration, workflows, and scripts from bash to zsh, and increase your Terminal productivity, we are doing a half-day training in Amsterdam on September 6. You can get more details and sign up on our webpage!
Daniel Jalkut: “Apple fixed a niggling little AppleScript problem in macOS Catalina beta 4. It’s reassuring to me that they bothered to address this. Thanks!”
Jonathan Grynspan: “macOS Catalina Seed 4: Finder’s Open With menu has been rebuilt from scratch. You should never again see ”Fetching…“! Although in normal usage this should not impact you, if you do notice issues with the Open With menu, please file bug reports!”
There are no ads on my webpage or this newsletter. If you are enjoying what you are reading here, please spread the word and recommend it to another Mac Admin!
If you want to support me and this website even further, then consider buying one (or all) of my books. It’s like a subscription fee, but you also get a useful book or two extra!
Typography is a wonderful art and has a long history. When humans turned from manual typesetting to machines, type writers and then computers, some compromises had to be made. One of these compromises was to use simple straight quote symbols for opening and closing the quote, rather than different quote symbols for opening and closing.
Note: which kind of quotes are used for opening and closing dependent on the language or and some convention. English uses upper quotes “…”, German opens with a lower quote: „…“, French uses ‘guillemets:’ «…», and Japanese uses hooks: 「…」
Quotation Marks have funny names in many languages. Germans call them “Gänsefüßchen,” or “little goose feet.”
macOS, iOS and other modern operating systems have a feature which replaces the simple or straight quote symbols with the typographic quotes. So, you type "Hello!" and the quotes are automatically replaced with the proper (depending on localization) typographic quotes. This is called “smart quotes.”
This is pretty nice, but can be troublesome when dealing with Terminal and text editors. Scripting languages and shells always use straight quotes, and cannot deal with typographic quotes.
Now, if someone sends you a command or a script that uses quotes, and it goes through an app that replaces them with smart quotes, then bash and Terminal will fail miserably.
There is not much you can do, other than be aware of this and check pasted code carefully. There is something you can do to make this easier, though.
The default monospace font used in Terminal on macOS are ‘Menlo’ or ‘SF Mono,’ depending on the macOS version. Now these are fine typefaces, but their typographic quotes are not very curly at all, making them very hard to distinguish from the ‘dumb’ straight quotes that Terminal expects. The classic ‘Monaco’ typeface on the other hand has beautiful curly typographic quotes, making them very distinct from the the straight quote.
My favorite mono space typeface ‘Source Code Pro’ also has nice curly typographic quotes. I have built this table with many common monospace typefaces and their quotes.
Quotation Mark Comparison
Now this shouldn’t be your only criteria in choosing your Terminal font, but it may be something that helps avoid quote errors.
Many thanks again to all those who put a lot of effort into making MacADUK 2019 the great conference it was. Also thanks to the attendees with all their great feedback and applause. See you all again next year!
Version 1.2 is now notarized, so it should continue to work with macOS 10.14.5 and newer. It also checks the battery level before starting the process and will refuse continue if the battery is low. We also fixed a few layout and other bugs.
Important Update: Because this new version is built with Swift 5, it will require the Swift 5 Runtime Support to be installed as well, when on macOS 10.14.3 and older.
But the big new feature is that you can customize the installation process of the new macOS with custom packages.
The package installers will be installed after the macOS installation is complete but before DEP runs or the first user is created. This allows for some useful customizations and shortcuts in the deployment process.
The EraseInstall application will look for package installers (pkg) files in the /Library/Application Support/EraseInstall/Packages/ folder. When the package installers are in the correct format (see below) they will be added to the startosinstall command with the --installpackage option.
For this to work, the packages have to be ‘distribution packages with an’product archives,’ i.e. distribution packages with the identifier attribute set in the product key.
Most package installers created with tools commonly used by Mac Administrators build component packages (also called ‘flat packages’). These contain the payload files that will be installed on the target system and optional installation scripts to modify the behavior.
If you usually build your packages as component packages with pkgbuild or a similar tool, you can convert them to product archives with the productbuild command:
If you use a different tool to create your packages, please consult the tool’s manual or support reference whether they create component packages, distribution packages or product archives. – munkipkg: will automatically create product archives when the distribution_style key is set to true
– Whitebox Packages: identifier (id) and version can be set for a distribution package project when ‘Show Advanced User Options’ is enabled in Packages -> Preferences
– Jamf Composer: cannot create distribution packages or product archives. You can convert the component packages from Composer with the above productbuild command.
– pkgbuild and most other tools: creates component packages which you can convert using the above productbuild command
You can use the ‘ShowLanguageChooser’ and ‘SuppressSetupAssistant’ package installers built with these scripts as some examples to start with.
The macOS Mojave 10.14.4 update dropped on Monday night, along with iOS 12.2. Like last year’s 10.13.4 update, these updates didn’t only bring the usual “bug fixes and improvements” but new features, both user facing and “under the hood.”
Apple even put a section on the ‘Enterprise Content’ of the updates in the macOS release notes!
Fixes an issue that could prevent mobile accounts from logging in from an off-network Mac after changing their network account password.
Fixes an issue that intermittently prevented apps from downloading from the App Store or installing via MDM.
Mobile Active Directory accounts that have used their personal recovery key (PRK) to unlock a FileVault volume are no longer required to continue using the PRK to unlock, but can use their login password instead.
Export a predefined set of device information values for specified devices using a new command-line tool, exportDeviceInfo
Skip True Tone pane in Setup Assistant
Configure new restrictions: screenshot and remote screen observation
Configure Exchange Web Services authentication certificate
Configure Apple Remote Desktop access
Configure managed classes on student Mac computers
Configure Certificate Transparency payload
iOS
Enable or disable Voice and Data Roaming and Personal Hotspot
Configure new restrictions: Personal Hotspot modification (supervised only), disable server-side Siri logging
Display phone number, ICCID, and IMEI details of enrolled Dual SIM devices
Configure Certificate Transparency payload
tvOS
– Configure Managed Software Updates
While I do not recommend to macOS Server/Profile Manager as a production MDM, it is useful for testing new features and as a reference implementation.
We didn’t get new, disrupting features on the scale of user-approved MDM this year, but the spring update still warrants extra attention and preparation from system admins.
Explanation for those who live in countries with sensible units and date notations: Americans – aside from using weird non-metric units – also have the odd habit of putting the month first in dates, then the day, then the year. So: ‘Mar 14, 2019’ or 3/14/2019. Instead of the more sensible 14.3.2019.
On the other hand, once every year, this weird notation will spell out 3.14, or the first three digits of the circle number, π (pi). And since non-mathematicians seem to love the (non-deserved) quasi-mystical nature of Pi and mathematicians are happy that at least once a year people are paying attention, Pi-day has become kind of a thing.
It’s also an excuse to bake tasty pies as a real-world dad joke manifestation, so overall, fun can be had!
But since we are talking about date notations…
While the day.month.year notation common in the rest of the world is arguably better than the American month/day/year, it is still not an ideal notation. Even better is year-month-day, especially when used with fixed digit lengths: YYYY-MM-DD, e.g. 2019-03-14.
While we will have to wait 1122 years before this notation approximates π, it has many other benefits. First, it sensibly and obviously sorts the components of date and time from largest (years) to lowest (seconds or even fractions of a second). It is fairly easy to parse in scripts and languages. When you sort ISO 8601 date strings alphanumerically, they will be in the correct order for dates. No other notation does that.
This is the reason this notation is enshrined as ISO 8601 and used in many places on your computer. For example, property lists encode timestamps in ISO 8601.
Jamf Extension Attributes can also be parsed properly as dates when returned in ISO 8601 format.
Dates in the shell
When working in shell scripts on macOS, you can use the date command to get the current date or for other date operations. Other flavors of unix-like operating systems have a specific flag to get ISO 8601 output, but in macOS you have to format manually:
$ date -u +"%F"
2019-03-14
$ date -u +"%FT%T"
2019-03-14T08:00:15
When you want a file’s creation, access, or modification date you can use the stat command:
$ stat -f 'Created: %Sc Modified: %Sm Accessed: %Sa' pi-day
Created: Mar 14 08:43:07 2019 Modified: Mar 14 08:43:06 2019 Accessed: Mar 14 08:43:06 2019
You can teach Finder an approximation of ISO 8601. Go to System Preferences > Language & Region and click on the ‘Advanced…’ button and select the ‘Dates’ tab:
Set something close to the ISO date format for Mac
AppleScript
AppleScript will use the system’s date formatter (set in System Preferences) to parse and print dates. It will use the “Full date format” to show date objects by default, which is quite elaborate.
You can declare date variables with the short format, but as soon as you “compile” the script, it will be replaced by the full format. So, this:
set thedate to date "2019-03-14"
will turn into this
set thedate to date "Thursday, 14 March, 2019 at 00:00:00"
AppleScript uses the date format defined in System Preferences, so you have to have this set up. This format will also be used when AppleScript extracts a date object to a string, but again it will use the full date format by default:
get date string of thedate
"Thursday, 14 March, 2019"
There is, however, a short date string property you can use:
get short date string of thedate
"2019-03-14"
Again, the output will depend on the format set in System Preferences.
Swift uses the Date class to represent dates and times. There is a DateFormatter object which can convert Date objects to strings and back. There is also a dedicated, if awkwardly named, ISO8601DateFormatter class just for ISO dates and times.
let now = Date()
print(ISO8601DateFormatter().string(from: now))
let pidaywithtime = ISO8601DateFormatter().date(from: "2019-03-14T15:09:26Z")
You can even customize the behavior of the ISO8601DateFormatter:
let dateISOFormatter = ISO8601DateFormatter()
dateISOFormatter.formatOptions = [ .withFullDate, .withDashSeparatorInDate]
let piday = dateISOFormatter.date(from: "2019-03-14")