summaryrefslogtreecommitdiffstats
path: root/rules/post/install_initramfs.make
blob: 8377be12b1cdaa346b32297b68ad25f434b05668 (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
# -*-makefile-*-
#
# Copyright (C) 2005, 2006, 2007 Robert Schwebel <r.schwebel@pengutronix.de>
#               2008, 2009 by Marc Kleine-Budde <mkl@pengutronix.de>
#               2009 by Jon Ringle <jon@ringle.org>
#
# 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_initramfs
#
# Installs a file with user/group ownership and permissions via
# initramfs.
#
# $1: packet label (not used)
# $2: UID
# $3: GID
# $4: permissions (octal)
# $5: source file
# $6: dest file
#
install_initramfs =										\
	PACKET=$(strip $(1));									\
	OWN=$(strip $(2));									\
	GRP=$(strip $(3));									\
	PER=$(strip $(4));									\
	SRC=$(strip $(5));									\
	DST=$(strip $(6));									\
	PKG_PKGDIR="$(PKGDIR)/$($(PTX_MAP_TO_PACKAGE_$(notdir $(basename $(basename $@)))))";	\
												\
	if [ "$$SRC" = "-" ]; then								\
		SRC=$${PKG_PKGDIR}/$$DST;							\
	fi; 											\
												\
	if [ -z "$(6)" ]; then									\
		echo "install_initramfs:";							\
		echo "  dir=$$SRC";								\
		echo "  owner=$$OWN";								\
		echo "  group=$$GRP";								\
		echo "  permissions=$$PER";							\
		echo "dir $$SRC $$PER $$OWN $$GRP" >> $(INITRAMFS_CONTROL);				\
	else											\
		if [ \! -f "$${SRC}" ]; then							\
			ptxd_bailout "source '$${SRC}' does not exist!";			\
		fi;										\
		echo "install_initramfs:";							\
		echo "  installing $$DST from $$SRC";						\
		echo "  owner=$$OWN";								\
		echo "  group=$$GRP";								\
		echo "  permissions=$$PER"; 							\
		echo "file $$DST $$SRC $$PER $$OWN $$GRP" >> $(INITRAMFS_CONTROL);			\
	fi

#
# install_initramfs_alt
#
# Installs a file with user/group ownership and permissions via
# initramfs.
#
# This macro first looks in $(PTXDIST_WORKSPACE)/initramfs for the file to copy and then
# in $(PTXDIST_TOPDIR)/projectroot/initramfs and installs the file under $(ROOTDIR)
#
# $1: packet label (not used)
# $2: UID
# $3: GID
# $4: permissions (octal)
# $5: source file
#
install_initramfs_alt =										\
	PACKET=$(strip $(1));									\
	OWN=$(strip $(2));									\
	GRP=$(strip $(3));									\
	PER=$(strip $(4));									\
	FILE=$(strip $(5));									\
	PKG_PKGDIR="$(PKGDIR)/$($(PTX_MAP_TO_PACKAGE_$(notdir $(basename $(basename $@)))))";	\
	PKG_DIR="$($(PTX_MAP_TO_PACKAGE_$(notdir $(basename $(basename $@))))_DIR)";		\
												\
	if [ -f $(PTXDIST_WORKSPACE)/initramfs$$FILE$(PTXDIST_PLATFORMSUFFIX) ]; then		\
		SRC=$(PTXDIST_WORKSPACE)/initramfs$$FILE$(PTXDIST_PLATFORMSUFFIX);		\
	elif [ -f $(PTXDIST_WORKSPACE)/initramfs$$FILE ]; then					\
		SRC=$(PTXDIST_WORKSPACE)/initramfs$$FILE;					\
	elif [ -f $(PTXDIST_TOPDIR)/projectroot/initramfs$$FILE ]; then				\
		SRC=$(PTXDIST_TOPDIR)/projectroot/initramfs$$FILE;				\
	elif [ -f $${PKG_PKGDIR}$$FILE ]; then							\
		SRC=$${PKG_PKGDIR}$$FILE;							\
	elif [ -f $${PKG_DIR}$$FILE ]; then							\
		SRC=$${PKG_DIR}$$FILE;								\
	else											\
		echo "initramfs_alt: Search for $$FILE in:";					\
		echo "$(PTXDIST_WORKSPACE)/initramfs$$FILE$(PTXDIST_PLATFORMSUFFIX)";		\
		echo "$(PTXDIST_WORKSPACE)/initramfs$$FILE";					\
		echo "$(PTXDIST_TOPDIR)/projectroot/initramfs$$FILE";				\
		echo "$${PKG_PKGDIR}$$FILE";							\
		echo "$${PKG_DIR}$$FILE";							\
		ptxd_bailout "No suitable file $$FILE found to install";			\
	fi;											\
	echo "install_initramfs_alt:";								\
	echo "  installing $$FILE from $$SRC";							\
	echo "  owner=$$OWN";									\
	echo "  group=$$GRP";									\
	echo "  permissions=$$PER"; 								\
	echo "file $$FILE $$SRC $$PER $$OWN $$GRP" >> $(INITRAMFS_CONTROL)

#
# install_initramfs_link
#
# Installs a soft link in initramfs
#
# $1: packet label (not used)
# $2: source
# $3: destination
# slink <name> <target> <mode> <uid> <gid>
#
install_initramfs_link =							\
	PACKET=$(strip $(1));							\
	SRC=$(strip $(2));							\
	DST=$(strip $(3));							\
	echo "install_initramfs_link: src=$$SRC dst=$$DST "; 			\
	echo "slink $$SRC $$DST 0755 0 0" >> $(INITRAMFS_CONTROL)

#
# install_initramfs_node
#
# Installs a device node via initramfs
#
# $1: packet label (not used)
# $2: UID
# $3: GID
# $4: permissions (octal)
# $5: type
# $6: major
# $7: minor
# $8: device node name
#
install_initramfs_node =		\
	PACKET=$(strip $(1));		\
	OWN=$(strip $(2));		\
	GRP=$(strip $(3));		\
	PER=$(strip $(4));		\
	TYP=$(strip $(5));		\
	MAJ=$(strip $(6));		\
	MIN=$(strip $(7));		\
	DEV=$(strip $(8));		\
	echo "install_initramfs_node:";	\
	echo "  owner=$$OWN";		\
	echo "  group=$$GRP";		\
	echo "  permissions=$$PER";	\
	echo "  type=$$TYP";		\
	echo "  major=$$MAJ";		\
	echo "  minor=$$MIN";		\
	echo "  name=$$DEV";		\
	echo "nod $$DEV $$PER $$OWN $$GRP $$TYP $$MAJ $$MIN" >> $(INITRAMFS_CONTROL)

# vim: syntax=make