zfs-0.6.5.3-r1.ebuild 6.4 KB

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