libsemanage-9999.ebuild 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI="6"
  4. PYTHON_COMPAT=( python{2_7,3_4,3_5} )
  5. inherit multilib python-r1 toolchain-funcs multilib-minimal
  6. MY_P="${P//_/-}"
  7. MY_RELEASEDATE="20161014"
  8. SEPOL_VER="${PV}"
  9. SELNX_VER="${PV}"
  10. DESCRIPTION="SELinux kernel and policy management library"
  11. HOMEPAGE="https://github.com/SELinuxProject/selinux/wiki"
  12. if [[ ${PV} == 9999 ]]; then
  13. inherit git-r3
  14. EGIT_REPO_URI="https://github.com/SELinuxProject/selinux.git"
  15. S="${WORKDIR}/${MY_P}/${PN}"
  16. else
  17. SRC_URI="https://raw.githubusercontent.com/wiki/SELinuxProject/selinux/files/releases/${MY_RELEASEDATE}/${MY_P}.tar.gz"
  18. KEYWORDS="~amd64 ~arm ~arm64 ~mips ~x86"
  19. S="${WORKDIR}/${MY_P}"
  20. fi
  21. LICENSE="GPL-2"
  22. SLOT="0"
  23. IUSE="python"
  24. RDEPEND=">=sys-libs/libsepol-${SEPOL_VER}[${MULTILIB_USEDEP}]
  25. >=sys-libs/libselinux-${SELNX_VER}[${MULTILIB_USEDEP}]
  26. >=sys-process/audit-2.2.2[${MULTILIB_USEDEP}]
  27. >=dev-libs/ustr-1.0.4-r2[${MULTILIB_USEDEP}]
  28. "
  29. DEPEND="${RDEPEND}
  30. sys-devel/bison
  31. sys-devel/flex
  32. python? (
  33. >=dev-lang/swig-2.0.4-r1
  34. virtual/pkgconfig
  35. ${PYTHON_DEPS}
  36. )"
  37. # tests are not meant to be run outside of the
  38. # full SELinux userland repo
  39. RESTRICT="test"
  40. src_prepare() {
  41. echo "# Set this to true to save the linked policy." >> "${S}/src/semanage.conf"
  42. echo "# This is normally only useful for analysis" >> "${S}/src/semanage.conf"
  43. echo "# or debugging of policy." >> "${S}/src/semanage.conf"
  44. echo "save-linked=false" >> "${S}/src/semanage.conf"
  45. echo >> "${S}/src/semanage.conf"
  46. echo "# Set this to 0 to disable assertion checking." >> "${S}/src/semanage.conf"
  47. echo "# This should speed up building the kernel policy" >> "${S}/src/semanage.conf"
  48. echo "# from policy modules, but may leave you open to" >> "${S}/src/semanage.conf"
  49. echo "# dangerous rules which assertion checking" >> "${S}/src/semanage.conf"
  50. echo "# would catch." >> "${S}/src/semanage.conf"
  51. echo "expand-check=1" >> "${S}/src/semanage.conf"
  52. echo >> "${S}/src/semanage.conf"
  53. echo "# Modules in the module store can be compressed" >> "${S}/src/semanage.conf"
  54. echo "# with bzip2. Set this to the bzip2 blocksize" >> "${S}/src/semanage.conf"
  55. echo "# 1-9 when compressing. The higher the number," >> "${S}/src/semanage.conf"
  56. echo "# the more memory is traded off for disk space." >> "${S}/src/semanage.conf"
  57. echo "# Set to 0 to disable bzip2 compression." >> "${S}/src/semanage.conf"
  58. echo "bzip-blocksize=0" >> "${S}/src/semanage.conf"
  59. echo >> "${S}/src/semanage.conf"
  60. echo "# Reduce memory usage for bzip2 compression and" >> "${S}/src/semanage.conf"
  61. echo "# decompression of modules in the module store." >> "${S}/src/semanage.conf"
  62. echo "bzip-small=true" >> "${S}/src/semanage.conf"
  63. eapply "${FILESDIR}"/${PN}-2.7-build-paths.patch
  64. eapply_user
  65. multilib_copy_sources
  66. }
  67. multilib_src_compile() {
  68. emake \
  69. AR="$(tc-getAR)" \
  70. CC="$(tc-getCC)" \
  71. LIBDIR="${EPREFIX}/usr/$(get_libdir)" \
  72. all
  73. if multilib_is_native_abi && use python; then
  74. building_py() {
  75. emake "$@"
  76. }
  77. python_foreach_impl building_py swigify
  78. python_foreach_impl building_py pywrap
  79. fi
  80. }
  81. multilib_src_install() {
  82. emake \
  83. LIBDIR="${ED}/usr/$(get_libdir)" \
  84. SHLIBDIR="${ED}/usr/$(get_libdir)" \
  85. DESTDIR="${ED}" install
  86. if multilib_is_native_abi && use python; then
  87. installation_py() {
  88. emake DESTDIR="${ED}" \
  89. LIBDIR="${ED}/usr/$(get_libdir)" \
  90. SHLIBDIR="${ED}/usr/$(get_libdir)" \
  91. LIBSEPOLA="${EPREFIX%/}/usr/$(get_libdir)/libsepol.a" \
  92. install-pywrap
  93. python_optimize # bug 531638
  94. }
  95. python_foreach_impl installation_py
  96. fi
  97. }
  98. pkg_postinst() {
  99. # Migrate the SELinux semanage configuration store if not done already
  100. local selinuxtype=$(awk -F'=' '/SELINUXTYPE=/ {print $2}' "${EROOT}"/etc/selinux/config 2>/dev/null)
  101. if [ -n "${selinuxtype}" ] && [ ! -d "${EROOT}"/var/lib/selinux/${mcs}/active ] ; then
  102. ewarn "Since the 2.4 SELinux userspace, the policy module store is moved"
  103. ewarn "from /etc/selinux to /var/lib/selinux. The migration will be run now."
  104. ewarn "If there are any issues, it can be done manually by running:"
  105. ewarn "/usr/libexec/selinux/semanage_migrate_store"
  106. ewarn "For more information, please see"
  107. ewarn "- https://github.com/SELinuxProject/selinux/wiki/Policy-Store-Migration"
  108. fi
  109. # Run the store migration without rebuilds
  110. for POLICY_TYPE in ${POLICY_TYPES} ; do
  111. if [ ! -d "${EROOT}/var/lib/selinux/${POLICY_TYPE}/active" ] ; then
  112. einfo "Migrating store ${POLICY_TYPE} (without policy rebuild)."
  113. /usr/libexec/selinux/semanage_migrate_store -n -s "${POLICY_TYPE}" || die "Failed to migrate store ${POLICY_TYPE}"
  114. fi
  115. done
  116. }