libsemanage-2.5.ebuild 4.5 KB

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