zfs-0.6.5.4-r2.ebuild 6.4 KB

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