summaryrefslogtreecommitdiffstats
path: root/rules/post/install.make
blob: c40e36eb6ac1bf998174bc0aa9ad2afc8a03ff60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
# -*-makefile-*-
#
# Copyright (C) 2005, 2006, 2007 Robert Schwebel <r.schwebel@pengutronix.de>
#               2008, 2009, 2010 by Marc Kleine-Budde <mkl@pengutronix.de>
#
# See CREDITS for details about who has contributed to this project.
#
# For further information about the PTXdist project and license conditions
# see the README file.
#

install_check =										\
	CMD="$(strip $(1))";								\
	if [ ! -f "$(STATEDIR)/$$XPKG.cmds" ]; then					\
		echo;									\
		echo "Error: install_init was not called for package '$$XPKG'!";	\
		echo "This is probably caused by a typo in the package name of:";	\
		echo "\$$(call $$CMD, $$XPKG, ...)";					\
		echo;									\
		exit 1;									\
	fi

#
# install_copy
#
# Installs a file with user/group ownership and permissions via
# fakeroot.
#
# $1: xpkg label
# $2: UID
# $3: GID
# $4: permissions (octal)
#
# a) install src->dst:
#     $5: source (for files); directory (for directories)
#     $6: destination (for files); empty (for directories). Prefixed with
#         $(ROOTDIR), so it needs to have a leading /
#
# b) install from PKG_PKGDIR (result of 'make install'):
#
#     $5: "-": source is taken from $(PKG_PKGDIR)/$destination
#     $6: destination
#
# binaries are stripped automatically
#
install_copy = 											\
	XPKG="$(subst _,-,$(strip $(1)))";							\
	OWN="$(strip $(2))";									\
	GRP="$(strip $(3))";									\
	PER="$(strip $(4))";									\
	SRC="$(strip $(5))";									\
	DST="$(strip $(6))";									\
	STRIP="$(strip $(7))";									\
	$(call install_check, install_copy);							\
	if [ -z "$(6)" ]; then									\
		echo "ptxd_install_dir '$$SRC' '$$OWN' '$$GRP' '$$PER'" >> "$(STATEDIR)/$$XPKG.cmds";\
	else											\
		echo "ptxd_install_file '$$SRC' '$$DST' '$$OWN' '$$GRP' '$$PER' '$$STRIP'" >> "$(STATEDIR)/$$XPKG.cmds";\
	fi

#
# install_alternative
#
# Installs a file with user/group ownership and permissions via
# fakeroot.
#
# This macro first looks in $(PTXDIST_WORKSPACE)/projectroot for the file to copy and then
# in $(PTXDIST_TOPDIR)/projectroot and installs the file under $(ROOTDIR)
#
# $1: xpkg label
# $2: UID
# $3: GID
# $4: permissions (octal)
# $5: source file
# $6: (strip, obsolete)
# $7: destination (optional)
#
install_alternative =									\
	XPKG=$(subst _,-,$(strip $(1)));						\
	OWN=$(strip $(2));								\
	GRP=$(strip $(3));								\
	PER=$(strip $(4));								\
	FILE=$(strip $(5));								\
	STRIP=$(strip $(6));								\
	DST=$(strip $(7));								\
	$(call install_check, install_alternative);					\
	echo "ptxd_install_alternative '$$FILE' '$$DST' '$$OWN' '$$GRP' '$$PER' '$$STRIP'" >> "$(STATEDIR)/$$XPKG.cmds"

