Gentoo Archives: gentoo-hardened

From: Peter Volkov <pva@g.o>
To: gentoo-hardened@l.g.o
Subject: Re: [gentoo-hardened] Update on selinux-policy-2 eclass
Date: Wed, 03 Aug 2011 15:02:38
Message-Id: 1312383671.25999.12.camel@tablet
In Reply to: Re: [gentoo-hardened] Update on selinux-policy-2 eclass by Sven Vermeulen
1 В Срд, 03/08/2011 в 15:29 +0200, Sven Vermeulen пишет:
2 > > 4. [ -n "${POLICY_PATCH}" ]
3 > > generally it's better to use bash tests [[ ]] and avoid quotation.
4 >
5 > For POLICY_PATCH, I'll keep the quotation(s) because it can contain multiple
6 > patches (space-separated).
7
8 If you use [[ -n ${POLICY_PATCH} ]] then quotation is not needed even in
9 case it contains multiple values. E.g. here:
10 if [[ -n "${POLICY_PATCH}" ]];
11
12 quotation is not required - bash will understand this correctly.
13
14 BTW,
15 for POLPATCH in "${POLICY_PATCH}";
16 do
17 cd "${S}/refpolicy/policy/modules"
18 epatch "${POLPATCH}"
19 done
20
21 It looks like quotation is not necessary around "${POLICY_PATCH}"?
22 Independently of how many values has "${POLICY_PATCH}" values for cycle
23 will iterate only once.
24
25 Also it looks like it's better use bash array for POLICY_PATCH. This way
26 you'll allow path to patch to have spaces and still correct iteration.
27 For example take a look at PATCHES variable in base.eclass. It has code
28 that allows you to make such changes in eclass backward compatible. But
29 still it's better to use arrays so probably it's good idea for eclass
30 just die in case user uses POLICY_PATCH as a variable and not as a bash
31 array:
32
33 POLICY_PATCH=( "${FILESDIR}/mypatch.patch" "${FILESDIR}/patches_folder/"
34 )
35
36 [[ "$(declare -p POLICY_PATCH 2>/dev/null 2>&1)" == "declare -a"* ]] ||
37 die
38 for x in "${POLICY_PATCH[@]}"; do
39 epatch "${x}"
40 done
41
42 > > 8.
43 > > selinux-policy-2_src_compile() {
44 > > for i in ${POLICY_TYPES}; do
45 > > make NAME=$i -C "${S}"/${i} || die "${i} compile failed"
46 > > Is parallel build unsupported here? May be emake?
47 >
48 > emake fails here
49
50 It's good idea to document this within comments above and use emake -j1.
51
52 --
53 Peter.