2021-02-05 17:12:51 +00:00
{ lib , stdenv , fetchurl , pkg-config , bison , flex , libsepol , libselinux , bzip2 , audit
2020-04-24 23:36:52 +00:00
, enablePython ? true , swig ? null , python ? null
} :
2021-02-05 17:12:51 +00:00
with lib ;
2020-04-24 23:36:52 +00:00
stdenv . mkDerivation rec {
pname = " l i b s e m a n a g e " ;
2021-12-06 16:07:01 +00:00
version = " 3 . 3 " ;
inherit ( libsepol ) se_url ;
2020-04-24 23:36:52 +00:00
src = fetchurl {
2021-12-06 16:07:01 +00:00
url = " ${ se_url } / ${ version } / l i b s e m a n a g e - ${ version } . t a r . g z " ;
sha256 = " 1 s 3 w b 6 6 l 4 7 b l c 1 5 s 6 l k q s 1 1 j 9 l 8 p y c d q q b b 0 3 x 3 v p f r l z 9 d f r l 4 4 " ;
2020-04-24 23:36:52 +00:00
} ;
outputs = [ " o u t " " d e v " " m a n " ] ++ optional enablePython " p y " ;
2021-12-06 16:07:01 +00:00
strictDeps = true ;
nativeBuildInputs = [ bison flex pkg-config ] ++ optional enablePython swig ;
2020-04-24 23:36:52 +00:00
buildInputs = [ libsepol libselinux bzip2 audit ]
2021-12-06 16:07:01 +00:00
++ optional enablePython python ;
2020-04-24 23:36:52 +00:00
makeFlags = [
" P R E F I X = $ ( o u t ) "
" I N C L U D E D I R = $ ( d e v ) / i n c l u d e "
" M A N 3 D I R = $ ( m a n ) / s h a r e / m a n / m a n 3 "
" M A N 5 D I R = $ ( m a n ) / s h a r e / m a n / m a n 5 "
" P Y T H O N = p y t h o n "
2021-12-06 16:07:01 +00:00
" P Y P R E F I X = p y t h o n "
2020-04-24 23:36:52 +00:00
" P Y T H O N L I B D I R = $ ( p y ) / ${ python . sitePackages } "
" D E F A U L T _ S E M A N A G E _ C O N F _ L O C A T I O N = $ ( o u t ) / e t c / s e l i n u x / s e m a n a g e . c o n f "
] ;
2021-02-13 14:23:35 +00:00
# The following turns the 'clobbered' error into a warning
# which should fix the following error:
#
# semanage_store.c: In function 'semanage_exec_prog':
# semanage_store.c:1278:6: error: variable 'i' might be clobbered by 'longjmp' or 'vfork' [8;;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wclobbered -Werror=clobbered8;; ]
# 1278 | int i;
# | ^
# cc1: all warnings being treated as errors
NIX_CFLAGS_COMPILE = [ " - W n o - e r r o r = c l o b b e r e d " ] ;
2020-04-24 23:36:52 +00:00
installTargets = [ " i n s t a l l " ] ++ optionals enablePython [ " i n s t a l l - p y w r a p " ] ;
2021-12-06 16:07:01 +00:00
enableParallelBuilding = true ;
2020-04-24 23:36:52 +00:00
meta = removeAttrs libsepol . meta [ " o u t p u t s T o I n s t a l l " ] // {
description = " P o l i c y m a n a g e m e n t t o o l s f o r S E L i n u x " ;
2021-02-05 17:12:51 +00:00
license = lib . licenses . lgpl21 ;
2020-04-24 23:36:52 +00:00
} ;
}