Browse Source

add mac installer

copy-dylibs-in-bottle
Alexandros Theodotou 3 years ago
parent
commit
e87fefbae9
  1. 1
      .gitignore
  2. 23
      Makefile
  3. 64
      tools/gen_icon_set.py
  4. 188
      tools/gen_osx_installer.sh
  5. 62
      tools/osx/Info.plist.in
  6. 8
      tools/osx/appdmg.json.in
  7. 31
      tools/osx/startup_script.sh
  8. BIN
      tools/osx/zrythm.icns

1
.gitignore vendored

@ -7,3 +7,4 @@ debian.rules @@ -7,3 +7,4 @@ debian.rules
zrythm*.exe
zrythm*.zip
zrythm_installer
.DS_Store

23
Makefile

@ -24,6 +24,7 @@ MESON_DIR=meson-$(MESON_VERSION) @@ -24,6 +24,7 @@ MESON_DIR=meson-$(MESON_VERSION)
MESON_TARBALL=$(MESON_DIR).tar.gz
BUILD_ARCH_DIR=$(BUILD_DIR)/archlinux
BUILD_WINDOWS_DIR=$(BUILD_DIR)/windows10
BUILD_OSX_DIR=$(BUILD_DIR)/osx
WIN_CHROOT_DIR=/tmp/zrythm-root
WIN_TRIAL_CHROOT_DIR=/tmp/zrythm-trial-root
# This is the directory to rsync into
@ -52,6 +53,9 @@ RCEDIT64_URL=https://github.com/electron/rcedit/releases/download/v$(RCEDIT64_VE @@ -52,6 +53,9 @@ RCEDIT64_URL=https://github.com/electron/rcedit/releases/download/v$(RCEDIT64_VE
UNIX_INSTALLER_ZIP=zrythm_installer.zip
UNIX_TRIAL_INSTALLER_ZIP=zrythm_trial_installer.zip
COMMON_SRC_DEPS=$(BUILD_DIR)/$(ZLFO_TARBALL) $(BUILD_DIR)/$(ZRYTHM_TARBALL) $(BUILD_DIR)/meson/meson.py
OSX_INSTALL_PREFIX=/tmp/zrythm-osx
OSX_INSTALLER=zrythm-$(ZRYTHM_VERSION)-setup.dmg
OSX_TRIAL_INSTALLER=zrythm-trial-$(ZRYTHM_VERSION)-setup.dmg
define start_vm
if sudo virsh list | grep -q " $(1) .*paused" ; then \
@ -256,6 +260,25 @@ artifacts/windows10/$(WINDOWS_INSTALLER) artifacts/windows10/$(WINDOWS_TRIAL_INS @@ -256,6 +260,25 @@ artifacts/windows10/$(WINDOWS_INSTALLER) artifacts/windows10/$(WINDOWS_TRIAL_INS
scp alex@$(WINDOWS_IP):$(MINGW_SRC_DIR)/build/$(WINDOWS_TRIAL_INSTALLER) artifacts/windows10/$(WINDOWS_TRIAL_INSTALLER)
$(call stop_vm,windows10)
$(OSX_INSTALL_PREFIX)/bin/zrythm: $(BUILD_DIR)/$(ZRYTHM_TARBALL)
-rm -rf $(BUILD_OSX_DIR)/$(ZRYTHM_TARBALL)
-rm -rf $(OSX_INSTALL_PREFIX)
mkdir -p $(BUILD_OSX_DIR)
cp $(BUILD_DIR)/$(ZRYTHM_TARBALL) $(BUILD_OSX_DIR)/$(ZRYTHM_TARBALL)
cd $(BUILD_OSX_DIR) && tar xf $(ZRYTHM_TARBALL) && \
cd zrythm-$(ZRYTHM_VERSION) && \
meson build -Denable_sdl=true -Denable_rtaudio=true \
-Denable_rtmidi=true -Denable_ffmpeg=true \
--prefix=$(OSX_INSTALL_PREFIX) && \
ninja -C build && ninja -C build install
# this must be run on macos
artifacts/osx/$(OSX_INSTALLER) artifacts/osx/$(OSX_TRIAL_INSTALLER)&: tools/gen_osx_installer.sh $(OSX_INSTALL_PREFIX)/bin/zrythm
tools/gen_osx_installer.sh $(ZRYTHM_VERSION) \
$(BUILD_OSX_DIR)/zrythm-$(ZRYTHM_VERSION) \
$(OSX_INSTALL_PREFIX) artifacts/osx/$(OSX_INSTALLER) \
tools/osx /usr/local
.PHONY: debian9
debian9: $(BUILD_DIR)/$(DEBIAN_PKG_FILE)

64
tools/gen_icon_set.py

@ -0,0 +1,64 @@ @@ -0,0 +1,64 @@
import os
import sys
import pathlib
import subprocess
if len(sys.argv) < 2:
print("No path to original / hi-res icon provided")
raise SystemExit
if len(sys.argv) > 2:
print("Too many arguments")
raise SystemExit
originalPicture = sys.argv[1]
if not (os.path.isfile(originalPicture)):
print(f"There is no such file: {sys.argv[1]}")
raise SystemExit
fname = pathlib.Path(originalPicture).stem
ext = pathlib.Path(originalPicture).suffix
destDir = pathlib.Path(originalPicture).parent
iconsetDir = os.path.join(destDir, f"{fname}.iconset")
if not (os.path.exists(iconsetDir)):
pathlib.Path(iconsetDir).mkdir(parents=False, exist_ok=True)
class IconParameters():
width = 0
scale = 1
def __init__(self,width,scale):
self.width = width
self.scale = scale
def getIconName(self):
if self.scale != 1:
return f"icon_{self.width}x{self.width}{ext}"
else:
return f"icon_{self.width//2}x{self.width//2}@2x{ext}"
# https://developer.apple.com/design/human-interface-guidelines/macos/icons-and-images/app-icon#app-icon-sizes
ListOfIconParameters = [
IconParameters(16, 1),
IconParameters(16, 2),
IconParameters(32, 1),
IconParameters(32, 2),
IconParameters(64, 1),
IconParameters(64, 2),
IconParameters(128, 1),
IconParameters(128, 2),
IconParameters(256, 1),
IconParameters(256, 2),
IconParameters(512, 1),
IconParameters(512, 2),
IconParameters(1024, 1),
IconParameters(1024, 2)
]
# generate iconset
for ip in ListOfIconParameters:
subprocess.call(["sips", "-z", str(ip.width), str(ip.width), originalPicture, "--out", os.path.join(iconsetDir, ip.getIconName())])
#print(f"Generated {ip.getIconName()}")
# convert iconset to icns file
subprocess.call(["iconutil", "-c", "icns", iconsetDir, "-o", os.path.join(destDir, f"{fname}.icns")])

188
tools/gen_osx_installer.sh

@ -0,0 +1,188 @@ @@ -0,0 +1,188 @@
#! /bin/bash
# Copyright (C) 2019-2020 Alexandros Theodotou <alex at zrythm dot org>
# Notes:
# 1. This script assumes you have all the dependencies
# installed using HomeBrew.
# 2. Meant to be run from the parent dir
# 3. Uses appdmg (brew install npm, npm install -g appdmg)
# 4. need to install librsvg and then reinstall gdk-pixbuf
# in brew to get svg support (or copy the pixbuf loader from
# the Cellar of libtsvg to the Cellar of gdk-pixbuf)
# args:
# 1: version
# 2: zrythm source root dir
# 3: prefix where zrythm was installed
# 4: path to copy finished installer to
# 5: osx data dir (tools/osx)
# 6: normal prefix (where other programs are installed)
set -e
ZRYTHM_VERSION=$1
ZRYTHM_SRC_DIR=$2
ZRYTHM_INSTALL_PREFIX=$3
FINAL_DMG_PATH=$4
OSX_SOURCE_DATA_DIR=$5
NORMAL_PREFIX=$6
WORK_ROOT=/tmp/zrythm-dmg
rm -rf $WORK_ROOT
# setup directory structure
APPDIR=$WORK_ROOT/Zrythm.app
Contents=$APPDIR/Contents
Resources=$Contents/Resources
Bin=$Resources/bin
Share=$Resources/share
Etc=$Resources/etc
Locale=$Resources/share/locale
Lib=$Resources/lib
echo "system dependencies:"
for file in $ZRYTHM_INSTALL_PREFIX/bin/zrythm* ; do
if ! file $file | grep -qs Mach-O ; then
continue
fi
otool -L $file | awk '{print $1}' | egrep -v "(^$WORK_ROOT*)"
done | sort | uniq
echo "Removing old $APPDIR tree ..."
rm -rf $APPDIR
echo "Building new app directory structure ..."
mkdir -p $Contents/MacOS
mkdir -p $Etc
mkdir -p $Locale
mkdir -p $Lib
mkdir -p $Bin
# copy static files
echo "copying plists"
sed "s/@VERSION@/$ZRYTHM_VERSION/" < \
$OSX_SOURCE_DATA_DIR/Info.plist.in > $Contents/Info.plist
cp $OSX_SOURCE_DATA_DIR/startup_script.sh $Contents/MacOS/Zrythm
chmod 775 $Contents/MacOS/Zrythm
MAIN_EXECUTABLE=zrythm ## used in startup_script
echo "Copying zrythm executable ...."
cp $ZRYTHM_INSTALL_PREFIX/bin/zrythm $Bin/
cp $OSX_SOURCE_DATA_DIR/zrythm.icns $Resources/
set +e # things below are not error-free (optional files etc) :(
#
# Copy stuff that may be dynamically loaded
#
# etc gtk
cp -RL $NORMAL_PREFIX/etc/gtk-3.0 $Etc/
# charset alias
cp -RL $NORMAL_PREFIX/lib/charset.alias $Lib/
# GDK Pixbuf
echo "copying gdk pixbuf loaders"
GDK_PIXBUF_DIR=gdk-pixbuf-2.0/2.10.0
mkdir -p $Lib/$GDK_PIXBUF_DIR
cp -RL $NORMAL_PREFIX/lib/$GDK_PIXBUF_DIR/* $Lib/$GDK_PIXBUF_DIR/
# localization
echo "copying languages"
languages="fr de it es ja"
for lang in $languages; do
CUR_DIR="$Locale/$lang/LC_MESSAGES"
mkdir -p $CUR_DIR
cp $NORMAL_PREFIX/share/locale/$lang/zrythm.mo "$CUR_DIR/"
cp $NORMAL_PREFIX/share/locale/$lang/LC_MESSAGES/gtk30.mo \
$NORMAL_PREFIX/share/locale/$lang/LC_MESSAGES/gtk30-properties.mo \
$CUR_DIR/
done
echo "copying Adwaita icons"
ICONS_DIR="$Share/icons"
mkdir -p "$ICONS_DIR"
cp -RL "$NORMAL_PREFIX/share/icons/Adwaita" "$ICONS_DIR/"
echo "copying existing hicolor icons"
cp -RL "$NORMAL_PREFIX/share/icons/hicolor" "$ICONS_DIR/"
echo "copying app icon"
APPICON_DIR1=$ICONS_DIR/hicolor/scalable/apps
APPICON_DIR2=$ICONS_DIR/hicolor/48x48/apps
mkdir -p $APPICON_DIR1
mkdir -p $APPICON_DIR2
cp $ZRYTHM_SRC_DIR/resources/icons/zrythm/zrythm.svg $APPICON_DIR1/
cp $ZRYTHM_SRC_DIR/resources/icons/zrythm/zrythm.svg $APPICON_DIR2/
echo "copying themes"
#rsync -a --copy-links /usr/local/share/ $Share/
cp -RL "$NORMAL_PREFIX/share/themes" "$Share/"
echo "copying fonts"
cp -R $ZRYTHM_SRC_DIR/data/fonts "$Share/"
SCHEMAS_DIR="glib-2.0/schemas"
mkdir -p $Share/$SCHEMAS_DIR
cp $NORMAL_PREFIX/share/$SCHEMAS_DIR/org.zrythm*.xml \
"$Share/$SCHEMAS_DIR/"
cp $NORMAL_PREFIX/share/$SCHEMAS_DIR/org.gtk.*.xml \
"$Share/$SCHEMAS_DIR/"
echo "building schemas"
glib-compile-schemas "$Share/$SCHEMAS_DIR/"
# copy libs
STDCPP='|libstdc\+\+'
while [ true ] ; do
missing=false
for file in $Bin/* $Lib/* ; do
if ! file $file | grep -qs Mach-O ; then
continue
fi
# libffi contains "S" (other section symbols) that should not be stripped.
if [[ $file == *"libffi"* ]] ; then
continue
fi
if test x$STRIP != x ; then
strip -u -r -arch all $file &>/dev/null
fi
deps=`otool -L $file | awk '{print $1}' | egrep "($NORMAL_PREFIX|libs/$STDCPP)" | grep -v "$(basename $file)"`
echo "deps=$deps"
# echo -n "."
for dep in $deps ; do
echo "dependency $dep"
base=`basename $dep`
if ! test -f $Lib/$base; then
if echo $dep | grep -sq '^libs' ; then
cp $WORK_ROOT/$dep $Lib
else
cp -L $dep $Lib
fi
missing=true
fi
done
done
if test x$missing = xfalse ; then
# everything has been found
break
fi
done
# make dmg
echo "making dmg from .app"
rm -f $FINAL_DMG_PATH
mkdir -p $(dirname "$FINAL_DMG_PATH")
sed "s|@APP_PATH@|$APPDIR|" < \
$OSX_SOURCE_DATA_DIR/appdmg.json.in > $WORK_ROOT/appdmg.json
sed -i -e "s|@ICNS_PATH@|$Resources/zrythm.icns|" \
$WORK_ROOT/appdmg.json
cat $WORK_ROOT/appdmg.json
appdmg $WORK_ROOT/appdmg.json $FINAL_DMG_PATH
rm -f $WORK_ROOT/appdmg.json
echo "Done."
exit

62
tools/osx/Info.plist.in

@ -0,0 +1,62 @@ @@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//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>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>zrythm</string>
</array>
<key>CFBundleTypeOSTypes</key>
<array>
<string>****</string>
<string>fold</string>
</array>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleTypeIconFile</key>
<string>zrythm.icns</string>
</dict>
</array>
<key>CFBundleExecutable</key>
<string>zrythm</string>
<key>CFBundleGetInfoString</key>
<string>@PACKAGE_VERSION@, (C) 2018-2020 Alexandros Theodotou https://www.zrythm.org</string>
<key>CFBundleIconFile</key>
<string>zrythm.icns</string>
<key>CFBundleIdentifier</key>
<string>org.zrythm.Zrythm</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>Zrythm</string>
<key>CFBundleDisplayName</key>
<string>Zrythm</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersions</key>
<string>@PACKAGE_VERSION@</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>@PACKAGE_VERSION@</string>
<key>LSUIElement</key>
<string>0</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright 2018 - 2020 Alexandros Theodotou, GNU Affero General Public License, version 3 or later.</string>
<key>LSMinimumSystemVersion</key>
<string>10.4</string>
<key>GtkOSXLaunchScriptFile</key>
<string>gtk3-launcher.sh</string>
<key>NSHighResolutionCapable</key>
<true/>
</dict>
</plist>

8
tools/osx/appdmg.json.in

@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
{
"title": "Zrythm",
"icon": "@ICNS_PATH@",
"contents": [
{ "x": 448, "y": 344, "type": "link", "path": "/Applications" },
{ "x": 192, "y": 344, "type": "file", "path": "@APP_PATH@" }
]
}

31
tools/osx/startup_script.sh

@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
#!/bin/sh
name=`basename "$0"`
tmp="$0"
tmp=`dirname "$tmp"`
tmp=`dirname "$tmp"`
bundle=`dirname "$tmp"`
bundle_contents="$bundle"/Contents
bundle_res="$bundle_contents"/Resources
bundle_lib="$bundle_res"/lib
bundle_bin="$bundle_res"/bin
bundle_data="$bundle_res"/share
bundle_etc="$bundle_res"/etc
export XDG_DATA_DIRS="$bundle_data"
export GTK_DATA_PREFIX="$bundle_res"
export GTK_EXE_PREFIX="$bundle_res"
export GTK_PATH="$bundle_res"
export GDK_PIXBUF_MODULE_FILE="$bundle_lib/gdk-pixbuf-2.0/2.10.0/loaders.cache"
I18NDIR="$bundle_data/locale"
# Strip out the argument added by the OS.
if /bin/expr "x$1" : '^x-psn_' > /dev/null; then
shift 1
fi
export GDK_DEBUG=interactive
exec "$bundle_bin/zrythm" "$@"

BIN
tools/osx/zrythm.icns

Binary file not shown.
Loading…
Cancel
Save