zfs-0.6.5.2-r1.ebuild 5.6 KB

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