Bug 716635

Summary: selinux-policy.spec: add option to skip building the -doc package
Product: [Fedora] Fedora Reporter: Mr-4 <mr.dash.four>
Component: selinux-policyAssignee: Miroslav Grepl <mgrepl>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 15CC: dominick.grift, dwalsh, mgrepl
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-02-06 17:14:24 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Attachments:
Description Flags
Patch allowing the doc sub-package to be excluded when building the selinux policy rpm none

Description Mr-4 2011-06-25 20:30:50 UTC
Description of problem:
Currently there is no option to skip compiling and building the selinux-doc sub-package in the .spec file. 

There is option to skip/build the various other policies (mls, minimum, targeted etc), but there is no such option for the doc sub-package.

Version-Release number of selected component (if applicable):
Latest SELinux policy as distributed with FC15

How reproducible:
always

Steps to Reproduce:
1. rpmbuild -bb selinux-policy.spec
2.
3.
  
Actual results:
the -doc sub-package is always created

Expected results:
an option to include/exclude this sub-package as desired

Additional info:
The attached patch (made against the .spec file distributed with the latest policy) fixes this.

Comment 1 Mr-4 2011-06-25 20:33:22 UTC
Created attachment 509924 [details]
Patch allowing the doc sub-package to be excluded when building the selinux policy rpm

Comment 2 Daniel Walsh 2011-06-26 11:09:34 UTC
Looks reasonable.

Comment 3 Daniel Walsh 2012-02-06 17:14:24 UTC
Lost this in the weeds.

Fixed in selinux-policy-3.10.0-83.fc17

Comment 4 Mr-4 2012-02-06 19:42:44 UTC
OK, seen that I submitted this over 6 months ago - when my rpm-building experience wasn't all that, I have a few optimisations to make (will re-submit a separate patch, if needed - just let me know if that is the case):

%if %{?BUILD_DOC:0}%{!?BUILD_DOC:1}
%define BUILD_DOC 1
%endif

[...]

+%if %{BUILD_DOC}
 make UNK_PERMS=allow NAME=targeted TYPE=mcs DISTRO=%{distro} UBAC=n DIRECT_INITRC=n MONOLITHIC=%{monolithic} DESTDIR=%{buildroot} PKGNAME=%{name}-%{version} POLY=y MLS_CATS=1024 MCS_CATS=1024 install-headers install-docs
+%else
+make UNK_PERMS=allow NAME=targeted TYPE=mcs DISTRO=%{distro} UBAC=n DIRECT_INITRC=n MONOLITHIC=%{monolithic} DESTDIR=%{buildroot} PKGNAME=%{name}-%{version} POLY=y MLS_CATS=1024 MCS_CATS=1024 install-headers
+%endif

Could be transformed/optimised with the following:

%if %{?BUILD_DOC:0}%{!?BUILD_DOC:1}
%define BUILD_DOC 1
%define docs-target install-docs
%else
%define docs-target %{nil}
%endif

[...]

 make UNK_PERMS=allow NAME=targeted TYPE=mcs DISTRO=%{distro} UBAC=n DIRECT_INITRC=n MONOLITHIC=%{monolithic} DESTDIR=%{buildroot} PKGNAME=%{name}-%{version} POLY=y MLS_CATS=1024 MCS_CATS=1024 install-headers %{docs-target}

Comment 5 Daniel Walsh 2012-02-06 20:33:18 UTC
I had done a different optimization but I kind of like yours.

Comment 6 Miroslav Grepl 2012-02-07 10:54:33 UTC
(In reply to comment #4)

> %endif
> 
> [...]
> 
>  make UNK_PERMS=allow NAME=targeted TYPE=mcs DISTRO=%{distro} UBAC=n
> DIRECT_INITRC=n MONOLITHIC=%{monolithic} DESTDIR=%{buildroot}
> PKGNAME=%{name}-%{version} POLY=y MLS_CATS=1024 MCS_CATS=1024 install-headers
> %{docs-target}

Is it working for you?

Comment 7 Miroslav Grepl 2012-02-07 12:48:09 UTC
It wants docs_target instead of docs-target. But there is another issue.

Comment 8 Mr-4 2012-02-07 14:18:30 UTC
Yeah, I didn't actually test it (apparently, Fedora's RPM got confused by the dash in "docs-target"), but the following *does* work (tried and tested - promise!):

%if %{?BUILD_DOC:0}%{!?BUILD_DOC:1}
%define BUILD_DOC 1
%define docstarget install-docs
%else
%define docstarget %{nil}
%endif

[...]

make UNK_PERMS=allow NAME=targeted TYPE=mcs DISTRO=%{distro} UBAC=n
DIRECT_INITRC=n MONOLITHIC=%{monolithic} DESTDIR=%{buildroot}
PKGNAME=%{name}-%{version} POLY=y MLS_CATS=1024 MCS_CATS=1024 install-headers
%{docstarget}

On a separate note - any chance you can get Bug 716632 pulled "out of the weeds" as well?

Comment 9 Daniel Walsh 2012-02-07 14:56:30 UTC
That one has been fixed for a while.

 man semodule_expand
...

       -a     Do  not  check  assertions.   This  will cause the policy to not
              check any neverallow rules.