logo

overlay

My own overlay for experimentations, use with caution, no support is provided git clone https://hacktivis.me/git/overlay.git

zfs-kmod-0.8.4-r1.ebuild (4808B)


  1. # Copyright 1999-2020 Gentoo Authors
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=7
  4. inherit autotools flag-o-matic linux-mod toolchain-funcs
  5. DESCRIPTION="Linux ZFS kernel module for sys-fs/zfs"
  6. HOMEPAGE="https://github.com/openzfs/zfs"
  7. if [[ ${PV} == "9999" ]]; then
  8. inherit git-r3
  9. EGIT_REPO_URI="https://github.com/openzfs/zfs.git"
  10. else
  11. SRC_URI="https://github.com/openzfs/zfs/releases/download/zfs-${PV}/zfs-${PV}.tar.gz"
  12. KEYWORDS="~amd64 ~arm64 ~ppc64"
  13. S="${WORKDIR}/zfs-${PV}"
  14. ZFS_KERNEL_COMPAT="5.6"
  15. fi
  16. LICENSE="CDDL debug? ( GPL-2+ )"
  17. SLOT="0"
  18. IUSE="custom-cflags debug kernel-builtin +rootfs"
  19. DEPEND=""
  20. RDEPEND="${DEPEND}
  21. !sys-kernel/spl
  22. "
  23. BDEPEND="
  24. dev-lang/perl
  25. virtual/awk
  26. "
  27. RESTRICT="debug? ( strip ) test"
  28. DOCS=( AUTHORS COPYRIGHT META README.md )
  29. PATCHES=( "${FILESDIR}/${PV}-powerpc_jmp_weak.patch" )
  30. pkg_setup() {
  31. CONFIG_CHECK="
  32. !DEBUG_LOCK_ALLOC
  33. EFI_PARTITION
  34. MODULES
  35. !PAX_KERNEXEC_PLUGIN_METHOD_OR
  36. !TRIM_UNUSED_KSYMS
  37. ZLIB_DEFLATE
  38. ZLIB_INFLATE
  39. "
  40. use debug && CONFIG_CHECK="${CONFIG_CHECK}
  41. FRAME_POINTER
  42. DEBUG_INFO
  43. !DEBUG_INFO_REDUCED
  44. "
  45. use rootfs && \
  46. CONFIG_CHECK="${CONFIG_CHECK}
  47. BLK_DEV_INITRD
  48. DEVTMPFS
  49. "
  50. if use arm64; then
  51. kernel_is -ge 5 && CONFIG_CHECK="${CONFIG_CHECK} !PREEMPT"
  52. fi
  53. kernel_is -lt 5 && CONFIG_CHECK="${CONFIG_CHECK} IOSCHED_NOOP"
  54. if [[ ${PV} != "9999" ]]; then
  55. local kv_major_max kv_minor_max zcompat
  56. zcompat="${ZFS_KERNEL_COMPAT_OVERRIDE:-${ZFS_KERNEL_COMPAT}}"
  57. kv_major_max="${zcompat%%.*}"
  58. zcompat="${zcompat#*.}"
  59. kv_minor_max="${zcompat%%.*}"
  60. kernel_is -le "${kv_major_max}" "${kv_minor_max}" || die \
  61. "Linux ${kv_major_max}.${kv_minor_max} is the latest supported version"
  62. # 0.8.x requires at least 2.6.32
  63. kernel_is ge 2 6 32 || die "Linux 2.6.32 or newer required"
  64. else
  65. # git master requires at least 3.10
  66. kernel_is -ge 3 10 || die "Linux 3.10 or newer required"
  67. fi
  68. linux-mod_pkg_setup
  69. }
  70. src_prepare() {
  71. default
  72. if [[ ${PV} == "9999" ]]; then
  73. eautoreconf
  74. else
  75. # Set module revision number
  76. sed -i "s/\(Release:\)\(.*\)1/\1\2${PR}-gentoo/" META || die "Could not set Gentoo release"
  77. fi
  78. }
  79. src_configure() {
  80. set_arch_to_kernel
  81. use custom-cflags || strip-flags
  82. filter-ldflags -Wl,*
  83. local myconf=(
  84. CROSS_COMPILE="${CHOST}-"
  85. HOSTCC="$(tc-getBUILD_CC)"
  86. --bindir="${EPREFIX}/bin"
  87. --sbindir="${EPREFIX}/sbin"
  88. --with-config=kernel
  89. --with-linux="${KV_DIR}"
  90. --with-linux-obj="${KV_OUT_DIR}"
  91. $(use_enable debug)
  92. $(use_enable kernel-builtin linux-builtin)
  93. )
  94. CONFIG_SHELL="${EPREFIX}/bin/bash" econf "${myconf[@]}"
  95. }
  96. src_compile() {
  97. use kernel-builtin && return
  98. set_arch_to_kernel
  99. myemakeargs=(
  100. CROSS_COMPILE="${CHOST}-"
  101. HOSTCC="$(tc-getBUILD_CC)"
  102. V=1
  103. )
  104. emake "${myemakeargs[@]}"
  105. }
  106. src_install() {
  107. if use kernel-builtin; then
  108. ./copy-builtin /usr/src/linux || die "Failed to copy in current kernel"
  109. else
  110. set_arch_to_kernel
  111. myemakeargs+=(
  112. DEPMOD="/bin/true"
  113. DESTDIR="${D}"
  114. INSTALL_MOD_PATH="${INSTALL_MOD_PATH:-$EROOT}"
  115. )
  116. emake "${myemakeargs[@]}" install
  117. einstalldocs
  118. fi
  119. }
  120. pkg_postinst() {
  121. linux-mod_pkg_postinst
  122. # Remove old modules
  123. if [[ -d "${EROOT}/lib/modules/${KV_FULL}/addon/zfs" ]]; then
  124. ewarn "${PN} now installs modules in ${EROOT}/lib/modules/${KV_FULL}/extra/zfs"
  125. ewarn "Old modules were detected in ${EROOT}/lib/modules/${KV_FULL}/addon/zfs"
  126. ewarn "Automatically removing old modules to avoid problems."
  127. rm -r "${EROOT}/lib/modules/${KV_FULL}/addon/zfs" || die "Cannot remove modules"
  128. rmdir --ignore-fail-on-non-empty "${EROOT}/lib/modules/${KV_FULL}/addon"
  129. fi
  130. if use x86 || use arm; then
  131. ewarn "32-bit kernels will likely require increasing vmalloc to"
  132. ewarn "at least 256M and decreasing zfs_arc_max to some value less than that."
  133. fi
  134. ewarn "This version of OpenZFS includes support for new feature flags"
  135. ewarn "that are incompatible with previous versions. GRUB2 support for"
  136. ewarn "/boot with the new feature flags is not yet available."
  137. ewarn "Do *NOT* upgrade root pools to use the new feature flags."
  138. ewarn "Any new pools will be created with the new feature flags by default"
  139. ewarn "and will not be compatible with older versions of ZFSOnLinux. To"
  140. ewarn "create a newpool that is backward compatible wih GRUB2, use "
  141. ewarn
  142. ewarn "zpool create -d -o feature@async_destroy=enabled "
  143. ewarn " -o feature@empty_bpobj=enabled -o feature@lz4_compress=enabled"
  144. ewarn " -o feature@spacemap_histogram=enabled"
  145. ewarn " -o feature@enabled_txg=enabled "
  146. ewarn " -o feature@extensible_dataset=enabled -o feature@bookmarks=enabled"
  147. ewarn " ..."
  148. ewarn
  149. ewarn "GRUB2 support will be updated as soon as either the GRUB2"
  150. ewarn "developers do a tag or the Gentoo developers find time to backport"
  151. ewarn "support from GRUB2 HEAD."
  152. }