zfs-0.6.5.6.ebuild 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. # Copyright 1999-2015 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI="5"
  4. PYTHON_COMPAT=( python{2_7,3_4,3_5} )
  5. if [ ${PV} == "9999" ] ; then
  6. inherit git-r3 linux-mod
  7. AUTOTOOLS_AUTORECONF="1"
  8. EGIT_REPO_URI="git://github.com/zfsonlinux/${PN}.git"
  9. else
  10. SRC_URI="https://github.com/zfsonlinux/${PN}/releases/download/${P}/${P}.tar.gz"
  11. KEYWORDS=" ~amd64"
  12. fi
  13. inherit autotools-utils bash-completion-r1 flag-o-matic linux-info python-r1 systemd toolchain-funcs udev
  14. DESCRIPTION="Userland utilities for ZFS Linux kernel module"
  15. HOMEPAGE="http://zfsonlinux.org/"
  16. LICENSE="BSD-2 CDDL MIT"
  17. SLOT="0"
  18. IUSE="custom-cflags debug kernel-builtin +rootfs test-suite static-libs"
  19. RESTRICT="test"
  20. COMMON_DEPEND="
  21. sys-apps/util-linux[static-libs?]
  22. sys-libs/zlib[static-libs(+)?]
  23. virtual/awk
  24. "
  25. DEPEND="${COMMON_DEPEND}
  26. virtual/pkgconfig
  27. "
  28. RDEPEND="${COMMON_DEPEND}
  29. !=sys-apps/grep-2.13*
  30. !kernel-builtin? ( =sys-fs/zfs-kmod-${PV}* )
  31. !sys-fs/zfs-fuse
  32. !prefix? ( virtual/udev )
  33. test-suite? (
  34. sys-apps/util-linux
  35. sys-devel/bc
  36. sys-block/parted
  37. sys-fs/lsscsi
  38. sys-fs/mdadm
  39. sys-process/procps
  40. virtual/modutils
  41. )
  42. rootfs? (
  43. app-arch/cpio
  44. app-misc/pax-utils
  45. !<sys-boot/grub-2.00-r2:2
  46. )
  47. !>=sys-fs/udev-init-scripts-28
  48. "
  49. AT_M4DIR="config"
  50. AUTOTOOLS_IN_SOURCE_BUILD="1"
  51. pkg_setup() {
  52. if use kernel_linux && use test-suite; then
  53. linux-info_pkg_setup
  54. if ! linux_config_exists; then
  55. ewarn "Cannot check the linux kernel configuration."
  56. else
  57. # recheck that we don't have usblp to collide with libusb
  58. if use test-suite; then
  59. if linux_chkconfig_present BLK_DEV_LOOP; then
  60. eerror "The ZFS test suite requires loop device support enabled."
  61. eerror "Please enable it:"
  62. eerror " CONFIG_BLK_DEV_LOOP=y"
  63. eerror "in /usr/src/linux/.config or"
  64. eerror " Device Drivers --->"
  65. eerror " Block devices --->"
  66. eerror " [ ] Loopback device support"
  67. fi
  68. fi
  69. fi
  70. fi
  71. }
  72. src_prepare() {
  73. # Update paths
  74. sed -e "s|/sbin/lsmod|/bin/lsmod|" \
  75. -e "s|/usr/bin/scsi-rescan|/usr/sbin/rescan-scsi-bus|" \
  76. -e "s|/sbin/parted|/usr/sbin/parted|" \
  77. -i scripts/common.sh.in
  78. autotools-utils_src_prepare
  79. }
  80. src_configure() {
  81. use custom-cflags || strip-flags
  82. local myeconfargs=(
  83. --bindir="${EPREFIX}/bin"
  84. --sbindir="${EPREFIX}/sbin"
  85. --with-config=user
  86. --with-dracutdir="/usr/$(get_libdir)/dracut"
  87. --with-linux="${KV_DIR}"
  88. --with-linux-obj="${KV_OUT_DIR}"
  89. --with-udevdir="$(get_udevdir)"
  90. --with-blkid
  91. $(use_enable debug)
  92. )
  93. autotools-utils_src_configure
  94. # prepare systemd unit and helper script
  95. cat "${FILESDIR}/zfs.service.in" | \
  96. sed -e "s:@sbindir@:${EPREFIX}/sbin:g" \
  97. -e "s:@sysconfdir@:${EPREFIX}/etc:g" \
  98. > "${T}/zfs.service" || die
  99. cat "${FILESDIR}/zfs-init.sh.in" | \
  100. sed -e "s:@sbindir@:${EPREFIX}/sbin:g" \
  101. -e "s:@sysconfdir@:${EPREFIX}/etc:g" \
  102. > "${T}/zfs-init.sh" || die
  103. }
  104. src_install() {
  105. autotools-utils_src_install
  106. gen_usr_ldscript -a uutil nvpair zpool zfs zfs_core
  107. use test-suite || rm -rf "${ED}usr/share/zfs"
  108. newbashcomp "${FILESDIR}/bash-completion-r1" zfs
  109. bashcomp_alias zfs zpool
  110. exeinto /usr/libexec
  111. doexe "${T}/zfs-init.sh"
  112. systemd_dounit "${T}/zfs.service"
  113. }
  114. pkg_postinst() {
  115. if ! use kernel-builtin && [ ${PV} = "9999" ]
  116. then
  117. einfo "Adding ${P} to the module database to ensure that the"
  118. einfo "kernel modules and userland utilities stay in sync."
  119. update_moduledb
  120. fi
  121. if [ -e "${EROOT}etc/runlevels/boot/zfs" ]
  122. then
  123. einfo 'The zfs boot script has been split into the zfs-import,'
  124. einfo 'zfs-mount and zfs-share scripts.'
  125. einfo
  126. einfo 'You had the zfs script in your boot runlevel. For your'
  127. einfo 'convenience, it has been automatically removed and the three'
  128. einfo 'scripts that replace it have been configured to start.'
  129. einfo 'The zfs-import and zfs-mount scripts have been added to the boot'
  130. einfo 'runlevel while the zfs-share script is in the default runlevel.'
  131. rm "${EROOT}etc/runlevels/boot/zfs"
  132. ln -snf "${EROOT}etc/init.d/zfs-import" \
  133. "${EROOT}etc/runlevels/boot/zfs-import"
  134. ln -snf "${EROOT}etc/init.d/zfs-mount" \
  135. "${EROOT}etc/runlevels/boot/zfs-mount"
  136. ln -snf "${EROOT}etc/init.d/zfs-share" \
  137. "${EROOT}etc/runlevels/default/zfs-share"
  138. else
  139. [ -e "${EROOT}etc/runlevels/boot/zfs-import" ] || \
  140. einfo "You should add zfs-import to the boot runlevel."
  141. [ -e "${EROOT}etc/runlevels/boot/zfs-mount" ] || \
  142. einfo "You should add zfs-mount to the boot runlevel."
  143. [ -e "${EROOT}etc/runlevels/default/zfs-share" ] || \
  144. einfo "You should add zfs-share to the default runlevel."
  145. fi
  146. if [ -e "${EROOT}etc/runlevels/default/zed" ]
  147. then
  148. einfo 'The downstream OpenRC zed script has replaced by the upstream'
  149. einfo 'OpenRC zfs-zed script.'
  150. einfo
  151. einfo 'You had the zed script in your default runlevel. For your'
  152. einfo 'convenience, it has been automatically removed and the zfs-zed'
  153. einfo 'script that replaced it has been configured to start.'
  154. rm "${EROOT}etc/runlevels/boot/zed"
  155. ln -snf "${EROOT}etc/init.d/zfs-sed" \
  156. "${EROOT}etc/runlevels/default/zfs-zed"
  157. else
  158. [ -e "${EROOT}etc/runlevels/default/zfs-zed" ] || \
  159. einfo "You should add zfs-zed to the default runlevel."
  160. fi
  161. if [ -e "${EROOT}etc/runlevels/shutdown/zfs-shutdown" ]
  162. then
  163. einfo "The zfs-shutdown script is obsolete. Removing it from runlevel."
  164. rm "${EROOT}etc/runlevels/shutdown/zfs-shutdown"
  165. fi
  166. }
  167. pkg_postrm() {
  168. if ! use kernel-builtin && [ ${PV} = "9999" ]
  169. then
  170. remove_moduledb
  171. fi
  172. }