Makefile 5.52 KB
Newer Older
1
#
2
# Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
3 4 5 6 7 8 9 10
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=foris
11
PKG_VERSION:=99.5
12
PKG_RELEASE:=1
13 14
PKG_SOURCE_SUBDIR:=$(PKG_NAME)
PKG_SOURCE_PROTO:=git
Martin Strbacka's avatar
Martin Strbacka committed
15
PKG_SOURCE_URL:=https://gitlab.labs.nic.cz/turris/foris.git
16
PKG_SOURCE_VERSION:=package-v$(PKG_VERSION)
17 18
PKG_SOURCE:=$(PKG_NAME)-$(PKG_SOURCE_VERSION).tar.gz
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
19

20 21 22 23 24 25 26
PKG_BUILD_DEPENDS:=\
	ruby/host \
	python3-libsass/host \
	python3-pytz/host \
	python3-babel/host \
	python3-markupsafe/host \
	python3-jinja2/host
27 28

include $(INCLUDE_DIR)/package.mk
29
include $(INCLUDE_DIR)/host-build.mk
30 31
include ./files/foris-translations.mk

32
$(call include_mk, python3-package.mk)
33

34 35
define Package/foris-common
	TITLE:=foris-common
36
	DEPENDS:=\
37 38
		+python3-light +python3-bottle +python3-bottle-i18n \
		+python3-flup +python3-ubus +python3-jinja2 +lighttpd +lighttpd-mod-fastcgi \
39
		+lighttpd-mod-redirect +lighttpd-mod-setenv +lighttpd-mod-alias +foris-ws \
40
		+foris-client-python3 +fosquitto +python3-paho-mqtt
41
	MAINTAINER:=CZ.NIC <packaging@turris.cz>
42 43
endef

44 45
define Package/foris-common/description
 Common things required for the foris web apps.
46 47
endef

48
define Build/Compile
Jan Čermák's avatar
Jan Čermák committed
49
	$(call Build/Compile/Default)
50
	$(call Build/Compile/Py3Mod,,install --prefix=/usr --root="$(PKG_INSTALL_DIR)")
51 52
endef

53
define Package/foris-common/conffiles
54
/etc/config/foris
55 56
endef

57
define Package/foris-common/install
58 59 60 61
	$(INSTALL_DIR) $(1)/usr/share/turris-webapps
	$(INSTALL_DATA) ./files/00_foris.conf $(1)/usr/share/turris-webapps/
	$(INSTALL_DIR) $(1)/www/webapps-icons
	$(INSTALL_DATA) ./files/foris.jpg $(1)/www/webapps-icons
62
	$(INSTALL_DIR) $(1)/etc/lighttpd/conf.d/
63
	$(INSTALL_DATA) ./files/foris-root.lighttpd-conf $(1)/etc/lighttpd/conf.d/foris-root.conf
64 65 66

	$(INSTALL_DIR) $(1)/usr/share/foris
	$(INSTALL_BIN) ./files/lighttpd-dynamic-conf $(1)/usr/share/foris/lighttpd-dynamic-conf
67
	sed -i 's|python2.7|$(PYTHON3)|' $(1)/usr/share/foris/lighttpd-dynamic-conf
68

69 70
	$(INSTALL_DIR) $(1)/usr/share/foris/plugins

71
	$(INSTALL_DIR) $(1)/etc/config
72 73 74
	$(INSTALL_DATA) ./files/foris.conf $(1)/etc/config/foris

	$(INSTALL_DIR) $(1)/usr/bin
75
	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/foris $(1)/usr/bin/foris
76

77
	$(INSTALL_DIR) $(1)$(PYTHON3_PKG_DIR)
78

79
	$(CP) \
