lxc: export systemd cgroups after install
[feed/packages.git] / utils / lxc / Makefile
1 #
2 # Copyright (C) 2013-2015 OpenWrt.org
3 # Copyright (C) 2020 Sartura
4 #
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
7 #
8
9 include $(TOPDIR)/rules.mk
10
11 PKG_NAME:=lxc
12 PKG_VERSION:=4.0.12
13 PKG_RELEASE:=$(AUTORELEASE)
14
15 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
16 PKG_SOURCE_URL:=https://linuxcontainers.org/downloads/lxc/
17 PKG_HASH:=db242f8366fc63e8c7588bb2017b354173cf3c4b20abc18780debdc48b14d3ef
18
19 PKG_MAINTAINER:=Marko Ratkaj <markoratkaj@gmail.com>
20 PKG_LICENSE:=LGPL-2.1-or-later BSD-2-Clause GPL-2.0
21
22 PKG_FIXUP:=autoreconf
23 PKG_INSTALL:=1
24 PKG_BUILD_PARALLEL:=1
25 PKG_USE_MIPS16:=0
26
27 include $(INCLUDE_DIR)/package.mk
28
29 LXC_APPLETS_BIN += \
30 attach autostart cgroup copy config console create destroy device \
31 execute freeze info monitor snapshot start stop unfreeze unshare \
32 usernsexec wait top ls
33
34 LXC_APPLETS_LIB += \
35 monitord user-nic
36
37 LXC_SCRIPTS += \
38 checkconfig
39
40 DEPENDS_APPLETS = +libpthread +libcap +liblxc
41
42 DEPENDS_create = +lxc-configs +lxc-hooks +lxc-templates +flock +getopt
43
44 define Package/lxc/Default
45 SECTION:=utils
46 CATEGORY:=Utilities
47 TITLE:=LXC userspace tools
48 URL:=https://linuxcontainers.org/
49 DEPENDS:=lxc
50 endef
51
52 define Package/lxc
53 $(call Package/lxc/Default)
54 DEPENDS:=@!arc
55 MENU:=1
56 endef
57
58 define Package/lxc-auto
59 $(call Package/lxc/Default)
60 TITLE:= (initscript)
61 DEPENDS+=+lxc-start +lxc-stop
62 endef
63
64 define Package/lxc-auto/description
65 LXC is the userspace control package for Linux Containers, a lightweight
66 virtual system mechanism sometimes described as "chroot on steroids".
67 This package adds an initscript for starting and stopping the containers
68 on boot and shutdown.
69 endef
70
71 define Package/lxc-auto/conffiles
72 /etc/config/lxc-auto
73 endef
74
75 define Package/lxc-unprivileged
76 $(call Package/lxc/Default)
77 TITLE:=Helper script for unprivileged containers support
78 DEPENDS+=+shadow-utils +shadow-newuidmap +shadow-newgidmap
79 endef
80
81 define Package/lxc-unprivileged/description
82 Support for unprivileged containers requires newuidmap and newguidmap.
83 This package makes sure they are available & have correct permissions.
84 endef
85
86 define Package/lxc-unprivileged/install
87 $(INSTALL_DIR) $(1)/etc/uci-defaults
88 $(INSTALL_DATA) ./files/lxc-unprivileged.defaults $(1)/etc/uci-defaults/lxc-unprivileged
89 endef
90
91 define Package/lxc/config
92 source "$(SOURCE)/Config.in"
93 endef
94
95 define Package/lxc/description
96 LXC is the userspace control package for Linux Containers, a lightweight
97 virtual system mechanism sometimes described as "chroot on steroids".
98 endef
99
100 define Package/lxc-common
101 $(call Package/lxc/Default)
102 TITLE:=LXC common files
103 endef
104
105 define Package/lxc-hooks
106 $(call Package/lxc/Default)
107 TITLE:=LXC virtual machine hooks
108 endef
109
110 define Package/lxc-templates
111 $(call Package/lxc/Default)
112 TITLE:=LXC virtual machine templates
113 endef
114
115 define Package/lxc-configs
116 $(call Package/lxc/Default)
117 TITLE:=LXC virtual machine common config files
118 endef
119
120 define Package/liblxc
121 $(call Package/lxc/Default)
122 SECTION:=libs
123 CATEGORY:=Libraries
124 TITLE:=LXC userspace library
125 DEPENDS+= +libcap +libpthread +LXC_SECCOMP:libseccomp +libopenssl
126 endef
127
128 define Package/lxc-init
129 $(call Package/lxc/Default)
130 TITLE:=LXC Lua bindings
131 DEPENDS+= +liblxc
132 endef
133
134 CONFIGURE_ARGS += \
135 --disable-werror \
136 --disable-rpath \
137 --disable-doc \
138 --disable-api-docs \
139 --disable-apparmor \
140 --disable-selinux \
141 --$(if $(CONFIG_LXC_SECCOMP),en,dis)able-seccomp \
142 --enable-capabilities \
143 --disable-examples
144
145 ifdef CONFIG_USE_MIPS16
146 TARGET_CFLAGS += -minterlink-mips16
147 endif
148 TARGET_LDFLAGS += -lgcc_eh
149
150 define Build/InstallDev
151 $(INSTALL_DIR) $(1)/usr/include/lxc/
152 $(CP) \
153 $(PKG_INSTALL_DIR)/usr/include/lxc/* \
154 $(1)/usr/include/lxc/
155
156 $(INSTALL_DIR) $(1)/usr/lib
157 $(CP) \
158 $(PKG_INSTALL_DIR)/usr/lib/liblxc.so* \
159 $(1)/usr/lib/
160
161 $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
162 $(CP) \
163 $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/lxc.pc \
164 $(1)/usr/lib/pkgconfig/
165 $(SED) 's,/usr/include,$$$${prefix}/include,g' $(1)/usr/lib/pkgconfig/lxc.pc
166 $(SED) 's,/usr/lib,$$$${prefix}/lib,g' $(1)/usr/lib/pkgconfig/lxc.pc
167 endef
168
169
170 define Package/lxc/install
171 true
172 endef
173
174 define Package/lxc-auto/install
175 $(INSTALL_DIR) $(1)/etc/config $(1)/etc/init.d
176 $(INSTALL_CONF) ./files/lxc-auto.config $(1)/etc/config/lxc-auto
177 $(INSTALL_BIN) ./files/lxc-auto.init $(1)/etc/init.d/lxc-auto
178 endef
179
180 define Package/lxc-auto/postinst
181 [ "$${PKG_UPGRADE}" = "0" ] && /etc/init.d/lxc-auto boot
182 endef
183
184 define Package/lxc-common/conffiles
185 /etc/lxc/default.conf
186 /etc/lxc/lxc.conf
187 endef
188
189 define Package/lxc-common/install
190 $(INSTALL_DIR) $(1)/usr/lib/lxc/rootfs
191 $(CP) \
192 $(PKG_INSTALL_DIR)/usr/lib/lxc/rootfs/README \
193 $(1)/usr/lib/lxc/rootfs/
194
195 $(INSTALL_DIR) $(1)/usr/share/lxc
196 $(CP) \
197 $(PKG_INSTALL_DIR)/usr/share/lxc/lxc.functions \
198 $(1)/usr/share/lxc/
199
200 $(INSTALL_DIR) $(1)/etc/lxc/
201 $(CP) \
202 $(PKG_INSTALL_DIR)/etc/lxc/default.conf \
203 $(1)/etc/lxc/default.conf
204
205 $(INSTALL_DIR) $(1)/etc/lxc/
206 $(CP) \
207 ./files/lxc.conf \
208 $(1)/etc/lxc/lxc.conf
209
210 $(INSTALL_DIR) $(1)/srv/lxc/
211 endef
212
213 define Package/lxc-hooks/install
214 $(INSTALL_DIR) $(1)/usr/share/lxc/hooks
215 $(CP) \
216 $(PKG_INSTALL_DIR)/usr/share/lxc/hooks/* \
217 $(1)/usr/share/lxc/hooks/
218 endef
219
220 define Package/lxc-templates/install
221 $(INSTALL_DIR) $(1)/usr/share/lxc/templates/
222 $(CP) \
223 $(PKG_INSTALL_DIR)/usr/share/lxc/templates/lxc-* \
224 $(1)/usr/share/lxc/templates/
225 endef
226
227 define Package/lxc-configs/install
228 $(INSTALL_DIR) $(1)/usr/share/lxc/config/
229 $(CP) \
230 $(PKG_INSTALL_DIR)/usr/share/lxc/config/* \
231 $(1)/usr/share/lxc/config/
232 endef
233
234 define Package/liblxc/install
235 $(INSTALL_DIR) $(1)/usr/lib/
236 $(CP) \
237 $(PKG_INSTALL_DIR)/usr/lib/liblxc.so* \
238 $(1)/usr/lib/
239 endef
240
241 define Package/lxc-init/install
242 $(INSTALL_DIR) $(1)/sbin
243 $(CP) \
244 $(PKG_INSTALL_DIR)/usr/sbin/init.lxc \
245 $(1)/sbin/
246 endef
247
248 define GenPlugin
249 define Package/lxc-$(1)
250 $(call Package/lxc/Default)
251 TITLE:=Utility lxc-$(1) from the LXC userspace tools
252 DEPENDS+= +lxc-common $(2) $(DEPENDS_$(1))
253 endef
254
255 define Package/lxc-$(1)/install
256 $(INSTALL_DIR) $$(1)$(3)
257 $(INSTALL_BIN) \
258 $(PKG_INSTALL_DIR)$(3)/lxc-$(1) \
259 $$(1)$(3)/
260 endef
261
262 $$(eval $$(call BuildPackage,lxc-$(1)))
263 endef
264
265
266 $(eval $(call BuildPackage,lxc))
267 $(eval $(call BuildPackage,lxc-common))
268 $(eval $(call BuildPackage,lxc-hooks))
269 $(eval $(call BuildPackage,lxc-configs))
270 $(eval $(call BuildPackage,lxc-templates))
271 $(eval $(call BuildPackage,liblxc))
272 $(eval $(call BuildPackage,lxc-init))
273 $(eval $(call BuildPackage,lxc-auto))
274 $(eval $(call BuildPackage,lxc-unprivileged))
275 $(foreach u,$(LXC_APPLETS_BIN),$(eval $(call GenPlugin,$(u),$(DEPENDS_APPLETS),"/usr/bin")))
276 $(foreach u,$(LXC_APPLETS_LIB),$(eval $(call GenPlugin,$(u),$(DEPENDS_APPLETS),"/usr/lib/lxc")))
277 $(foreach u,$(LXC_SCRIPTS),$(eval $(call GenPlugin,$(u),,"/usr/bin")))