#
# install_config
#
# Installs a config file with user/group ownership and permissions via
# fakeroot. Adds filename to conffiles
#
# This macro first looks in $(PTXDIST_WORKSPACE)/projectroot for the file to copy and then
# in $(PTXDIST_TOPDIR)/projectroot and installs the file under $(ROOTDIR)
#
# $1: xpkg label
# $2: UID
# $3: GID
# $4: permissions (octal)
# $5: source file
# $6: (strip, obsolete)
# $7: destination (optional)
#
install_config =									\
	XPKG=$(subst _,-,$(strip $(1)));						\
	OWN=$(strip $(2));								\
	GRP=$(strip $(3));								\
	PER=$(strip $(4));								\
	FILE=$(strip $(5));								\
	STRIP=$(strip $(6));								\
	DST=$(strip $(7));								\
	$(call install_check, install_config);						\
	echo "ptxd_install_config '$$FILE' '$$DST' '$$OWN' '$$GRP' '$$PER' '$$STRIP'" >> "$(STATEDIR)/$$XPKG.cmds"

#
# install_tree
#
# Installs all files and subdirectories with user/group ownership and
# permissions via fakeroot.
#
#
# $1: xpkg label
# $2: OWN, use '-' to use the real UID of each file/directory
# $3: GID, use '-' to use the real GID of each file/directory
# $4: the toplevel directory, or  "-": to use $(PKG_PKGDIR)/$destination
# $5: the target directory.
# $6: strip
#
install_tree =			\
	XPKG=$(subst _,-,$(strip $(1)));	\
	OWN=$(strip $(2));	\
	GRP=$(strip $(3));	\
	DIR=$(strip $(4));	\
	DST=$(strip $(5));	\
	STRIP=$(strip $(6));	\
	$(call install_check, install_tree);	\
	echo "ptxd_install_tree '$$DIR' '$$DST' '$$OWN' '$$GRP' '$$STRIP'" >> "$(STATEDIR)/$$XPKG.cmds"

#
# install_alternative_tree
#
# Installs all files and subdirectories with user/group ownership and
# permissions via fakeroot.
#
#
# $1: xpkg label
# $2: OWN, use '-' to use the real UID of each file/directory
# $3: GID, use '-' to use the real GID of each file/directory
# $4: the toplevel directory, searched for like install_alternative
# $5: strip
# $6: the target directory (optional)
#
install_alternative_tree =	\
	XPKG=$(subst _,-,$(strip $(1)));	\
	OWN=$(strip $(2));	\
	GRP=$(strip $(3));	\
	DIR=$(strip $(4));	\
	STRIP=$(strip $(5));	\
	DST=$(strip $(6));	\
	$(call install_check, install_alternative_tree);	\
	echo "ptxd_install_alternative_tree '$$DIR' '$$DST' '$$OWN' '$$GRP' '$$STRIP'" >> "$(STATEDIR)/$$XPKG.cmds"

#
# install_archive
#
# Installs all files and directories in an archive with user/group ownership and
# permissions via fakeroot.
#
#
# $1: xpkg label
# $2: OWN, use '-' to use the real UID of each file/directory
# $3: GID, use '-' to use the real GID of each file/directory
# $4: the archive
# $5: the target directory.
#
install_archive =		\
	XPKG=$(subst _,-,$(strip $(1)));	\
	OWN=$(strip $(2));	\
	GRP=$(strip $(3));	\
	DIR=$(strip $(4));	\
	DST=$(strip $(5));	\
	$(call install_check, install_archive);	\
	echo "ptxd_install_archive '$$DIR' '$$DST' '$$OWN' '$$GRP'" >> "$(STATEDIR)/$$XPKG.cmds"

#
# install_glob
#
# Installs all files and subdirectories with user/group ownership and
# permissions via fakeroot.
#
#
# $1: xpkg label
# $2: OWN, use '-' to use the real UID of each file/directory
# $3: GID, use '-' to use the real GID of each file/directory
# $4: the toplevel directory, or  "-": to use $(PKG_PKGDIR)/$destination
# $5: the target directory.
# $6: the search patterns for 'find -path'
# $7: the search patterns for '! find -path'
# $8: strip
#
install_glob =			\
	XPKG=$(subst _,-,$(strip $(1)));	\
	OWN=$(strip $(2));	\
	GRP=$(strip $(3));	\
	DIR=$(strip $(4));	\
	DST=$(strip $(5));	\
	YGLOB="$(strip $(6))";	\
	NGLOB="$(strip $(7))";	\
	STRIP=$(strip $(8));	\
	$(call install_check, install_tree);	\
	echo "ptxd_install_glob '$$DIR' '$$DST' '$$YGLOB' '$$NGLOB' '$$OWN' '$$GRP' '$$STRIP'" >> "$(STATEDIR)/$$XPKG.cmds"

