summaryrefslogtreecommitdiff
path: root/install/build_osx.sh
blob: 40e1fe907cd45369af108235a76e44117e3a97b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash

ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
cd $ROOT

# deleting dist
echo Deleting dist folder
rm -rf $ROOT/dist &>/dev/null 2>&1

# build the .app
echo Building OnionShare.app
pyinstaller $ROOT/install/pyinstaller.spec
python3 $ROOT/install/get-tor-osx.py

# create a symlink of onionshare-gui called onionshare, for the CLI version
cd $ROOT/dist/OnionShare.app/Contents/MacOS
ln -s onionshare-gui onionshare
cd $ROOT

if [ "$1" = "--release" ]; then
  mkdir -p dist
  APP_PATH="$ROOT/dist/OnionShare.app"
  PKG_PATH="$ROOT/dist/OnionShare.pkg"
  IDENTITY_NAME_APPLICATION="Developer ID Application: Micah Lee"
  IDENTITY_NAME_INSTALLER="Developer ID Installer: Micah Lee"
  ENTITLEMENTS_CHILD_PATH="$ROOT/install/macos_sandbox/child.plist"
  ENTITLEMENTS_PARENT_PATH="$ROOT/install/macos_sandbox/parent.plist"

  echo "Codesigning the app bundle"
  codesign \
    --deep \
    -s "$IDENTITY_NAME_APPLICATION" \
    --force \
    --entitlements "$ENTITLEMENTS_CHILD_PATH" \
    --timestamp \
    "$APP_PATH"
  codesign \
    -s "$IDENTITY_NAME_APPLICATION" \
    --force \
    --entitlements "$ENTITLEMENTS_PARENT_PATH" \
    --timestamp \
    "$APP_PATH"

  echo "Creating an installer"
  productbuild \
    --sign "$IDENTITY_NAME_INSTALLER" \
    --component "$APP_PATH" /Applications \
    --timestamp \
    "$PKG_PATH"

  echo "Cleaning up"
  rm -rf "$APP_PATH"

  echo "All done, your installer is in: $PKG_PATH"
fi