Replace $Header: $ with $Id$ where it has accidentally been reverted
[gentoo.git] / sys-kernel / dracut / dracut-040-r3.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=4
6
7 inherit bash-completion-r1 eutils linux-info multilib systemd
8
9 DESCRIPTION="Generic initramfs generation tool"
10 HOMEPAGE="http://dracut.wiki.kernel.org"
11 SRC_URI="mirror://kernel/linux/utils/boot/${PN}/${P}.tar.xz"
12 LICENSE="GPL-2"
13 SLOT="0"
14 KEYWORDS="~alpha ~amd64 ~arm ~ia64 ~ppc ~ppc64 ~sparc ~x86"
15 IUSE="debug selinux systemd"
16
17 RESTRICT="test"
18
19 CDEPEND="virtual/udev
20         systemd? ( >=sys-apps/systemd-199 )
21         "
22 RDEPEND="${CDEPEND}
23         app-arch/cpio
24         >=app-shells/bash-4.0
25         >sys-apps/kmod-5[tools]
26         || ( >=sys-apps/sysvinit-2.87-r3 sys-apps/systemd[sysv-utils] sys-apps/systemd-sysv-utils )
27         >=sys-apps/util-linux-2.21
28
29         debug? ( dev-util/strace )
30         selinux? (
31                 sys-libs/libselinux
32                 sys-libs/libsepol
33                 sec-policy/selinux-dracut
34         )
35         "
36 DEPEND="${CDEPEND}
37         app-text/asciidoc
38         >=dev-libs/libxslt-1.1.26
39         app-text/docbook-xml-dtd:4.5
40         >=app-text/docbook-xsl-stylesheets-1.75.2
41         virtual/pkgconfig
42         "
43
44 DOCS=( AUTHORS HACKING NEWS README README.generic README.kernel README.modules
45         README.testsuite TODO )
46 MY_LIBDIR=/usr/lib
47 PATCHES=(
48         "${FILESDIR}/${PV}-0001-dracut-functions.sh-support-for-altern.patch"
49         "${FILESDIR}/${PV}-0002-gentoo.conf-let-udevdir-be-handled-by-.patch"
50         "${FILESDIR}/${PV}-0003-Use-the-same-paths-in-dracut.sh-as-tho.patch"
51         "${FILESDIR}/${PV}-0005-NEWS-add-040-entry.patch"
52         "${FILESDIR}/${PV}-0006-Don-t-pass-rsyncable-option-to-gzip-Ge.patch"
53         "${FILESDIR}/${PV}-0007-Take-into-account-lib64-dirs-when-dete.patch"
54         )
55 QA_MULTILIB_PATHS="
56         usr/lib/dracut/dracut-install
57         usr/lib/dracut/skipcpio
58         "
59
60 #
61 # Helper functions
62 #
63
64 # Removes module from modules.d.
65 # $1 = module name
66 # Module name can be specified without number prefix.
67 rm_module() {
68         local force m
69         [[ $1 = -f ]] && force=-f
70
71         for m in $@; do
72                 if [[ $m =~ ^[0-9][0-9][^\ ]*$ ]]; then
73                         rm ${force} --interactive=never -r "${modules_dir}"/$m
74                 else
75                         rm ${force} --interactive=never -r "${modules_dir}"/[0-9][0-9]$m
76                 fi
77         done
78 }
79
80 # Grabbed from net-misc/netctl ebuild.
81 optfeature() {
82         local desc=$1
83         shift
84         while (( $# )); do
85                 if has_version "$1"; then
86                         elog "  [I] $1 to ${desc}"
87                 else
88                         elog "  [ ] $1 to ${desc}"
89                 fi
90                 shift
91         done
92 }
93
94 #
95 # ebuild functions
96 #
97
98 src_prepare() {
99         epatch "${PATCHES[@]}"
100
101         local libdirs="/$(get_libdir) /usr/$(get_libdir)"
102         if [[ ${SYMLINK_LIB} = yes ]]; then
103                 # Preserve lib -> lib64 symlinks in initramfs
104                 [[ $libdirs =~ /lib\  ]] || libdirs+=" /lib /usr/lib"
105         fi
106         einfo "Setting libdirs to \"${libdirs}\" ..."
107         sed -e "3alibdirs=\"${libdirs}\"" \
108                 -i "${S}/dracut.conf.d/gentoo.conf.example" || die
109
110         local udevdir="$("$(tc-getPKG_CONFIG)" udev --variable=udevdir)"
111         einfo "Setting udevdir to ${udevdir}..."
112         sed -r -e "s|^(udevdir=).*$|\1${udevdir}|" \
113                         -i "${S}/dracut.conf.d/gentoo.conf.example" || die
114
115         if use systemd; then
116                 local systemdutildir="$(systemd_get_utildir)"
117                 local systemdsystemunitdir="$(systemd_get_unitdir)"
118                 local systemdsystemconfdir="$("$(tc-getPKG_CONFIG)" systemd \
119                         --variable=systemdsystemconfdir)"
120                 [[ ${systemdsystemconfdir} ]] \
121                         || systemdsystemconfdir=/etc/systemd/system
122                 einfo "Setting systemdutildir to ${systemdutildir} and ..."
123                 sed -e "5asystemdutildir=\"${systemdutildir}\"" \
124                         -i "${S}/dracut.conf.d/gentoo.conf.example" || die
125                 einfo "Setting systemdsystemunitdir to ${systemdsystemunitdir} and..."
126                 sed -e "6asystemdsystemunitdir=\"${systemdsystemunitdir}\"" \
127                         -i "${S}/dracut.conf.d/gentoo.conf.example" || die
128                 einfo "Setting systemdsystemconfdir to ${systemdsystemconfdir}..."
129                 sed -e "7asystemdsystemconfdir=\"${systemdsystemconfdir}\"" \
130                         -i "${S}/dracut.conf.d/gentoo.conf.example" || die
131         else
132                 local systemdutildir="/lib/systemd"
133                 einfo "Setting systemdutildir for standalone udev to" \
134                         "${systemdutildir}..."
135                 sed -e "5asystemdutildir=\"${systemdutildir}\"" \
136                         -i "${S}/dracut.conf.d/gentoo.conf.example" || die
137         fi
138
139         epatch_user
140 }
141
142 src_configure() {
143         local myconf="--libdir=${MY_LIBDIR}"
144         myconf+=" --bashcompletiondir=$(get_bashcompdir)"
145
146         if use systemd; then
147                 myconf+=" --systemdsystemunitdir='$(systemd_get_unitdir)'"
148         fi
149
150         econf ${myconf}
151 }
152
153 src_compile() {
154         tc-export CC
155         emake doc install/dracut-install skipcpio/skipcpio
156 }
157
158 src_install() {
159         default
160
161         local my_libdir="${MY_LIBDIR}"
162         local dracutlibdir="${my_libdir#/}/dracut"
163
164         echo "DRACUT_VERSION=$PVR" > "${D%/}/${dracutlibdir}/dracut-version.sh"
165
166         insinto "${dracutlibdir}/dracut.conf.d/"
167         newins dracut.conf.d/gentoo.conf.example gentoo.conf
168
169         insinto /etc/logrotate.d
170         newins dracut.logrotate dracut
171
172         dodir /var/lib/dracut/overlay
173
174         dohtml dracut.html
175
176         #
177         # Modules
178         #
179         local module
180         modules_dir="${D%/}/${dracutlibdir}/modules.d"
181
182         use debug || rm_module 95debug
183         use selinux || rm_module 98selinux
184
185         if use systemd; then
186                 # With systemd following modules do not make sense
187                 rm_module 96securityfs 97masterkey 98integrity
188         else
189                 rm_module 98systemd
190                 # Without systemd following modules do not make sense
191                 rm_module 00systemd-bootchart
192         fi
193
194         # Remove modules which won't work for sure
195         rm_module 95fcoe # no tools
196         # fips module depends on masked app-crypt/hmaccalc
197         rm_module 01fips 02fips-aesni
198 }
199
200 pkg_postinst() {
201         if linux-info_get_any_version && linux_config_src_exists; then
202                 ewarn ""
203                 ewarn "If the following test report contains a missing kernel"
204                 ewarn "configuration option, you should reconfigure and rebuild your"
205                 ewarn "kernel before booting image generated with this Dracut version."
206                 ewarn ""
207
208                 local CONFIG_CHECK="~BLK_DEV_INITRD ~DEVTMPFS"
209
210                 # Kernel configuration options descriptions:
211                 local desc_DEVTMPFS="Maintain a devtmpfs filesystem to mount at /dev"
212                 local desc_BLK_DEV_INITRD="Initial RAM filesystem and RAM disk "\
213 "(initramfs/initrd) support"
214
215                 local opt desc
216
217                 # Generate ERROR_* variables for check_extra_config.
218                 for opt in ${CONFIG_CHECK}; do
219                         opt=${opt#\~}
220                         desc=desc_${opt}
221                         eval "local ERROR_${opt}='CONFIG_${opt}: \"${!desc}\"" \
222                                 "is missing and REQUIRED'"
223                 done
224
225                 check_extra_config
226                 echo
227         else
228                 ewarn ""
229                 ewarn "Your kernel configuration couldn't be checked.  Do you have"
230                 ewarn "/usr/src/linux/.config file there?  Please check manually if"
231                 ewarn "following options are enabled:"
232                 ewarn ""
233                 ewarn "  CONFIG_BLK_DEV_INITRD"
234                 ewarn "  CONFIG_DEVTMPFS"
235                 ewarn ""
236         fi
237
238         elog "To get additional features, a number of optional runtime"
239         elog "dependencies may be installed:"
240         elog ""
241         optfeature "Networking support"  net-misc/curl "net-misc/dhcp[client]" \
242                 sys-apps/iproute2
243         optfeature \
244                 "Measure performance of the boot process for later visualisation" \
245                 app-benchmarks/bootchart2 app-admin/killproc sys-process/acct
246         optfeature "Scan for Btrfs on block devices"  sys-fs/btrfs-progs
247         optfeature "Load kernel modules and drop this privilege for real init" \
248                 sys-libs/libcap
249         optfeature "Support CIFS" net-fs/cifs-utils
250         optfeature "Decrypt devices encrypted with cryptsetup/LUKS" \
251                 "sys-fs/cryptsetup[-static-libs]"
252         optfeature "Support for GPG-encrypted keys for crypt module" \
253                 app-crypt/gnupg
254         optfeature \
255                 "Allows use of dash instead of default bash (on your own risk)" \
256                 app-shells/dash
257         optfeature "Framebuffer splash (media-gfx/splashutils)" \
258                 media-gfx/splashutils
259         optfeature "Support iSCSI" sys-block/open-iscsi
260         optfeature "Support Logical Volume Manager" sys-fs/lvm2
261         optfeature "Support MD devices, also known as software RAID devices" \
262                 sys-fs/mdadm
263         optfeature "Support Device Mapper multipathing" sys-fs/multipath-tools
264         optfeature "Plymouth boot splash"  '>=sys-boot/plymouth-0.8.5-r5'
265         optfeature "Support network block devices" sys-block/nbd
266         optfeature "Support NFS" net-fs/nfs-utils net-nds/rpcbind
267         optfeature \
268                 "Install ssh and scp along with config files and specified keys" \
269                 net-misc/openssh
270         optfeature "Enable logging with syslog-ng or rsyslog" app-admin/syslog-ng \
271                 app-admin/rsyslog
272 }