procd: add jail support
[openwrt/staging/chunkeey.git] / package / system / procd / Makefile
1 #
2 # Copyright (C) 2014-2015 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:=2015-03-25
12
13 PKG_RELEASE=$(PKG_SOURCE_VERSION)
14
15 PKG_SOURCE_PROTO:=git
16 PKG_SOURCE_URL:=git://nbd.name/luci2/procd.git
17 PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
18 PKG_SOURCE_VERSION:=29f139217c71c8753643779c800788783bf43c23
19 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
20 CMAKE_INSTALL:=1
21
22 PKG_LICENSE:=GPL-2.0
23 PKG_LICENSE_FILES:=
24
25 PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
26
27 PKG_CONFIG_DEPENDS:=CONFIG_KERNEL_SECCOMP
28
29 include $(INCLUDE_DIR)/package.mk
30 include $(INCLUDE_DIR)/cmake.mk
31
32 TARGET_LDFLAGS += $(if $(CONFIG_USE_GLIBC),-lrt)
33
34 define Package/procd
35 SECTION:=base
36 CATEGORY:=Base system
37 DEPENDS:=+ubusd +ubus +libjson-script +ubox +USE_GLIBC:librt +libubox +libubus +NAND_SUPPORT:procd-nand
38 TITLE:=OpenWrt system process manager
39 endef
40
41 define Package/procd-jail
42 SECTION:=base
43 CATEGORY:=Base system
44 DEPENDS:=procd +@KERNEL_NAMESPACES +@KERNEL_UTS_NS +@KERNEL_IPC_NS +@KERNEL_PID_NS @mips||mipsel||i386||x86_64
45 TITLE:=OpenWrt process jail
46 DEFAULT:=n
47 endef
48
49 define Package/procd-nand
50 SECTION:=utils
51 CATEGORY:=Utilities
52 DEPENDS:=@NAND_SUPPORT +ubi-utils
53 TITLE:=OpenWrt sysupgrade nand helper
54 endef
55
56 define Package/procd-nand-firstboot
57 SECTION:=utils
58 CATEGORY:=Utilities
59 DEPENDS:=procd-nand
60 TITLE:=OpenWrt firstboot nand helper
61 endef
62
63 define Package/procd/config
64 menu "Configuration"
65 depends on PACKAGE_procd
66
67 config PROCD_SHOW_BOOT
68 bool
69 default n
70 prompt "Print the shutdown to the console as well as logging it to syslog"
71
72 config PROCD_ZRAM_TMPFS
73 bool
74 default n
75 prompt "Mount /tmp using zram."
76 endmenu
77 endef
78
79 PKG_CONFIG_DEPENDS:= CONFIG_NAND_SUPPORT CONFIG_PROCD_SHOW_BOOT CONFIG_PROCD_ZRAM_TMPFS
80
81 ifeq ($(CONFIG_NAND_SUPPORT),y)
82 CMAKE_OPTIONS += -DBUILD_UPGRADED=1
83 endif
84
85 ifeq ($(CONFIG_PROCD_SHOW_BOOT),y)
86 CMAKE_OPTIONS += -DSHOW_BOOT_ON_CONSOLE=1
87 endif
88
89 ifeq ($(CONFIG_PROCD_ZRAM_TMPFS),y)
90 CMAKE_OPTIONS += -DZRAM_TMPFS=1
91 endif
92
93 define Package/procd/install
94 $(INSTALL_DIR) $(1)/sbin $(1)/etc $(1)/lib/functions
95
96 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/{init,procd,askfirst,udevtrigger} $(1)/sbin/
97 $(INSTALL_BIN) ./files/reload_config $(1)/sbin/
98 $(INSTALL_DATA) ./files/hotplug*.json $(1)/etc/
99 $(INSTALL_DATA) ./files/procd.sh $(1)/lib/functions/
100 ifeq ($(CONFIG_KERNEL_SECCOMP),y)
101 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libpreload-seccomp.so $(1)/lib
102 endif
103 endef
104
105 define Package/procd-jail/install
106 $(INSTALL_DIR) $(1)/sbin $(1)/lib
107
108 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/{utrace,ujail} $(1)/sbin/
109 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libpreload-trace.so $(1)/lib
110 endef
111
112 define Package/procd-nand/install
113 $(INSTALL_DIR) $(1)/sbin $(1)/lib/upgrade
114
115 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/upgraded $(1)/sbin/
116 $(INSTALL_DATA) ./files/nand.sh $(1)/lib/upgrade/
117 endef
118
119 define Package/procd-nand-firstboot/install
120 $(INSTALL_DIR) $(1)/lib/preinit
121
122 $(INSTALL_DATA) ./files/nand-preinit.sh $(1)/lib/preinit/60-nand-firstboot.sh
123 endef
124
125 $(eval $(call BuildPackage,procd))
126 $(eval $(call BuildPackage,procd-jail))
127 $(eval $(call BuildPackage,procd-nand))
128 $(eval $(call BuildPackage,procd-nand-firstboot))