Use https by default
[gentoo.git] / app-admin / setools / setools-3.3.8-r5.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI="5"
6 PYTHON_COMPAT=( python2_7 )
7
8 inherit autotools java-pkg-opt-2 python-r1 eutils toolchain-funcs
9
10 DESCRIPTION="SELinux policy tools"
11 HOMEPAGE="http://www.tresys.com/selinux/selinux_policy_tools.shtml"
12 SRC_URI="http://oss.tresys.com/projects/setools/chrome/site/dists/${P}/${P}.tar.bz2
13         https://dev.gentoo.org/~swift/patches/setools/${P}-01-fedora-patches.tar.gz
14         https://dev.gentoo.org/~swift/patches/setools/${P}-03-gentoo-patches.tar.gz"
15
16 LICENSE="GPL-2"
17 SLOT="0"
18 KEYWORDS="amd64 x86"
19 IUSE="X debug java python"
20
21 DEPEND=">=sys-libs/libsepol-2.1.4
22         >=sys-libs/libselinux-2.3
23         sys-devel/bison
24         sys-devel/flex
25         >=dev-db/sqlite-3.2:3
26         dev-libs/libxml2:2
27         virtual/pkgconfig
28         java? (
29                 dev-lang/swig:1
30                 >=virtual/jdk-1.4
31         )
32         python? (
33                 ${PYTHON_DEPS}
34                 dev-lang/swig:1
35         )
36         X? (
37                 >=dev-lang/tk-8.4.9
38                 >=gnome-base/libglade-2.0
39                 >=x11-libs/gtk+-2.8:2
40         )"
41
42 RDEPEND=">=sys-libs/libsepol-2.1.4
43         >=sys-libs/libselinux-2.3
44         >=dev-db/sqlite-3.2:3
45         dev-libs/libxml2:2
46         java? ( >=virtual/jre-1.4 )
47         X? (
48                 >=dev-lang/tk-8.4.9:0=
49                 >=dev-tcltk/bwidget-1.8
50                 >=gnome-base/libglade-2.0
51                 >=x11-libs/gtk+-2.8:2
52         )"
53
54 RESTRICT="test"
55 # setools dirs that contain python code to build
56 PYTHON_DIRS="libapol/swig/python libpoldiff/swig/python libqpol/swig/python libseaudit/swig/python libsefs/swig/python python"
57
58 pkg_setup() {
59         if use java; then
60                 java-pkg-opt-2_pkg_setup
61         fi
62 }
63
64 src_prepare() {
65         EPATCH_MULTI_MSG="Applying various (Fedora-provided) setools fixes... " \
66         EPATCH_SUFFIX="patch" \
67         EPATCH_SOURCE="${WORKDIR}" \
68         EPATCH_FORCE="yes" \
69         epatch
70
71         EPATCH_MULTI_MSG="Applying various (Gentoo) setool fixes... " \
72         EPATCH_SUFFIX="patch" \
73         EPATCH_SOURCE="${WORKDIR}/gentoo-patches" \
74         EPATCH_FORCE="yes" \
75         epatch
76
77         # Disable broken check for SWIG version.
78         sed -e "s/AC_PROG_SWIG(2.0.0)/AC_PROG_SWIG/" -i configure.ac || die "sed failed"
79         # Use swig1.3
80         sed -e 's/AC_PATH_PROG(\[SWIG\],\[swig\])/AC_PATH_PROG([SWIG],[swig1.3])/' -i m4/ac_pkg_swig.m4 || die "failed to set swig1.3"
81         # Fix build failure due to double __init__.py installation
82         sed -e "s/^wrappedpy_DATA = qpol.py \$(pkgpython_PYTHON)/wrappedpy_DATA = qpol.py/" -i libqpol/swig/python/Makefile.am || die
83
84         local dir
85         for dir in ${PYTHON_DIRS}; do
86                 # Python bindings are built/installed manually.
87                 sed -e "s/MAYBE_PYSWIG = python/MAYBE_PYSWIG =/" -i ${dir%python}Makefile.am || die "sed failed"
88                 # Make PYTHON_LDFLAGS replaceable during running `make`.
89                 sed -e "/^AM_LDFLAGS =/s/@PYTHON_LDFLAGS@/\$(PYTHON_LDFLAGS)/" -i ${dir}/Makefile.am || die "sed failed"
90         done
91
92         # temporary work around bug #424581 until automake-1.12 is stable (then
93         # depend on it). Need to use MKDIR_P in the mean time for 1.12+.
94         has_version ">=sys-devel/automake-1.12.1" && { find . -name 'Makefile.*' -exec sed -i -e 's:mkdir_p:MKDIR_P:g' {} +  || die; }
95
96         eautoreconf
97
98         # Disable byte-compilation of Python modules.
99         echo '#!/bin/sh' > py-compile
100
101         epatch_user
102 }
103
104 src_configure() {
105         tc-ld-disable-gold #467136
106         econf \
107                 --with-java-prefix=${JAVA_HOME} \
108                 --disable-selinux-check \
109                 --disable-bwidget-check \
110                 $(use_enable python swig-python) \
111                 $(use_enable java swig-java) \
112                 $(use_enable X swig-tcl) \
113                 $(use_enable X gui) \
114                 $(use_enable debug)
115
116         # work around swig c99 issues.  it does not require
117         # c99 anyway.
118         sed -i -e 's/-std=gnu99//' "${S}/libseaudit/swig/python/Makefile"
119 }
120
121 src_compile() {
122         emake
123
124         if use python; then
125                 building() {
126                         python_export PYTHON_INCLUDEDIR
127                         python_export PYTHON_SITEDIR
128                         python_export PYTHON_LIBS
129                         emake \
130                                 SWIG_PYTHON_CPPFLAGS="-I${PYTHON_INCLUDEDIR}" \
131                                 PYTHON_LDFLAGS="${PYTHON_LIBS}" \
132                                 pyexecdir="${PYTHON_SITEDIR}" \
133                                 pythondir="${PYTHON_SITEDIR}" \
134                                 -C "$1"
135                 }
136                 local dir
137                 for dir in ${PYTHON_DIRS}; do
138                         python_foreach_impl building ${dir}
139                 done
140         fi
141 }
142
143 src_install() {
144         emake DESTDIR="${D}" install
145
146         if use python; then
147                 installation() {
148                         python_export PYTHON_SITEDIR
149                         emake DESTDIR="${D}" \
150                                 pyexecdir="${PYTHON_SITEDIR}" \
151                                 pythondir="${PYTHON_SITEDIR}" \
152                                 -C "$1" install
153                 }
154
155                 local dir
156                 for dir in ${PYTHON_DIRS}; do
157                         python_foreach_impl installation "${dir}"
158                 done
159         fi
160 }