Advertisement
Guest User

Untitled

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