aufs4-0_pre20170313.ebuild 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=6
  4. inherit eutils flag-o-matic linux-info linux-mod multilib readme.gentoo-r1 toolchain-funcs
  5. AUFS_VERSION="${PV%%_p*}"
  6. # highest branch version
  7. PATCH_MAX_VER=9
  8. # highest supported version
  9. KERN_MAX_VER=11
  10. # lowest supported version
  11. KERN_MIN_VER=0
  12. DESCRIPTION="An entirely re-designed and re-implemented Unionfs"
  13. HOMEPAGE="http://aufs.sourceforge.net/"
  14. SRC_URI="https://dev.gentoo.org/~jlec/distfiles/aufs4-standalone-${PV}.tar.xz"
  15. LICENSE="GPL-2"
  16. SLOT="0"
  17. KEYWORDS="~amd64 ~x86"
  18. IUSE="debug doc fuse hfs inotify kernel-patch nfs pax_kernel ramfs"
  19. DEPEND="
  20. dev-util/patchutils
  21. dev-vcs/git"
  22. RDEPEND="
  23. sys-fs/aufs-util
  24. !sys-fs/aufs
  25. !sys-fs/aufs2
  26. !sys-fs/aufs3"
  27. S="${WORKDIR}"/${PN}-standalone
  28. MODULE_NAMES="aufs(misc:${S})"
  29. pkg_setup() {
  30. CONFIG_CHECK+=" !AUFS_FS"
  31. use inotify && CONFIG_CHECK+=" ~FSNOTIFY"
  32. use nfs && CONFIG_CHECK+=" EXPORTFS"
  33. use fuse && CONFIG_CHECK+=" ~FUSE_FS"
  34. use hfs && CONFIG_CHECK+=" ~HFSPLUS_FS"
  35. use pax_kernel && CONFIG_CHECK+=" PAX" \
  36. && ERROR_PAX="Please use hardened sources"
  37. # this is needed so merging a binpkg ${PN} is
  38. # possible w/out a kernel unpacked on the system
  39. [[ -n "$PKG_SETUP_HAS_BEEN_RAN" ]] && return
  40. get_version
  41. kernel_is lt 4 ${KERN_MIN_VER} 0 && \
  42. die "the kernel version isn't supported by upstream anymore. Please upgrade."
  43. kernel_is gt 4 ${KERN_MAX_VER} 99 && die "kernel too new"
  44. linux-mod_pkg_setup
  45. if [[ "${KV_MINOR}" -gt "${PATCH_MAX_VER}" ]]; then
  46. PATCH_BRANCH="x-rcN"
  47. elif [[ "${KV_MINOR}" == "1" ]] && [[ "${KV_PATCH}" -ge "13" ]]; then
  48. PATCH_BRANCH="${KV_MINOR}".13+
  49. else
  50. PATCH_BRANCH="${KV_MINOR}"
  51. fi
  52. case ${KV_EXTRA} in
  53. "")
  54. elog "It seems you are using vanilla-sources with aufs4"
  55. elog "Please use sys-kernel/aufs-sources with USE=vanilla"
  56. elog "This will save you the nasty reemerge of sys-fs/aufs4 on every kernel upgrade"
  57. ;;
  58. "-gentoo")
  59. elog "It seems you are using gentoo-sources with aufs4"
  60. elog "Please use sys-kernel/aufs-sources"
  61. elog "This will save you the nasty reemerge of sys-fs/aufs4 on every kernel upgrade"
  62. ;;
  63. esac
  64. pushd "${T}" &> /dev/null || die
  65. unpack ${A}
  66. cd ${PN}-standalone || die
  67. local module_branch=origin/${PN}.${PATCH_BRANCH}
  68. einfo "Using ${module_branch} as patch source"
  69. git checkout -q -b local-${PN}.${PATCH_BRANCH} ${module_branch} || die
  70. combinediff \
  71. ${PN}-base.patch ${PN}-standalone.patch > "${T}"/combined-1.patch
  72. combinediff \
  73. "${T}"/combined-1.patch ${PN}-mmap.patch \
  74. > ${PN}-standalone-base-mmap-combined.patch
  75. if ! ( patch -p1 --dry-run --force -R -d ${KV_DIR} < ${PN}-standalone-base-mmap-combined.patch > /dev/null ); then
  76. if use kernel-patch; then
  77. cd ${KV_DIR}
  78. ewarn "Patching your kernel..."
  79. patch \
  80. --no-backup-if-mismatch --force -p1 -R -d ${KV_DIR} \
  81. < "${T}"/${PN}-standalone/${PN}-standalone-base-mmap-combined.patch \
  82. > /dev/null
  83. epatch "${T}"/${PN}-standalone/${PN}-standalone-base-mmap-combined.patch
  84. ewarn "You need to compile your kernel with the applied patch"
  85. ewarn "to be able to load and use the aufs kernel module"
  86. else
  87. eerror "You need to apply a patch to your kernel to compile and run the ${PN} module"
  88. eerror "Either enable the kernel-patch useflag to do it with this ebuild"
  89. eerror "or apply "${T}"/${PN}-standalone/${PN}-standalone-base-mmap-combined.patch by hand"
  90. die "missing kernel patch, please apply it first"
  91. fi
  92. fi
  93. popd &> /dev/null
  94. export PKG_SETUP_HAS_BEEN_RAN=1
  95. }
  96. set_config() {
  97. for option in $*; do
  98. grep -q "^CONFIG_AUFS_${option} =" config.mk || \
  99. die "${option} is not a valid config option"
  100. sed "/^CONFIG_AUFS_${option}/s:=:= y:g" -i config.mk || die
  101. done
  102. }
  103. src_prepare() {
  104. local module_branch=origin/${PN}.${PATCH_BRANCH}
  105. einfo "Using for module creation branch ${module_branch}"
  106. git checkout -q -b local-gentoo ${module_branch} || die
  107. # All config options to off
  108. sed "s:= y:=:g" -i config.mk || die
  109. set_config RDU BRANCH_MAX_127 SBILIST
  110. use debug && set_config DEBUG
  111. use fuse && set_config BR_FUSE POLL
  112. use hfs && set_config BR_HFSPLUS
  113. use inotify && set_config HNOTIFY HFSNOTIFY
  114. use nfs && set_config EXPORT
  115. use nfs && ( use amd64 || use ppc64 ) && set_config INO_T_64
  116. use ramfs && set_config BR_RAMFS
  117. use pax_kernel && epatch "${FILESDIR}"/pax-4.patch
  118. sed \
  119. -e "s:aufs.ko usr/include/linux/aufs_type.h:aufs.ko:g" \
  120. -i Makefile || die
  121. eapply_user
  122. }
  123. src_compile() {
  124. local ARCH=x86
  125. emake \
  126. CC=$(tc-getCC) \
  127. LD=$(tc-getLD) \
  128. LDFLAGS="$(raw-ldflags)" \
  129. ARCH=$(tc-arch-kernel) \
  130. CONFIG_AUFS_FS=m \
  131. KDIR="${KV_OUT_DIR}"
  132. }
  133. src_install() {
  134. linux-mod_src_install
  135. use doc && dodoc -r Documentation
  136. use kernel-patch || \
  137. doins "${T}"/${PN}-standalone/${PN}-standalone-base-mmap-combined.patch
  138. dodoc \
  139. Documentation/filesystems/aufs/README \
  140. "${T}"/${PN}-standalone/{aufs4-loopback,vfs-ino,tmpfs-idr}.patch
  141. readme.gentoo_create_doc
  142. }
  143. pkg_postinst() {
  144. readme.gentoo_print_elog
  145. linux-mod_pkg_postinst
  146. }