2021-12-06 16:07:01 +00:00
{ lib
, stdenv
, docbook_xml_dtd_44
, docbook_xml_dtd_45
, docbook_xsl
, asciidoctor
, fetchurl
, flex
, kmod
, libxslt
, nixosTests
, perl
, systemd
# drbd-utils are compiled twice, once with forOCF = true to extract
# its OCF definitions for use in the ocf-resource-agents derivation,
# then again with forOCF = false, where the ocf-resource-agents is
# provided as the OCF_ROOT.
, forOCF ? false
, ocf-resource-agents
} :
2020-04-24 23:36:52 +00:00
stdenv . mkDerivation rec {
2021-09-26 12:46:18 +00:00
pname = " d r b d " ;
2021-12-06 16:07:01 +00:00
version = " 9 . 1 9 . 1 " ;
2020-04-24 23:36:52 +00:00
src = fetchurl {
2021-12-06 16:07:01 +00:00
url = " h t t p s : / / p k g . l i n b i t . c o m / d o w n l o a d s / d r b d / u t i l s / ${ pname } - u t i l s - ${ version } . t a r . g z " ;
sha256 = " 1 l 9 9 k c r b 0 j 8 5 w x x m r d i h p x 9 b k 1 a 4 s d i 7 w l p 5 m 1 x 5 l 2 4 k 8 c k 1 m 5 c f " ;
2020-04-24 23:36:52 +00:00
} ;
2021-12-06 16:07:01 +00:00
nativeBuildInputs = [
flex
libxslt
docbook_xsl
asciidoctor
] ;
2020-04-24 23:36:52 +00:00
2021-12-06 16:07:01 +00:00
buildInputs = [
perl
# perlPackages.Po4a used by ja documentation
] ;
2020-04-24 23:36:52 +00:00
configureFlags = [
2021-12-06 16:07:01 +00:00
" - - l i b d i r = ${ placeholder " o u t " } / l i b "
" - - s b i n d i r = ${ placeholder " o u t " } / b i n "
2020-04-24 23:36:52 +00:00
" - - l o c a l s t a t e d i r = / v a r "
" - - s y s c o n f d i r = / e t c "
2021-12-06 16:07:01 +00:00
" - - w i t h o u t - d i s t r o "
2020-04-24 23:36:52 +00:00
] ;
2021-12-06 16:07:01 +00:00
makeFlags = [
" S O U R C E _ D A T E _ E P O C H = 1 "
" W A N T _ D R B D _ R E P R O D U C I B L E _ B U I L D = 1 "
] ++ lib . optional ( ! forOCF ) " O C F _ R O O T = ${ ocf-resource-agents } / u s r / l i b / o c f } " ;
2020-04-24 23:36:52 +00:00
installFlags = [
2021-12-06 16:07:01 +00:00
" p r e f i x = "
" D E S T D I R = ${ placeholder " o u t " } "
" l o c a l s t a t e d i r = / v a r "
" D R B D _ L I B _ D I R = / v a r / l i b "
" I N I T D I R = / e t c / i n i t . d "
" u d e v r u l e s d i r = / e t c / u d e v / r u l e s . d "
" s y s c o n f d i r = / e t c "
" s b i n d i r = / b i n "
" d a t a d i r = "
" L I B D I R = / l i b / d r b d "
" m a n d i r = / s h a r e / m a n "
2020-04-24 23:36:52 +00:00
] ;
2021-12-06 16:07:01 +00:00
postPatch = ''
patchShebangs .
substituteInPlace user/v84/drbdadm_usage_cnt.c \
- - replace ' " / l i b / d r b d " ) ; ' \
' " ${ placeholder " o u t " } / l i b / d r b d " ) ; '
substituteInPlace user/v9/drbdsetup_linux.c \
- - replace ' ret = system ( " / s b i n / m o d p r o b e d r b d " ) ; ' \
' ret = system ( " ${ kmod } / b i n / m o d p r o b e d r b d " ) ; '
substituteInPlace user/v84/drbdsetup.c \
- - replace ' system ( " / s b i n / m o d p r o b e d r b d " ) ' \
' system ( " ${ kmod } / b i n / m o d p r o b e d r b d " ) '
substituteInPlace documentation/ra2refentry.xsl \
- - replace " h t t p : / / w w w . o a s i s - o p e n . o r g / d o c b o o k / x m l / 4 . 4 / d o c b o o k x . d t d " \
" ${ docbook_xml_dtd_44 } / x m l / d t d / d o c b o o k / d o c b o o k x . d t d "
function patch_docbook45 ( ) {
substituteInPlace $ 1 \
- - replace " h t t p : / / w w w . o a s i s - o p e n . o r g / d o c b o o k / x m l / 4 . 5 / d o c b o o k x . d t d " \
" ${ docbook_xml_dtd_45 } / x m l / d t d / d o c b o o k / d o c b o o k x . d t d "
}
patch_docbook45 documentation/v9/drbd.conf.xml.in
patch_docbook45 documentation/v9/drbdsetup.xml.in
patch_docbook45 documentation/v84/drbdsetup.xml
patch_docbook45 documentation/v84/drbd.conf.xml
# The ja documentation is disabled because:
# make[1]: Entering directory '/build/drbd-utils-9.16.0/documentation/ja/v84'
# /nix/store/wyx2nn2pjcn50lc95c6qgsgm606rn0x2-perl5.32.1-po4a-0.62/bin/po4a-translate -f docbook -M utf-8 -L utf-8 -keep 0 -m ../../v84/drbdsetup.xml -p drbdsetup.xml.po -l drbdsetup.xml
# Use of uninitialized value $args[1] in sprintf at /nix/store/wyx2nn2pjcn50lc95c6qgsgm606rn0x2-perl5.32.1-po4a-0.62/lib/perl5/site_perl/Locale/Po4a/Common.pm line 134.
# Invalid po file drbdsetup.xml.po:
substituteInPlace Makefile . in \
- - replace ' DOC_DIRS : = documentation/v9 documentation/ja/v9 ' \
' DOC_DIRS : = documentation/v9 ' \
- - replace ' DOC_DIRS + = documentation/v84 documentation/ja/v84 ' \
' DOC_DIRS + = documentation/v84 ' \
- - replace ' $ ( MAKE ) - C documentation/ja/v9 doc' \
" " \
- - replace ' $ ( MAKE ) - C documentation/ja/v84 doc' \
" "
substituteInPlace user/v9/drbdtool_common.c \
- - replace ' add_component_to_path ( " / l i b / d r b d " ) ; ' \
' add_component_to_path ( " ${ placeholder " o u t " } / l i b / d r b d " ) ; '
'' ;
preConfigure = ''
export PATH = $ { systemd } /sbin : $ PATH
'' ;
enableParallelBuilding = true ;
passthru . tests . drbd = nixosTests . drbd ;
2021-01-15 22:18:51 +00:00
meta = with lib ; {
2021-12-06 16:07:01 +00:00
homepage = " h t t p s : / / l i n b i t . c o m / d r b d / " ;
description = " D i s t r i b u t e d R e p l i c a t e d B l o c k D e v i c e , a d i s t r i b u t e d s t o r a g e s y s t e m f o r L i n u x ( u s e r s p a c e u t i l i t i e s ) " ;
license = licenses . gpl2Plus ;
2020-04-24 23:36:52 +00:00
platforms = platforms . linux ;
2021-12-06 16:07:01 +00:00
maintainers = with maintainers ; [ ryantm astro ] ;
2020-04-24 23:36:52 +00:00
} ;
}