/[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 - (hide annotations) (download)
Fri May 20 19:06:07 2011 UTC (3 years, 3 months ago) by blueness
Branch: MAIN
Changes since 1.5: +2 -2 lines
Improved error handling when failed to load modules

1 pebenito 1.1 # Copyright 1999-2006 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 blueness 1.6 # $Header: /var/cvsroot/gentoo-x86/eclass/selinux-policy-2.eclass,v 1.5 2011/02/05 11:28:10 blueness Exp $
4 pebenito 1.1
5     # Eclass for installing SELinux policy, and optionally
6 blueness 1.5 # reloading the reference-policy based modules.
7 pebenito 1.1
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 pebenito 1.2 local modfiles
28     [ -z "${POLICY_TYPES}" ] && local POLICY_TYPES="strict targeted"
29    
30 pebenito 1.1 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 pebenito 1.4 mkdir "${S}"/${i}
39     cp "${S}"/refpolicy/doc/Makefile.example "${S}"/${i}/Makefile
40 pebenito 1.1
41 pebenito 1.4 cp ${modfiles} "${S}"/${i}
42 kaiowas 1.3
43     if [ -n "${POLICY_PATCH}" ]; then
44 blueness 1.5 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 kaiowas 1.3 fi
51    
52 pebenito 1.1 done
53     }
54    
55     selinux-policy-2_src_compile() {
56 pebenito 1.2 [ -z "${POLICY_TYPES}" ] && local POLICY_TYPES="strict targeted"
57    
58 pebenito 1.1 for i in ${POLICY_TYPES}; do
59 pebenito 1.4 make NAME=$i -C "${S}"/${i} || die "${i} compile failed"
60 pebenito 1.1 done
61     }
62    
63     selinux-policy-2_src_install() {
64 pebenito 1.2 [ -z "${POLICY_TYPES}" ] && local POLICY_TYPES="strict targeted"
65     local BASEDIR="/usr/share/selinux"
66 pebenito 1.1
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 pebenito 1.4 doins "${S}"/${i}/${j}.pp
72 pebenito 1.1 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 pebenito 1.2 [ -z "${POLICY_TYPES}" ] && local POLICY_TYPES="strict targeted"
83 pebenito 1.1
84 blueness 1.5 for i in ${POLICY_TYPES}; do
85     einfo "Inserting the following modules into the $i module store: ${MODS}"
86 pebenito 1.1
87 blueness 1.5 cd /usr/share/selinux/${i}
88 blueness 1.6 semodule -s ${i} ${COMMAND} || die "Failed to load in modules ${MODS} in the $i policy store"
89 blueness 1.5 done
90 pebenito 1.1 }
91    
92     EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_postinst

  ViewVC Help
Powered by ViewVC 1.1.20