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 " ;
version = " 2 . 9 " ;
inherit ( libsepol ) se_release se_url ;
src = fetchurl {
url = " ${ se_url } / ${ se_release } / l i b s e m a n a g e - ${ version } . t a r . g z " ;
sha256 = " 0 7 5 w 6 y 3 l 9 h i y 5 h i c g w r m i j y x m h f y d 1 r 7 c n c 0 8 q x y g 4 j 4 6 j f k 8 x i 5 " ;
} ;
outputs = [ " o u t " " d e v " " m a n " ] ++ optional enablePython " p y " ;
2021-02-05 17:12:51 +00:00
nativeBuildInputs = [ bison flex pkg-config ] ;
2020-04-24 23:36:52 +00:00
buildInputs = [ libsepol libselinux bzip2 audit ]
++ optionals enablePython [ swig python ] ;
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 "
" 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 " ] ;
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
} ;
}