Fresh pull from upstream
[librecmc/librecmc.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:=1
12
13 PKG_SOURCE_PROTO:=git
14 PKG_SOURCE_URL=$(LEDE_GIT)/project/procd.git
15 PKG_SOURCE_DATE:=2017-01-10
16 PKG_SOURCE_VERSION:=f7069032290a9720142b2ee2c6315d7e1f1a1bd3
17 PKG_MIRROR_HASH:=3917269c1ed1f9b6d4a8f5559b2cdec6f91da3ad00ffe5375b5680f9e230b21d
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_FLAGS:=nonshared
26
27 PKG_CONFIG_DEPENDS:= \
28         CONFIG_TARGET_INIT_PATH CONFIG_KERNEL_SECCOMP \
29         CONFIG_NAND_SUPPORT CONFIG_PROCD_SHOW_BOOT CONFIG_PROCD_ZRAM_TMPFS \
30         CONFIG_KERNEL_NAMESPACES CONFIG_PACKAGE_procd-ujail CONFIG_PACKAGE_procd-seccomp
31
32 include $(INCLUDE_DIR)/package.mk
33 include $(INCLUDE_DIR)/cmake.mk
34
35 ifeq ($(DUMP),)
36   STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell echo $(CONFIG_TARGET_INIT_PATH) | mkhash md5)
37 endif
38
39 CMAKE_OPTIONS += -DEARLY_PATH="$(TARGET_INIT_PATH)"
40 TARGET_LDFLAGS += $(if $(CONFIG_USE_GLIBC),-lrt)
41
42 define Package/procd
43   SECTION:=base
44   CATEGORY:=Base system
45   DEPENDS:=+ubusd +ubus +libjson-script +ubox +USE_GLIBC:librt +libubox +libubus +NAND_SUPPORT:procd-nand
46   TITLE:=OpenWrt system process manager
47 endef
48
49 define Package/procd-ujail
50   SECTION:=base
51   CATEGORY:=Base system
52   DEPENDS:=@KERNEL_NAMESPACES +@KERNEL_UTS_NS +@KERNEL_IPC_NS +@KERNEL_PID_NS +libubox +libblobmsg-json
53   TITLE:=OpenWrt process jail helper
54 endef
55
56 define Package/procd-seccomp
57   SECTION:=base
58   CATEGORY:=Base system
59   DEPENDS:=@arm||@armeb||@mips||@mipsel||@i386||@x86_64 @!TARGET_uml @KERNEL_SECCOMP +libubox +libblobmsg-json
60   TITLE:=OpenWrt process seccomp helper + utrace
61 endef
62
63 define Package/procd-nand
64   SECTION:=utils
65   CATEGORY:=Utilities
66   DEPENDS:=@NAND_SUPPORT +ubi-utils
67   TITLE:=OpenWrt sysupgrade nand helper
68 endef
69
70 define Package/procd-nand-firstboot
71   SECTION:=utils
72   CATEGORY:=Utilities
73   DEPENDS:=procd-nand
74   TITLE:=OpenWrt firstboot nand helper
75 endef
76
77 define Package/procd/config
78 menu "Configuration"
79         depends on PACKAGE_procd
80
81 config PROCD_SHOW_BOOT
82         bool
83         default n
84         prompt "Print the shutdown to the console as well as logging it to syslog"
85
86 config PROCD_ZRAM_TMPFS
87         bool
88         default n
89         prompt "Mount /tmp using zram."
90 endmenu
91 endef
92
93
94 ifeq ($(CONFIG_NAND_SUPPORT),y)
95   CMAKE_OPTIONS += -DBUILD_UPGRADED=1
96 endif
97
98 ifeq ($(CONFIG_PROCD_SHOW_BOOT),y)
99   CMAKE_OPTIONS += -DSHOW_BOOT_ON_CONSOLE=1
100 endif
101
102 ifeq ($(CONFIG_PROCD_ZRAM_TMPFS),y)
103   CMAKE_OPTIONS += -DZRAM_TMPFS=1
104 endif
105
106 ifdef CONFIG_PACKAGE_procd-ujail
107   CMAKE_OPTIONS += -DJAIL_SUPPORT=1
108 endif
109
110 ifdef CONFIG_PACKAGE_procd-seccomp
111   CMAKE_OPTIONS += -DSECCOMP_SUPPORT=1 -DUTRACE_SUPPORT=1
112 endif
113
114 define Package/procd/install
115         $(INSTALL_DIR) $(1)/sbin $(1)/etc $(1)/lib/functions
116
117         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/{init,procd,askfirst,udevtrigger} $(1)/sbin/
118         $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libsetlbf.so $(1)/lib
119         $(INSTALL_BIN) ./files/reload_config $(1)/sbin/
120         $(INSTALL_DATA) ./files/hotplug*.json $(1)/etc/
121         $(INSTALL_DATA) ./files/procd.sh $(1)/lib/functions/
122 endef
123
124 define Package/procd-ujail/install
125         $(INSTALL_DIR) $(1)/sbin
126         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ujail $(1)/sbin/
127 endef
128
129 define Package/procd-seccomp/install
130         $(INSTALL_DIR) $(1)/sbin $(1)/lib
131         $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libpreload-seccomp.so $(1)/lib
132         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/utrace $(1)/sbin/
133         $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libpreload-trace.so $(1)/lib
134 endef
135
136 define Package/procd-nand/install
137         $(INSTALL_DIR) $(1)/sbin $(1)/lib/upgrade
138
139         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/upgraded $(1)/sbin/
140         $(INSTALL_DATA) ./files/nand.sh $(1)/lib/upgrade/
141 endef
142
143 define Package/procd-nand-firstboot/install
144         $(INSTALL_DIR) $(1)/lib/preinit
145
146         $(INSTALL_DATA) ./files/nand-preinit.sh $(1)/lib/preinit/60-nand-firstboot.sh
147 endef
148
149 $(eval $(call BuildPackage,procd))
150 $(eval $(call BuildPackage,procd-ujail))
151 $(eval $(call BuildPackage,procd-seccomp))
152 $(eval $(call BuildPackage,procd-nand))
153 $(eval $(call BuildPackage,procd-nand-firstboot))