aboutsummaryrefslogtreecommitdiff
blob: d6589e9878bacb97e1ae376ca71a08ad7b0e1557 (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
<?xml version="1.0" encoding="UTF-8"?>
<guide self="ebuild-writing/functions/src_install/">
<chapter>
<title>src_install</title>

<body>
<table>
  <tr>
    <th>Function</th>
    <ti><c>src_install</c></ti>
  </tr>
  <tr>
    <th>Purpose</th>
    <ti>Install a package to <c>${D}</c></ti>
  </tr>
  <tr>
    <th>Sandbox</th>
    <ti>Enabled</ti>
  </tr>
  <tr>
    <th>Privilege</th>
    <ti>root</ti>
  </tr>
  <tr>
    <th>Called for</th>
    <ti>ebuild</ti>
  </tr>
</table>
</body>

<section>
<title>Default <c>src_install</c></title>
<body>

<p>
For EAPIs 4 and later, the default <c>src_install</c> function is the following:
</p>
<codesample lang="ebuild">
src_install() {
	if [[ -f Makefile ]] || [[ -f GNUmakefile ]] || [[ -f makefile ]] ; then
		emake DESTDIR="${D}" install
	fi

	if ! declare -p DOCS &gt;/dev/null 2&gt;&amp;1 ; then
		local d
		for d in README* ChangeLog AUTHORS NEWS TODO CHANGES THANKS BUGS \
				FAQ CREDITS CHANGELOG ; do
			[[ -s "${d}" ]] &amp;&amp; dodoc "${d}"
		done
	elif [[ $(declare -p DOCS) == "declare -a"* ]] ; then
		dodoc "${DOCS[@]}"
	else
		dodoc ${DOCS}
	fi
}
</codesample>
<p>
For EAPIs 6 and later, the default <c>src_install</c> function is the following:
</p>
<codesample lang="ebuild">
src_install() {
	if [[ -f Makefile ]] || [[ -f GNUmakefile ]] || [[ -f makefile ]] ; then
		emake DESTDIR="${D}" install
	fi
	einstalldocs
}
</codesample>

</body>
</section>

<section>
<title>Sample <c>src_install</c></title>
<body>

<codesample lang="ebuild">
src_install() {
	emake DESTDIR="${D}" install
	dodoc README CHANGES
}
</codesample>

</body>
</section>

<section>
<title>Easy Installs</title>
<body>
<p>
Often, especially with autotools-powered packages, there is a <c>Makefile</c>
<c>install</c> target which will honour the <c>DESTDIR</c> variable to tell it to
install to a non-root location. If possible, this should be used:
</p>

<codesample lang="ebuild">
	emake DESTDIR="${D}" install
</codesample>

<note>
<c>emake</c> should be used to parallelise here. Some installs are
not designed to be parallelised, use <c>emake -j1</c> or <c>make</c>
if you hit an error.
</note>

<p>
Usually the package's build system will not install the <c>README</c>,
<c>ChangeLog</c>, etc. files, so it is necessary to include additional
<c>dodoc</c> statements for them:
</p>

<codesample lang="ebuild">
	emake DESTDIR="${D}" install
	dodoc README CHANGES
	dodoc -r doc
</codesample>

<p>
<c>dodoc</c> supports <c>-r</c> as the first argument, which allows directories
to be installed recursively.
</p>

<note>
There is no need for <c>dodoc COPYING</c>! The license belongs in the
repository's <c>licenses/</c> directory. Sometimes though, you might want to
install <c>COPYING</c> regardless, if it explains how different licenses are
applied to different parts of the application, for example.
</note>
</body>
</section>

<section>
<title>Trivial Installs</title>
<body>

<p>
For some packages with no <c>Makefile</c> that only install a small
number of files, writing a manual install using <c>cp</c> is the
easiest option. For example, to do a simple install of some (no
compilation required) themes:
</p>

<codesample lang="ebuild">
	dodir /usr/share/foo-styles/
	cp -R "${S}/" "${D}/" || die "Install failed!"
</codesample>

<p>
Or sometimes a combination of <c>insinto</c> and <c>doins</c> (plus related
functions <d/> see <uri link="::function-reference/install-functions/"/>) <d/>
the following is based upon the <c>sys-fs/udev</c> install:
</p>

<codesample lang="ebuild">
src_install() {
	dobin udevinfo
	dobin udevtest
	into /
	dosbin udev
	dosbin udevd
	dosbin udevsend
	dosbin udevstart
	dosbin extras/scsi_id/scsi_id
	dosbin extras/volume_id/udev_volume_id

	exeinto /etc/udev/scripts
	doexe extras/ide-devfs.sh
	doexe extras/scsi-devfs.sh
	doexe extras/cdsymlinks.sh
	doexe extras/dvb.sh

	insinto /etc/udev
	newins "${FILESDIR}/udev.conf.post_050" udev.conf
	doins extras/cdsymlinks.conf

	# For devfs style layout
	insinto /etc/udev/rules.d/
	newins etc/udev/gentoo/udev.rules 50-udev.rules

	# scsi_id configuration
	insinto /etc
	doins extras/scsi_id/scsi_id.config

	# set up symlinks in /etc/hotplug.d/default
	dodir /etc/hotplug.d/default
	dosym ../../../sbin/udevsend /etc/hotplug.d/default/10-udev.hotplug

	# set up the /etc/dev.d directory tree
	dodir /etc/dev.d/default
	dodir /etc/dev.d/net
	exeinto /etc/dev.d/net
	doexe etc/dev.d/net/hotplug.dev

	doman *.8
	doman extras/scsi_id/scsi_id.8

	dodoc ChangeLog FAQ HOWTO-udev_for_dev README TODO
	dodoc docs/{overview,udev-OLS2003.pdf,udev_vs_devfs,RFC-dev.d,libsysfs.txt}
	dodoc docs/persistent_naming/* docs/writing_udev_rules/*

	newdoc extras/volume_id/README README_volume_id
}
</codesample>

<p>
This is, of course, considerably harder to handle than a
simple <c>Makefile</c> driven install.
</p>
</body>
</section>

<section>
<title>Other Installs</title>
<body>
<p>
Sometimes, there will be a <c>Makefile</c> that does not
honour <c>DESTDIR</c> and a non-trivial number of files to install. In
these situations, it is best to patch the <c>Makefile</c> and contact
upstream explaining the situation to them.
</p>
</body>
</section>

<section>
<title><c>src_install</c> Processes</title>
<body>

<p>
The following subsections cover different topics which often occur when writing
<c>src_install</c> functions.
</p>

<contentsTree/>

</body>
</section>
</chapter>

<include href="docompress/"/>
</guide>