-
Notifications
You must be signed in to change notification settings - Fork 235
/
Makefile
188 lines (146 loc) · 5.67 KB
/
Makefile
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
GRUNT = grunt
GRUNT_FLAGS = --no-color -v
GRUNT_FILES = Gruntfile.js.out
PRODUCT_VERSION ?= 0.0.0
BUILD_NUMBER ?= 0
PUBLISHER_NAME ?= Ascensio System SIA
PUBLISHER_URL ?= https://www.onlyoffice.com/
GRUNT_ENV += PRODUCT_VERSION=$(PRODUCT_VERSION)
GRUNT_ENV += BUILD_NUMBER=$(BUILD_NUMBER)
GRUNT_ENV += PUBLISHER_NAME="$(PUBLISHER_NAME)"
GRUNT_ENV += PUBLISHER_URL="$(PUBLISHER_URL)"
BRANDING_DIR ?= ./branding
DOCUMENT_ROOT ?= /var/www/onlyoffice/documentserver
ifeq ($(OS),Windows_NT)
PLATFORM := win
EXEC_EXT := .exe
SHARED_EXT := .dll
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
ARCHITECTURE := 64
endif
ifeq ($(PROCESSOR_ARCHITECTURE),x86)
ARCHITECTURE := 32
endif
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
PLATFORM := linux
SHARED_EXT := .so*
LIB_PREFIX := lib
endif
UNAME_M := $(shell uname -m)
ifeq ($(UNAME_M),x86_64)
ARCHITECTURE := 64
endif
ifneq ($(filter %86,$(UNAME_M)),)
ARCHITECTURE := 32
endif
endif
TARGET := $(PLATFORM)_$(ARCHITECTURE)
OUTPUT = ../build_tools/out/$(TARGET)/onlyoffice/documentserver/server
SPELLCHECKER_DICTIONARIES := $(OUTPUT)/../dictionaries
SPELLCHECKER_DICTIONARY_FILES += ../dictionaries/*_*
SCHEMA_DIR = schema
SCHEMA_FILES = $(SCHEMA_DIR)/**
SCHEMA = $(OUTPUT)/$(SCHEMA_DIR)/
TOOLS_DIR = tools
TOOLS_FILES += ../core/build/bin/$(TARGET)/allfontsgen$(EXEC_EXT)
TOOLS_FILES += ../core/build/bin/$(TARGET)/allthemesgen$(EXEC_EXT)
TOOLS = $(OUTPUT)/$(TOOLS_DIR)
LICENSE_FILES = LICENSE.txt 3rd-Party.txt license/
LICENSE = $(addsuffix $(OUTPUT)/, LICENSE_FILES)
LICENSE_JS := $(OUTPUT)/Common/sources/license.js
COMMON_DEFINES_JS := $(OUTPUT)/Common/sources/commondefines.js
WELCOME_DIR = welcome
WELCOME_FILES = $(BRANDING_DIR)/$(WELCOME_DIR)/**
WELCOME = $(OUTPUT)/$(WELCOME_DIR)/
INFO_DIR = info
INFO_FILES = $(BRANDING_DIR)/$(INFO_DIR)/**
INFO = $(OUTPUT)/$(INFO_DIR)/
CORE_FONTS_DIR = core-fonts
CORE_FONTS_FILES = ../$(CORE_FONTS_DIR)/**
CORE_FONTS = $(OUTPUT)/../$(CORE_FONTS_DIR)/
DOCUMENT_TEMPLATES_DIR = document-templates
DOCUMENT_TEMPLATES_FILES = ../$(DOCUMENT_TEMPLATES_DIR)/**
DOCUMENT_TEMPLATES = $(OUTPUT)/../$(DOCUMENT_TEMPLATES_DIR)/
DEBUG = $(BRANDING_DIR)/debug.js
.PHONY: all clean install uninstall build-date
.NOTPARALLEL:
all: $(SPELLCHECKER_DICTIONARIES) $(TOOLS) $(SCHEMA) $(CORE_FONTS) $(DOCUMENT_TEMPLATES) $(LICENSE) $(WELCOME) $(INFO) build-date
build-date: $(GRUNT_FILES)
sed "s|\(const buildVersion = \).*|\1'${PRODUCT_VERSION}';|" -i $(COMMON_DEFINES_JS)
sed "s|\(const buildNumber = \).*|\1${BUILD_NUMBER};|" -i $(COMMON_DEFINES_JS)
sed "s|\(const buildDate = \).*|\1'$$(date +%F)';|" -i $(LICENSE_JS)
test -e $(DEBUG) && \
cp $(DEBUG) $(OUTPUT)/Common/sources || true
$(SPELLCHECKER_DICTIONARIES): $(GRUNT_FILES)
mkdir -p $(SPELLCHECKER_DICTIONARIES) && \
cp -r -t $(SPELLCHECKER_DICTIONARIES) $(SPELLCHECKER_DICTIONARY_FILES)
$(SCHEMA):
mkdir -p $(SCHEMA) && \
cp -r -t $(SCHEMA) $(SCHEMA_FILES)
$(TOOLS):
mkdir -p $(TOOLS) && \
cp -r -t $(TOOLS) $(TOOLS_FILES)
$(LICENSE):
mkdir -p $(OUTPUT) && \
cp -r -t $(OUTPUT) $(LICENSE_FILES)
$(GRUNT_FILES):
cd $(@D) && \
npm install && \
$(GRUNT_ENV) $(GRUNT) $(GRUNT_FLAGS)
mkdir -p $(OUTPUT)
cp -r -t $(OUTPUT) ./build/server/*
echo "Done" > $@
$(WELCOME):
mkdir -p $(WELCOME) && \
cp -r -t $(WELCOME) $(WELCOME_FILES)
$(INFO):
mkdir -p $(INFO) && \
cp -r -t $(INFO) $(INFO_FILES)
$(CORE_FONTS):
mkdir -p $(CORE_FONTS) && \
cp -r -t $(CORE_FONTS) $(CORE_FONTS_FILES)
$(DOCUMENT_TEMPLATES):
mkdir -p $(DOCUMENT_TEMPLATES) && \
cp -r -t $(DOCUMENT_TEMPLATES) $(DOCUMENT_TEMPLATES_FILES)
clean:
rm -rf $(GRUNT_FILES)
install:
mkdir -pv ${DESTDIR}/var/www/onlyoffice
if ! id -u onlyoffice > /dev/null 2>&1; then useradd -m -d /var/www/onlyoffice -r -U onlyoffice; fi
mkdir -p ${DESTDIR}${DOCUMENT_ROOT}/fonts
mkdir -p ${DESTDIR}/var/log/onlyoffice/documentserver
mkdir -p ${DESTDIR}/var/lib/onlyoffice/documentserver/App_Data
cp -fr -t ${DESTDIR}${DOCUMENT_ROOT} build/* ../web-apps/deploy/*
mkdir -p ${DESTDIR}/etc/onlyoffice/documentserver
mv ${DESTDIR}${DOCUMENT_ROOT}/server/Common/config/* ${DESTDIR}/etc/onlyoffice/documentserver
chown onlyoffice:onlyoffice -R ${DESTDIR}/var/www/onlyoffice
chown onlyoffice:onlyoffice -R ${DESTDIR}/var/log/onlyoffice
chown onlyoffice:onlyoffice -R ${DESTDIR}/var/lib/onlyoffice
# Make symlinks for shared libs
find \
${DESTDIR}${DOCUMENT_ROOT}/server/FileConverter/bin \
-maxdepth 1 \
-name *$(SHARED_EXT) \
-exec sh -c 'ln -sf {} ${DESTDIR}/lib/$$(basename {})' \;
sudo -u onlyoffice "${DESTDIR}${DOCUMENT_ROOT}/server/tools/allfontsgen"\
--input="${DESTDIR}${DOCUMENT_ROOT}/core-fonts"\
--allfonts-web="${DESTDIR}${DOCUMENT_ROOT}/sdkjs/common/AllFonts.js"\
--allfonts="${DESTDIR}${DOCUMENT_ROOT}/server/FileConverter/bin/AllFonts.js"\
--images="${DESTDIR}${DOCUMENT_ROOT}/sdkjs/common/Images"\
--selection="${DESTDIR}${DOCUMENT_ROOT}/server/FileConverter/bin/font_selection.bin"\
--output-web="${DESTDIR}${DOCUMENT_ROOT}/fonts"\
--use-system="true"
sudo -u onlyoffice "${DESTDIR}${DOCUMENT_ROOT}/server/tools/allthemesgen"\
--converter-dir="${DESTDIR}${DOCUMENT_ROOT}/server/FileConverter/bin"\
--src="${DESTDIR}${DOCUMENT_ROOT}/sdkjs/slide/themes"\
--output="${DESTDIR}${DOCUMENT_ROOT}/sdkjs/common/Images"
uninstall:
userdel onlyoffice
# Unlink installed shared libs
find /lib -type l | while IFS= read -r lnk; do if (readlink "$$lnk" | grep -q '^${DOCUMENT_ROOT}/server/FileConverter/bin/'); then rm "$$lnk"; fi; done
rm -rf /var/www/onlyoffice/documentserver
rm -rf /var/log/onlyoffice/documentserver
rm -rf /var/lib/onlyoffice/documentserver
rm -rf /etc/onlyoffice/documentserver