80 81 82 83 84 85
		$(PKG_INSTALL_DIR)$(PYTHON3_PKG_DIR)/* \
		$(1)$(PYTHON3_PKG_DIR)/
	$(RM) -r $(1)$(PYTHON3_PKG_DIR)/foris/locale/
	$(RM) -r $(1)$(PYTHON3_PKG_DIR)/foris/langs/??.py
	$(RM) -r $(1)$(PYTHON3_PKG_DIR)/foris/config
	$(RM) $(1)$(PYTHON3_PKG_DIR)/foris/config_app.py
86

87 88
	$(INSTALL_DIR) $(1)$(PYTHON3_PKG_DIR)/foris/locale
	touch $(1)$(PYTHON3_PKG_DIR)/foris/locale/.keep
89 90
endef

91 92 93 94
define Package/foris-config
	TITLE:=foris-config
	DEPENDS:=\
		+foris-common +luci
95
	MAINTAINER:=CZ.NIC <packaging@turris.cz>
96 97 98 99 100
endef

define Package/foris
	TITLE:=foris
	DEPENDS:=\
Štěpán Henek's avatar
Štěpán Henek committed
101
		+foris-config
102
	MAINTAINER:=CZ.NIC <packaging@turris.cz>
103 104 105 106 107 108 109
endef

define Package/foris/description
 Web administration interface using nuci for communication.
endef

define Package/foris/install
110 111
	$(INSTALL_DIR) $(1)$(PYTHON3_PKG_DIR)/foris/
	touch $(1)$(PYTHON3_PKG_DIR)/foris/.keep
112 113 114 115 116 117 118 119
endef

define Package/foris-config/install
	$(INSTALL_DIR) $(1)/etc/lighttpd/conf.d/
	$(INSTALL_DATA) ./files/foris-config.lighttpd-conf $(1)/etc/lighttpd/conf.d/foris-config.conf
	$(INSTALL_DIR) $(1)/usr/share/foris
	$(INSTALL_BIN) ./files/foris-config-cgi $(1)/usr/share/foris/foris-config-cgi

120
	$(INSTALL_DIR) $(1)$(PYTHON3_PKG_DIR)/foris/config
121
	$(CP) \
122 123
		$(PKG_INSTALL_DIR)$(PYTHON3_PKG_DIR)/foris/config_app.py \
		$(1)$(PYTHON3_PKG_DIR)/foris/
124
	$(CP) \
125 126
		$(PKG_INSTALL_DIR)$(PYTHON3_PKG_DIR)/foris/config/* \
		$(1)$(PYTHON3_PKG_DIR)/foris/config/
127 128 129
endef

define Package/foris-common/postinst
130 131 132 133
#!/bin/sh
set -x
[ -n "$$IPKG_INSTROOT" ] || {
/etc/init.d/lighttpd enable
134
/etc/init.d/lighttpd restart
135 136 137
}
endef

138
define Package/foris-common/prerm
139 140 141 142 143 144
#!/bin/sh
set -x
/etc/init.d/lighttpd disable
/etc/init.d/lighttpd stop
endef

145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
define Package/foris-config/postinst
#!/bin/sh
set -x
[ -n "$$IPKG_INSTROOT" ] || {
/etc/init.d/lighttpd restart
}
endef

define Package/foris-config/postrm
#!/bin/sh
set -x
[ -n "$$IPKG_INSTROOT" ] || {
/etc/init.d/lighttpd restart
}
endef

161 162
define Build/InstallDev
	$(INSTALL_DIR) $(STAGING_DIR)/mk/
163
	$(INSTALL_DATA) ./files/foris-translations.mk $(STAGING_DIR)/mk/
164 165 166
	$(INSTALL_DATA) ./files/foris-plugin.mk $(STAGING_DIR)/mk/
endef

167 168 169 170 171 172
# $1 = translation name
define ForisTranslation
 define Package/foris-l10n-$(1)
	TITLE:=foris-l10n-$(1)
	DEPENDS:=\
		+foris
173
	MAINTAINER:=CZ.NIC <packaging@turris.cz>
174 175 176
 endef

 define Package/foris-l10n-$(1)/install
177
	$(INSTALL_DIR) $$(1)$(PYTHON3_PKG_DIR)/foris/locale/$(1)/LC_MESSAGES
178
	$(CP) \
179 180 181
		$(PKG_INSTALL_DIR)$(PYTHON3_PKG_DIR)/foris/locale/$(1)/LC_MESSAGES/*.mo \
		$$(1)$(PYTHON3_PKG_DIR)/foris/locale/$(1)/LC_MESSAGES/
	$(INSTALL_DIR) $$(1)$(PYTHON3_PKG_DIR)/foris/langs/
182
	$(CP) \
183 184
		$(PKG_INSTALL_DIR)$(PYTHON3_PKG_DIR)/foris/langs/$(1).py \
		$$(1)$(PYTHON3_PKG_DIR)/foris/langs/
185 186 187 188 189
 endef

 define Package/foris-l10n-$(1)/postrm
#!/bin/sh
set -x
190
[ -n "$$$${IPKG_INSTROOT}" ] || /etc/init.d/lighttpd restart
191 192 193 194 195
 endef

 define Package/foris-l10n-$(1)/postinst
#!/bin/sh
set -x
196
[ -n "$$$${IPKG_INSTROOT}" ] || /etc/init.d/lighttpd restart
197 198 199 200 201 202 203
 endef

endef

# Translation definitions
$(foreach trans,$(FORIS_TRANSLATIONS),$(eval $(call ForisTranslation,$(trans))))

204
$(eval $(call BuildPackage,foris))
205 206
$(foreach trans,$(FORIS_TRANSLATIONS),$(eval $(call BuildPackage,foris-l10n-$(trans))))

207
$(eval $(call Py3Package,foris))
208 209
$(eval $(call BuildPackage,foris-common))
$(eval $(call BuildPackage,foris-config))