forked from vtenfys/notion-linux
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.sh
executable file
·130 lines (110 loc) · 3.54 KB
/
build.sh
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/bash
set -e
ELECTRON_VERSION=6.1.7
NOTION_BINARY=notion.exe
NOTION_DMG=notion.dmg
if [[ $1 != windows && $1 != mac ]]; then
echo Please specify whether you would like to build a DEB package using \
Windows or macOS sources
echo Example: ./build.sh windows
exit 1
fi
# Check for Notion Windows installer
if [ "$1" == windows ] && ! [ -f $NOTION_BINARY ]; then
echo Notion installer missing!
echo Please download Notion for Windows from https://www.notion.so/desktop \
and place the installer in this directory as $NOTION_BINARY
exit 1
fi
# Check for Notion macOS installer
if [ "$1" == mac ] && ! [ -f $NOTION_DMG ]; then
echo Notion installer missing!
echo Please download Notion for macOS from https://www.notion.so/desktop \
and place the installer in this directory as $NOTION_DMG
exit 1
fi
# Check for required commands
check-command() {
if ! command -v "$1" >/dev/null 2>&1; then
echo Missing command: "$1"
exit 1
fi
}
commands=(
node npm asar electron-packager electron-installer-debian electron-installer-redhat
7z convert fakeroot dnf
)
for command in "${commands[@]}"; do
check-command "$command"
done
# Setup the build directory
mkdir -p build
if [ "$1" == windows ]; then
# Extract the Notion executable
if ! [ -f "build/notion/\$PLUGINSDIR/app-64.7z" ]; then
7z x $NOTION_BINARY -obuild/notion
fi
# Extract the app bundle
if ! [ -f build/bundle/resources/app.asar ]; then
7z x "build/notion/\$PLUGINSDIR/app-64.7z" -obuild/bundle
fi
# Extract the app container
if ! [ -d build/app ]; then
asar extract build/bundle/resources/app.asar build/app
fi
elif [ "$1" == mac ]; then
# Extract the Notion disk image
if ! [ -f 'build/notion/Notion Installer/Notion.app/Contents/Resources/app.asar' ]; then
7z x $NOTION_DMG -obuild/notion
fi
if ! [ -d build/app ]; then
asar extract \
'build/notion/Notion Installer/Notion.app/Contents/Resources/app.asar' \
build/app
fi
fi
# Install NPM dependencies
if ! [ -f build/app/package-lock.json ]; then
# Replace package name to fix some issues:
# - conflicting package in Ubuntu repos called "notion"
# - icon not showing up properly when only the DEB package is renamed
sed -i 's/"Notion"/"notion-desktop"/' build/app/package.json
# Remove existing node_modules
rm -rf build/app/node_modules
# Configure build settings
# See https://www.electronjs.org/docs/tutorial/using-native-node-modules
export npm_config_target=$ELECTRON_VERSION
export npm_config_arch=x64
export npm_config_target_arch=x64
export npm_config_disturl=https://electronjs.org/headers
export npm_config_runtime=electron
export npm_config_build_from_source=true
HOME=~/.electron-gyp npm install --prefix build/app
fi
# Convert icon.ico to PNG
if ! [ -f build/app/icon.png ]; then
convert 'build/app/icon.ico[0]' build/app/icon.png
fi
# Create Electron distribution
if ! [ -d build/dist ]; then
electron-packager build/app app \
--platform linux \
--arch x64 \
--out build/dist \
--electron-version $ELECTRON_VERSION \
--executable-name notion-desktop
fi
# Create Debian package
# electron-installer-debian \
# --src build/dist/app-linux-x64 \
# --dest out \
# --arch amd64 \
# --options.productName Notion \
# --options.icon build/dist/app-linux-x64/resources/app/icon.png
electron-installer-redhat \
--src build/dist/app-linux-x64 \
--dest dist/installers/ \
--arch x86_64 \
--options.productName Notion \
--options.icon build/dist/app-linux-x64/resources/app/icon.png\
--options.license OtherLicense