buildsystem: add CONFIG_SECCOMP
[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_RELEASE:=$(AUTORELEASE)
12
13 PKG_SOURCE_PROTO:=git
14 PKG_SOURCE_URL=$(PROJECT_GIT)/project/procd.git
15 PKG_SOURCE_DATE:=2021-10-13
16 PKG_SOURCE_VERSION:=82dd39024f63e53becd07c89831ed7d5fac7f339
17 PKG_MIRROR_HASH:=a9449894b4ce0b2860680c1691270d5fe9c84e4eecd48008ed732ef2d19af7db
18 CMAKE_INSTALL:=1
19
20 PKG_LICENSE:=GPL-2.0
21 PKG_LICENSE_FILES:=
22
23 PKG_MAINTAINER:=John Crispin <john@phrozen.org>
24
25 PKG_ASLR_PIE_REGULAR:=1
26 PKG_CONFIG_DEPENDS:= \
27 CONFIG_TARGET_INIT_PATH CONFIG_KERNEL_SECCOMP \
28 CONFIG_PROCD_SHOW_BOOT CONFIG_PROCD_ZRAM_TMPFS \
29 CONFIG_KERNEL_NAMESPACES CONFIG_PACKAGE_procd-ujail CONFIG_PACKAGE_procd-seccomp
30
31 include $(INCLUDE_DIR)/package.mk
32 include $(INCLUDE_DIR)/cmake.mk
33
34 ifeq ($(DUMP),)
35 STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell echo $(CONFIG_TARGET_INIT_PATH) | $(MKHASH) md5)
36 endif
37
38 CMAKE_OPTIONS += -DEARLY_PATH="$(TARGET_INIT_PATH)"
39 TARGET_LDFLAGS += $(if $(CONFIG_USE_GLIBC),-lrt)
40
41 TARGET_CFLAGS += -flto
42 TARGET_LDFLAGS += -flto
43
44 define Package/procd/Default
45 SECTION:=base
46 CATEGORY:=Base system
47 DEPENDS:=+ubusd +ubus +libjson-script +ubox +USE_GLIBC:librt +libubox \
48 +libubus +libblobmsg-json +libjson-c +jshn
49 TITLE:=OpenWrt system process manager
50 USERID:=:dialout=20 :audio=29
51 endef
52
53 define Package/procd
54 $(call Package/procd/Default)
55 VARIANT:=default
56 CONFLICTS:=procd-selinux
57 endef
58
59 define Package/procd-selinux
60 $(call Package/procd/Default)
61 DEPENDS += +libselinux
62 TITLE += with SELinux support
63 PROVIDES:=procd
64 VARIANT:=selinux
65 endef
66
67 define Package/procd-ujail
68 SECTION:=base
69 CATEGORY:=Base system
70 DEPENDS:=@KERNEL_NAMESPACES +@KERNEL_UTS_NS +@KERNEL_IPC_NS +@KERNEL_PID_NS \
71 +libubox +libubus +libuci +libblobmsg-json
72 TITLE:=OpenWrt process jail helper
73 endef
74
75 define Package/procd-ujail-console
76 SECTION:=base
77 CATEGORY:=Base system
78 DEPENDS:=+procd-ujail +libubus +libubox
79 TITLE:=OpenWrt process jail console
80 endef
81
82 define Package/procd-seccomp
83 SECTION:=base
84 CATEGORY:=Base system
85 DEPENDS:=@SECCOMP +libubox +libblobmsg-json
86 TITLE:=OpenWrt process seccomp helper + utrace
87 endef
88
89 define Package/uxc
90 SECTION:=base
91 CATEGORY:=Base system
92 DEPENDS:=+procd-ujail +libubus +libubox +libblobmsg-json +blockd +rpcd
93 TITLE:=OpenWrt container management
94 MAINTAINER:=Daniel Golle <daniel@makrotopia.org>
95 endef
96
97 define Package/procd/config
98 menu "Configuration"
99 depends on PACKAGE_procd || PACKAGE_procd-selinux
100
101 config PROCD_SHOW_BOOT
102 bool
103 default n
104 prompt "Print the shutdown to the console as well as logging it to syslog"
105
106 config PROCD_ZRAM_TMPFS
107 bool
108 default n
109 prompt "Mount /tmp using zram."
110 endmenu
111 endef
112
113 ifeq ($(BUILD_VARIANT),selinux)
114 CMAKE_OPTIONS += -DSELINUX=1
115 endif
116
117 ifeq ($(CONFIG_PROCD_SHOW_BOOT),y)
118 CMAKE_OPTIONS += -DSHOW_BOOT_ON_CONSOLE=1
119 endif
120
121 ifeq ($(CONFIG_PROCD_ZRAM_TMPFS),y)
122 CMAKE_OPTIONS += -DZRAM_TMPFS=1
123 endif
124
125 ifdef CONFIG_PACKAGE_procd-ujail
126 CMAKE_OPTIONS += -DJAIL_SUPPORT=1
127 endif
128
129 SECCOMP=$(if $(CONFIG_PACKAGE_procd-seccomp),1,0)
130 CMAKE_OPTIONS += -DSECCOMP_SUPPORT=$(SECCOMP) -DUTRACE_SUPPORT=$(SECCOMP)
131
132 define Package/procd/install
133 $(INSTALL_DIR) $(1)/sbin $(1)/etc $(1)/lib/functions
134
135 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/{init,procd,askfirst,udevtrigger,upgraded} $(1)/sbin/
136 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libsetlbf.so $(1)/lib
137 $(INSTALL_BIN) ./files/reload_config $(1)/sbin/
138 $(INSTALL_CONF) ./files/hotplug*.json $(1)/etc/
139 $(INSTALL_DATA) ./files/procd.sh $(1)/lib/functions/
140 endef
141
142 Package/procd-selinux/install = $(Package/procd/install)
143
144 define Package/procd-ujail/install
145 $(INSTALL_DIR) $(1)/sbin
146 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ujail $(1)/sbin/
147 endef
148
149 define Package/procd-ujail-console/install
150 $(INSTALL_DIR) $(1)/sbin
151 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ujail-console $(1)/sbin/
152 endef
153
154 define Package/procd-seccomp/install
155 $(INSTALL_DIR) $(1)/sbin $(1)/lib
156 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libpreload-seccomp.so $(1)/lib
157 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/utrace $(1)/sbin/
158 $(LN) utrace $(1)/sbin/seccomp-trace
159 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libpreload-trace.so $(1)/lib
160 endef
161
162 define Package/uxc/conffiles
163 /etc/uxc
164 endef
165
166 define Package/uxc/install
167 $(INSTALL_DIR) $(1)/sbin
168 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/uxc $(1)/sbin/
169 $(INSTALL_DIR) $(1)/etc/init.d
170 $(INSTALL_BIN) ./files/uxc.init $(1)/etc/init.d/uxc
171 endef
172
173 $(eval $(call BuildPackage,procd))
174 $(eval $(call BuildPackage,procd-selinux))
175 $(eval $(call BuildPackage,procd-ujail))
176 $(eval $(call BuildPackage,procd-ujail-console))
177 $(eval $(call BuildPackage,procd-seccomp))
178 $(eval $(call BuildPackage,uxc))