1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 inherit bash-completion-r1 eutils linux-info multilib systemd
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"
14 KEYWORDS="~alpha ~amd64 ~arm ~ia64 ~ppc ~ppc64 ~sparc ~x86"
15 IUSE="debug selinux systemd"
20 systemd? ( >=sys-apps/systemd-199 )
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
29 debug? ( dev-util/strace )
33 sec-policy/selinux-dracut
38 >=dev-libs/libxslt-1.1.26
39 app-text/docbook-xml-dtd:4.5
40 >=app-text/docbook-xsl-stylesheets-1.75.2
44 DOCS=( AUTHORS HACKING NEWS README README.generic README.kernel README.modules
45 README.testsuite TODO )
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"
56 usr/lib/dracut/dracut-install
57 usr/lib/dracut/skipcpio
64 # Removes module from modules.d.
66 # Module name can be specified without number prefix.
69 [[ $1 = -f ]] && force=-f
72 if [[ $m =~ ^[0-9][0-9][^\ ]*$ ]]; then
73 rm ${force} --interactive=never -r "${modules_dir}"/$m
75 rm ${force} --interactive=never -r "${modules_dir}"/[0-9][0-9]$m
80 # Grabbed from net-misc/netctl ebuild.
85 if has_version "$1"; then
86 elog " [I] $1 to ${desc}"
88 elog " [ ] $1 to ${desc}"
99 epatch "${PATCHES[@]}"
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"
106 einfo "Setting libdirs to \"${libdirs}\" ..."
107 sed -e "3alibdirs=\"${libdirs}\"" \
108 -i "${S}/dracut.conf.d/gentoo.conf.example" || die
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
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
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
143 local myconf="--libdir=${MY_LIBDIR}"
144 myconf+=" --bashcompletiondir=$(get_bashcompdir)"
147 myconf+=" --systemdsystemunitdir='$(systemd_get_unitdir)'"
155 emake doc install/dracut-install skipcpio/skipcpio
161 local my_libdir="${MY_LIBDIR}"
162 local dracutlibdir="${my_libdir#/}/dracut"
164 echo "DRACUT_VERSION=$PVR" > "${D%/}/${dracutlibdir}/dracut-version.sh"
166 insinto "${dracutlibdir}/dracut.conf.d/"
167 newins dracut.conf.d/gentoo.conf.example gentoo.conf
169 insinto /etc/logrotate.d
170 newins dracut.logrotate dracut
172 dodir /var/lib/dracut/overlay
180 modules_dir="${D%/}/${dracutlibdir}/modules.d"
182 use debug || rm_module 95debug
183 use selinux || rm_module 98selinux
186 # With systemd following modules do not make sense
187 rm_module 96securityfs 97masterkey 98integrity
190 # Without systemd following modules do not make sense
191 rm_module 00systemd-bootchart
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
201 if linux-info_get_any_version && linux_config_src_exists; then
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."
208 local CONFIG_CHECK="~BLK_DEV_INITRD ~DEVTMPFS"
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"
217 # Generate ERROR_* variables for check_extra_config.
218 for opt in ${CONFIG_CHECK}; do
221 eval "local ERROR_${opt}='CONFIG_${opt}: \"${!desc}\"" \
222 "is missing and REQUIRED'"
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:"
233 ewarn " CONFIG_BLK_DEV_INITRD"
234 ewarn " CONFIG_DEVTMPFS"
238 elog "To get additional features, a number of optional runtime"
239 elog "dependencies may be installed:"
241 optfeature "Networking support" net-misc/curl "net-misc/dhcp[client]" \
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" \
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" \
255 "Allows use of dash instead of default bash (on your own risk)" \
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" \
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
268 "Install ssh and scp along with config files and specified keys" \
270 optfeature "Enable logging with syslog-ng or rsyslog" app-admin/syslog-ng \