#
# install_spec
#
# Installs files specified by a spec file
# format as defined in linux/Documentation/filesystems/ramfs-rootfs-initramfs.txt
#	file  <name> <location> <mode> <uid> <gid>
#	dir   <name> <mode> <uid> <gid>
#	nod   <name> <mode> <uid> <gid> <dev_type> <maj> <min>
#	slink <name> <target> <mode> <uid> <gid>
#
# $1: xpkg label
# $2: spec file to parse
#
install_spec =			\
	XPKG=$(subst _,-,$(strip $(1)));	\
	SPECFILE=$(strip $(2));	\
	$(call install_check, install_spec);	\
	echo "ptxd_install_spec '$$SPECFILE'" >> "$(STATEDIR)/$$XPKG.cmds"

#
# install_package
#
# Installs usefull files and directories in an archive with user/group ownership and
# permissions via fakeroot.
# Usefull means binaries, libs + links, etc.
#
#
# $1: xpkg label
# $2: the toplevel directory
#
install_package =		\
	XPKG=$(subst _,-,$(strip $(1)));	\
	$(call install_check, install_package);	\
	echo "ptxd_install_package" >> "$(STATEDIR)/$$XPKG.cmds"

#
# install_lib
#
# Installs a library + links in an archive with root/root ownership and
# 0644 permissions via fakeroot.
#
#
# $1: xpkg label
# $2: UID
# $3: GID
# $4: permissions (octal)
# $5: library name without suffix.
# $6: optional root dir
#
install_lib =			\
	XPKG=$(subst _,-,$(strip $(1)));	\
	OWN="$(strip $(2))";	\
	GRP="$(strip $(3))";	\
	PER="$(strip $(4))";	\
	LIB=$(strip $(5));	\
	DST=$(strip $(6)); \
	$(call install_check, install_lib);	\
	echo "ptxd_install_lib '$$LIB' '$$DST' '$$OWN' '$$GRP' '$$PER'" >> "$(STATEDIR)/$$XPKG.cmds"

#
# install_replace
#
# Replace placeholder with value in a previously
# installed file
#
# $1: xpkg label
# $2: filename
# $3: placeholder
# $4: value
#
install_replace = \
	XPKG=$(subst _,-,$(strip $(1)));							\
	FILE=$(strip $(2));									\
	PLACEHOLDER=$(strip $(3));								\
	VALUE=$(strip $(4));									\
	$(call install_check, install_replace);							\
	echo "ptxd_install_replace '$$FILE' '$$PLACEHOLDER' '$$VALUE'" >> "$(STATEDIR)/$$XPKG.cmds"

#
# install_replace_figlet
#
# Replace placeholder with `figlet value` in a previously
# installed file
# Note: packages using this need to select host-figlet!
#
# $1: xpkg label
# $2: filename
# $3: placeholder
# $4: value
#
install_replace_figlet = \
	XPKG=$(subst _,-,$(strip $(1)));							\
	FILE=$(strip $(2));									\
	PLACEHOLDER=$(strip $(3));								\
	VALUE=$(strip $(4));									\
	$(call install_check, install_replace);							\
	echo "ptxd_install_replace_figlet '$$FILE' '$$PLACEHOLDER' '$$VALUE'" >> "$(STATEDIR)/$$XPKG.cmds"

