fe4dbfbe120d5234b0be7ff3dd758fd66b5649c5
[openwrt/openwrt.git] / package / system / procd / Makefile
1 #
2 # Copyright (C) 2014-2016 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 include $(TOPDIR)/rules.mk
9
10 PKG_NAME:=procd
11 PKG_VERSION:=2016-10-15
12
13 PKG_RELEASE=$(PKG_SOURCE_VERSION)
14
15 PKG_SOURCE_PROTO:=git
16 PKG_SOURCE_URL=$(LEDE_GIT)/project/procd.git
17 PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
18 PKG_SOURCE_VERSION:=d1e14deae2ea28935280c3a2a6609549761619bc
19 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz
20 PKG_MIRROR_MD5SUM:=06641ea55df6ab98e714728780b23c60cc9353e0686ec440bf03f0241a63dbaf
21 CMAKE_INSTALL:=1
22
23 PKG_LICENSE:=GPL-2.0
24 PKG_LICENSE_FILES:=
25
26 PKG_MAINTAINER:=John Crispin <john@phrozen.org>
27
28 PKG_FLAGS:=nonshared
29
30 PKG_CONFIG_DEPENDS:= \
31 CONFIG_TARGET_INIT_PATH CONFIG_KERNEL_SECCOMP \
32 CONFIG_NAND_SUPPORT CONFIG_PROCD_SHOW_BOOT CONFIG_PROCD_ZRAM_TMPFS \
33 CONFIG_KERNEL_NAMESPACES CONFIG_PACKAGE_procd-ujail CONFIG_PACKAGE_procd-seccomp
34
35 include $(INCLUDE_DIR)/package.mk
36 include $(INCLUDE_DIR)/cmake.mk
37
38 ifeq ($(DUMP),)
39 STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell $(SH_FUNC) echo $(CONFIG_TARGET_INIT_PATH) | md5s)
40 endif
41
42 CMAKE_OPTIONS += -DEARLY_PATH="$(TARGET_INIT_PATH)"
43 TARGET_LDFLAGS += $(if $(CONFIG_USE_GLIBC),-lrt)
44
45 define Package/procd
46 SECTION:=base
47 CATEGORY:=Base system
48 DEPENDS:=+ubusd +ubus +libjson-script +ubox +USE_GLIBC:librt +libubox +libubus +NAND_SUPPORT:procd-nand
49 TITLE:=OpenWrt system process manager
50 endef
51
52 define Package/procd-ujail
53 SECTION:=base
54 CATEGORY:=Base system
55 DEPENDS:=@KERNEL_NAMESPACES +@KERNEL_UTS_NS +@KERNEL_IPC_NS +@KERNEL_PID_NS +libubox +libblobmsg-json
56 TITLE:=OpenWrt process jail helper
57 endef
58
59 define Package/procd-seccomp
60 SECTION:=base
61 CATEGORY:=Base system
62 DEPENDS:=@arm||@armeb||@mips||@mipsel||@i386||@x86_64 @!TARGET_uml @KERNEL_SECCOMP +libubox +libblobmsg-json
63 TITLE:=OpenWrt process seccomp helper + utrace
64 endef
65
66 define Package/procd-nand
67 SECTION:=utils
68 CATEGORY:=Utilities
69 DEPENDS:=@NAND_SUPPORT +ubi-utils
70 TITLE:=OpenWrt sysupgrade nand helper
71 endef
72
73 define Package/procd-nand-firstboot
74 SECTION:=utils
75 CATEGORY:=Utilities
76 DEPENDS:=procd-nand
77 TITLE:=OpenWrt firstboot nand helper
78 endef
79
80 define Package/procd/config
81 menu "Configuration"
82 depends on PACKAGE_procd
83
84 config PROCD_SHOW_BOOT
85 bool
86 default n
87 prompt "Print the shutdown to the console as well as logging it to syslog"
88
89 config PROCD_ZRAM_TMPFS
90 bool
91 default n
92 prompt "Mount /tmp using zram."
93 endmenu
94 endef
95
96
97 ifeq ($(CONFIG_NAND_SUPPORT),y)
98 CMAKE_OPTIONS += -DBUILD_UPGRADED=1
99 endif
100
101 ifeq ($(CONFIG_PROCD_SHOW_BOOT),y)
102 CMAKE_OPTIONS += -DSHOW_BOOT_ON_CONSOLE=1
103 endif
104
105 ifeq ($(CONFIG_PROCD_ZRAM_TMPFS),y)
106 CMAKE_OPTIONS += -DZRAM_TMPFS=1
107 endif
108
109 ifdef CONFIG_PACKAGE_procd-ujail
110 CMAKE_OPTIONS += -DJAIL_SUPPORT=1
111 endif
112
113 ifdef CONFIG_PACKAGE_procd-seccomp
114 CMAKE_OPTIONS += -DSECCOMP_SUPPORT=1 -DUTRACE_SUPPORT=1
115 endif
116
117 define Package/procd/install
118 $(INSTALL_DIR) $(1)/sbin $(1)/etc $(1)/lib/functions
119
120 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/{init,procd,askfirst,udevtrigger} $(1)/sbin/
121 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libsetlbf.so $(1)/lib
122 $(INSTALL_BIN) ./files/reload_config $(1)/sbin/
123 $(INSTALL_DATA) ./files/hotplug*.json $(1)/etc/
124 $(INSTALL_DATA) ./files/procd.sh $(1)/lib/functions/
125 endef
126
127 define Package/procd-ujail/install
128 $(INSTALL_DIR) $(1)/sbin
129 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ujail $(1)/sbin/
130 endef
131
132 define Package/procd-seccomp/install
133 $(INSTALL_DIR) $(1)/sbin $(1)/lib
134 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libpreload-seccomp.so $(1)/lib
135 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/utrace $(1)/sbin/
136 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libpreload-trace.so $(1)/lib
137 endef
138
139 define Package/procd-nand/install
140 $(INSTALL_DIR) $(1)/sbin $(1)/lib/upgrade
141
142 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/upgraded $(1)/sbin/
143 $(INSTALL_DATA) ./files/nand.sh $(1)/lib/upgrade/
144 endef
145
146 define Package/procd-nand-firstboot/install
147 $(INSTALL_DIR) $(1)/lib/preinit
148
149 $(INSTALL_DATA) ./files/nand-preinit.sh $(1)/lib/preinit/60-nand-firstboot.sh
150 endef
151
152 $(eval $(call BuildPackage,procd))
153 $(eval $(call BuildPackage,procd-ujail))
154 $(eval $(call BuildPackage,procd-seccomp))
155 $(eval $(call BuildPackage,procd-nand))
156 $(eval $(call BuildPackage,procd-nand-firstboot))