Skip to content

Commit

Permalink
Merge pull request #167 from smoogipoo/extract-app-template
Browse files Browse the repository at this point in the history
Extract macOS app template to directory
  • Loading branch information
peppy committed Apr 4, 2024
2 parents a278b69 + 8ce5ab1 commit 8247971
Show file tree
Hide file tree
Showing 6 changed files with 2,892 additions and 12 deletions.
29 changes: 17 additions & 12 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -364,33 +364,38 @@ private static void displayHeader()

private static void buildForMac(string arch, string version)
{
// unzip the template app, with all structure existing except for dotnet published content.
runCommand("unzip", $"\"osu!.app-template.zip\" -d {stagingPath}", false);
const string app_dir = "osu!.app";

string stagingTarget = Path.Combine(stagingPath, app_dir);

if (Directory.Exists(stagingTarget))
Directory.Delete(stagingTarget, true);

runCommand("cp", $"-r \"{Path.Combine(templatesPath, app_dir)}\" \"{stagingTarget}\"");

// without touching the app bundle itself, changes to file associations / icons / etc. will be cached at a macOS level and not updated.
runCommand("touch", $"\"{Path.Combine(stagingPath, "osu!.app")}\" {stagingPath}", false);
runCommand("touch", $"\"{stagingTarget}\" {stagingPath}", false);

runCommand("dotnet", $"publish -f net8.0 -r osx-{arch} {ProjectName} --configuration Release -o {stagingPath}/osu!.app/Contents/MacOS /p:Version={version} --self-contained");
runCommand("dotnet", $"publish -f net8.0 -r osx-{arch} {ProjectName} --configuration Release -o {stagingTarget}/Contents/MacOS /p:Version={version} --self-contained");

string stagingApp = $"{stagingPath}/osu!.app";
string archLabel = arch == "x64" ? "Intel" : "Apple Silicon";
string zippedApp = $"{releasesPath}/osu!.app ({archLabel}).zip";
string zippedApp = $"{releasesPath}/{app_dir} ({archLabel}).zip";

// correct permissions post-build. dotnet outputs 644 by default; we want 755.
runCommand("chmod", $"-R 755 {stagingApp}");
runCommand("chmod", $"-R 755 {stagingTarget}");

if (!string.IsNullOrEmpty(CodeSigningCertificate))
{
// sign using apple codesign
runCommand("codesign",
$"--deep --force --verify --keychain app-signing --entitlements {Path.Combine(Environment.CurrentDirectory, "osu.entitlements")} -o runtime --verbose --sign \"{CodeSigningCertificate}\" {stagingApp}");
$"--deep --force --verify --keychain app-signing --entitlements {Path.Combine(Environment.CurrentDirectory, "osu.entitlements")} -o runtime --verbose --sign \"{CodeSigningCertificate}\" {stagingTarget}");

// check codesign was successful
runCommand("spctl", $"--assess -vvvv {stagingApp}");
runCommand("spctl", $"--assess -vvvv {stagingTarget}");
}

// package for distribution
runCommand("ditto", $"-ck --rsrc --keepParent --sequesterRsrc {stagingApp} \"{zippedApp}\"");
runCommand("ditto", $"-ck --rsrc --keepParent --sequesterRsrc {stagingTarget} \"{zippedApp}\"");

string notarisationUsername = ConfigurationManager.AppSettings["AppleUsername"] ?? string.Empty;
string notarisationPassword = ConfigurationManager.AppSettings["ApplePassword"] ?? string.Empty;
Expand All @@ -405,13 +410,13 @@ private static void buildForMac(string arch, string version)
// TODO: make this actually wait properly

// staple notarisation result
runCommand("xcrun", $"stapler staple {stagingApp}");
runCommand("xcrun", $"stapler staple {stagingTarget}");
}

File.Delete(zippedApp);

// repackage for distribution
runCommand("ditto", $"-ck --rsrc --keepParent --sequesterRsrc {stagingApp} \"{zippedApp}\"");
runCommand("ditto", $"-ck --rsrc --keepParent --sequesterRsrc {stagingTarget} \"{zippedApp}\"");
}

/// <summary>
Expand Down
Binary file removed osu!.app-template.zip
Binary file not shown.
100 changes: 100 additions & 0 deletions templates/osu!.app/Contents/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>osu!</string>
<key>CFBundleName</key>
<string>osu!</string>
<key>CFBundleGetInfoString</key>
<string>osu-lazer</string>
<key>CFBundleIconFile</key>
<string>osu.icns</string>
<key>CFBundleIdentifier</key>
<string>sh.ppy.osu.lazer</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>0.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>lazer</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>0.0</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>LSHasLocalizedDisplayName</key>
<true/>
<key>LSMinimumSystemVersion</key>
<string>10.7.0</string>
<key>NSPrincipalClass</key>
<string>CStubApplication</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>Supported protocols</string>
<key>CFBundleURLSchemes</key>
<array>
<string>osu</string>
</array>
</dict>
</array>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>osu! beatmap archive</string>
<key>LSHandlerRank</key>
<string>Default</string>
<key>CFBundleTypeExtensions</key>
<array>
<string>osz</string>
</array>
<key>CFBundleTypeMIMETypes</key>
<array>
<string>application/x-osu-beatmap-archive</string>
</array>
<key>LSTypeIsPackage</key>
<false/>
</dict>
<dict>
<key>CFBundleTypeName</key>
<string>osu! skin archive</string>
<key>LSHandlerRank</key>
<string>Default</string>
<key>CFBundleTypeExtensions</key>
<array>
<string>osk</string>
</array>
<key>CFBundleTypeMIMETypes</key>
<array>
<string>application/x-osu-skin-archive</string>
</array>
<key>LSTypeIsPackage</key>
<false/>
</dict>
<dict>
<key>CFBundleTypeName</key>
<string>osu! replay</string>
<key>LSHandlerRank</key>
<string>Default</string>
<key>CFBundleTypeExtensions</key>
<array>
<string>osr</string>
</array>
<key>CFBundleTypeMIMETypes</key>
<array>
<string>application/x-osu-replay</string>
</array>
<key>LSTypeIsPackage</key>
<false/>
</dict>
</array>
<key>LSApplicationCategoryType</key>
<string>public.app-category.music-games</string>
</dict>
</plist>
1 change: 1 addition & 0 deletions templates/osu!.app/Contents/PkgInfo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
APPL????
Binary file added templates/osu!.app/Contents/Resources/osu.icns
Binary file not shown.
Loading

0 comments on commit 8247971

Please sign in to comment.