#
# install_script_replace
#
# Replace placeholder with value in a script
#
# $1: xpkg label
# $2: script (preinst, postinst, ...)
# $3: placeholder
# $4: value
#
install_script_replace = \
	XPKG=$(subst _,-,$(strip $(1)));							\
	FILE=$(strip $(2));									\
	PLACEHOLDER=$(strip $(3));								\
	VALUE=$(strip $(4));									\
	$(call install_check, install_script_replace);						\
	echo "ptxd_install_script_replace '$$FILE' '$$PLACEHOLDER' '$$VALUE'" >> "$(STATEDIR)/$$XPKG.cmds"

#
# install_copy_toolchain_lib
#
# $1: xpkg label
# $2: source
# $3: destination
# $4: strip (y|n)	default is to strip
#
install_copy_toolchain_lib =									\
	XPKG=$(subst _,-,$(strip $(1)));							\
	LIB="$(strip $2)";									\
	DST="$(strip $3)";									\
	STRIP="$(strip $4)";									\
	test "$${DST}" != "" && DST="-d $${DST}";						\
	$(call install_check, install_copy_toolchain_lib);					\
	${CROSS_ENV_CC} $(CROSS_ENV_STRIP) PKGDIR="$(PKGDIR)"					\
		$(SCRIPTSDIR)/install_copy_toolchain.sh -p "$${XPKG}" -l "$${LIB}" $${DST} -s "$${STRIP}"

#
# install_copy_toolchain_dl
#
# $1: xpkg label
# $2: strip (y|n)	default is to strip
#
install_copy_toolchain_dl =									\
	XPKG=$(subst _,-,$(strip $(1)));							\
	STRIP="$(strip $2)";									\
	$(call install_check, install_copy_toolchain_dl);					\
	${CROSS_ENV_CC} $(CROSS_ENV_STRIP) PKGDIR="$(PKGDIR)"					\
		$(SCRIPTSDIR)/install_copy_toolchain.sh -p "$${XPKG}" -l LINKER -s "$${STRIP}"

#
# install_copy_toolchain_other
#
# $1: xpkg label
# $2: source
# $3: destination
# $4: strip (y|n)	default is to strip
#
install_copy_toolchain_usr =									\
	XPKG=$(subst _,-,$(strip $(1)));							\
	LIB="$(strip $2)";									\
	DST="$(strip $3)";									\
	STRIP="$(strip $4)";									\
	test "$${DST}" != "" && DST="-d $${DST}";						\
	$(call install_check, install_copy_toolchain_other);					\
	${CROSS_ENV_CC} $(CROSS_ENV_STRIP) PKGDIR="$(PKGDIR)"					\
		$(SCRIPTSDIR)/install_copy_toolchain.sh -p "$${XPKG}" -u "$${LIB}" $${DST} -s "$${STRIP}"

#
# install_link
#
# Installs a soft link in root directory in an xpkg package
#
# $1: xpkg label
# $2: source
# $3: destination
#
install_link =									\
	XPKG=$(subst _,-,$(strip $(1)));					\
	SRC=$(strip $(2));							\
	DST=$(strip $(3));							\
	$(call install_check, install_link);					\
	echo "ptxd_install_link '$$SRC' '$$DST'" >> "$(STATEDIR)/$$XPKG.cmds"

#
# install_node
#
# Installs a device node in root directory in an xpkg package
#
# $1: xpkg label
# $2: UID
# $3: GID
# $4: permissions (octal)
# $5: type
# $6: major
# $7: minor
# $8: device node name
#
install_node =				\
	XPKG=$(subst _,-,$(strip $(1)));\
	OWN=$(strip $(2));		\
	GRP=$(strip $(3));		\
	PER=$(strip $(4));		\
	TYP=$(strip $(5));		\
	MAJ=$(strip $(6));		\
	MIN=$(strip $(7));		\
	DEV=$(strip $(8));		\
	$(call install_check, install_node);	\
	echo "ptxd_install_node '$$DEV' '$$OWN' '$$GRP' '$$PER' '$$TYP' '$$MAJ' '$$MIN'" >> "$(STATEDIR)/$$XPKG.cmds"

# vim: syntax=make