/[gentoo-x86]/eclass/selinux-policy-2.eclass
Gentoo

Contents of /eclass/selinux-policy-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (show annotations) (download)
Fri May 20 19:06:07 2011 UTC (2 years, 11 months ago) by blueness
Branch: MAIN
Changes since 1.5: +2 -2 lines
Improved error handling when failed to load modules

1 # Copyright 1999-2006 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/selinux-policy-2.eclass,v 1.5 2011/02/05 11:28:10 blueness Exp $
4
5 # Eclass for installing SELinux policy, and optionally
6 # reloading the reference-policy based modules.
7
8 inherit eutils
9
10 IUSE=""
11
12 HOMEPAGE="http://www.gentoo.org/proj/en/hardened/selinux/"
13 SRC_URI="http://oss.tresys.com/files/refpolicy/refpolicy-${PV}.tar.bz2"
14
15 LICENSE="GPL-2"
16 SLOT="0"
17 S="${WORKDIR}/"
18
19 RDEPEND=">=sys-apps/policycoreutils-1.30.30
20 >=sec-policy/selinux-base-policy-${PV}"
21
22 DEPEND="${RDEPEND}
23 sys-devel/m4
24 >=sys-apps/checkpolicy-1.30.12"
25
26 selinux-policy-2_src_unpack() {
27 local modfiles
28 [ -z "${POLICY_TYPES}" ] && local POLICY_TYPES="strict targeted"
29
30 unpack ${A}
31
32 for i in ${MODS}; do
33 modfiles="`find ${S}/refpolicy/policy/modules -iname $i.te` $modfiles"
34 modfiles="`find ${S}/refpolicy/policy/modules -iname $i.fc` $modfiles"
35 done
36
37 for i in ${POLICY_TYPES}; do
38 mkdir "${S}"/${i}
39 cp "${S}"/refpolicy/doc/Makefile.example "${S}"/${i}/Makefile
40
41 cp ${modfiles} "${S}"/${i}
42
43 if [ -n "${POLICY_PATCH}" ]; then
44 for POLPATCH in "${POLICY_PATCH}";
45 do
46 cd "${S}"/${i}
47 einfo "Patching ${i}"
48 epatch "${POLPATCH}" || die "failed patch ${POLPATCH}"
49 done
50 fi
51
52 done
53 }
54
55 selinux-policy-2_src_compile() {
56 [ -z "${POLICY_TYPES}" ] && local POLICY_TYPES="strict targeted"
57
58 for i in ${POLICY_TYPES}; do
59 make NAME=$i -C "${S}"/${i} || die "${i} compile failed"
60 done
61 }
62
63 selinux-policy-2_src_install() {
64 [ -z "${POLICY_TYPES}" ] && local POLICY_TYPES="strict targeted"
65 local BASEDIR="/usr/share/selinux"
66
67 for i in ${POLICY_TYPES}; do
68 for j in ${MODS}; do
69 echo "Installing ${i} ${j} policy package"
70 insinto ${BASEDIR}/${i}
71 doins "${S}"/${i}/${j}.pp
72 done
73 done
74 }
75
76 selinux-policy-2_pkg_postinst() {
77 # build up the command in the case of multiple modules
78 local COMMAND
79 for i in ${MODS}; do
80 COMMAND="-i ${i}.pp ${COMMAND}"
81 done
82 [ -z "${POLICY_TYPES}" ] && local POLICY_TYPES="strict targeted"
83
84 for i in ${POLICY_TYPES}; do
85 einfo "Inserting the following modules into the $i module store: ${MODS}"
86
87 cd /usr/share/selinux/${i}
88 semodule -s ${i} ${COMMAND} || die "Failed to load in modules ${MODS} in the $i policy store"
89 done
90 }
91
92 EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_postinst

  ViewVC Help
Powered by ViewVC 1.1.20