2016-01-18 00:04:40 +01:00
|
|
|
{ stdenv, fetchurl, pkgconfig, autoreconfHook, makeWrapper
|
2018-12-15 04:50:31 +01:00
|
|
|
, ncurses, cpio, gperf, cdrkit, flex, bison, qemu, pcre, augeas, libxml2
|
2014-11-06 11:32:59 +01:00
|
|
|
, acl, libcap, libcap_ng, libconfig, systemd, fuse, yajl, libvirt, hivex
|
2018-12-15 04:50:31 +01:00
|
|
|
, gmp, readline, file, numactl, xen, libapparmor
|
2018-01-09 14:36:37 +01:00
|
|
|
, getopt, perlPackages, ocamlPackages
|
2018-03-21 14:05:34 +01:00
|
|
|
, appliance ? null
|
2018-01-09 14:36:37 +01:00
|
|
|
, javaSupport ? false, jdk ? null }:
|
|
|
|
|
2018-03-21 14:05:34 +01:00
|
|
|
assert appliance == null || stdenv.lib.isDerivation appliance;
|
2018-01-09 14:36:37 +01:00
|
|
|
assert javaSupport -> jdk != null;
|
2014-11-06 11:32:59 +01:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
name = "libguestfs-${version}";
|
2018-10-03 19:03:27 +02:00
|
|
|
version = "1.38.6";
|
2014-11-06 11:32:59 +01:00
|
|
|
|
|
|
|
src = fetchurl {
|
2018-02-21 20:31:25 +01:00
|
|
|
url = "http://libguestfs.org/download/1.38-stable/libguestfs-${version}.tar.gz";
|
2018-10-03 19:03:27 +02:00
|
|
|
sha256 = "1v2mggx2jlaq4m3p5shc46gzf7vmaayha6r0nwdnyzd7x6q0is7p";
|
2014-11-06 11:32:59 +01:00
|
|
|
};
|
|
|
|
|
2017-09-14 21:24:37 +02:00
|
|
|
nativeBuildInputs = [ pkgconfig ];
|
2014-11-06 11:32:59 +01:00
|
|
|
buildInputs = [
|
2018-12-15 04:50:31 +01:00
|
|
|
makeWrapper autoreconfHook ncurses cpio gperf
|
2014-11-06 11:32:59 +01:00
|
|
|
cdrkit flex bison qemu pcre augeas libxml2 acl libcap libcap_ng libconfig
|
2018-12-15 04:50:31 +01:00
|
|
|
systemd fuse yajl libvirt gmp readline file hivex
|
|
|
|
numactl xen libapparmor getopt perlPackages.ModuleBuild
|
|
|
|
] ++ (with perlPackages; [ perl libintl_perl GetoptLong SysVirt ])
|
|
|
|
++ (with ocamlPackages; [ ocaml findlib ocamlbuild ocaml_libvirt ocaml_gettext ounit ])
|
2018-01-09 14:36:37 +01:00
|
|
|
++ stdenv.lib.optional javaSupport jdk;
|
2014-11-06 11:32:59 +01:00
|
|
|
|
2017-02-22 07:01:09 +01:00
|
|
|
prePatch = ''
|
|
|
|
# build-time scripts
|
2019-01-15 23:41:31 +01:00
|
|
|
substituteInPlace run.in --replace '#!/bin/bash' '#!${stdenv.shell}'
|
|
|
|
substituteInPlace ocaml-link.sh --replace '#!/bin/bash' '#!${stdenv.shell}'
|
2017-02-22 07:01:09 +01:00
|
|
|
|
|
|
|
# $(OCAMLLIB) is read-only "${ocamlPackages.ocaml}/lib/ocaml"
|
|
|
|
substituteInPlace ocaml/Makefile.am --replace '$(DESTDIR)$(OCAMLLIB)' '$(out)/lib/ocaml'
|
|
|
|
substituteInPlace ocaml/Makefile.in --replace '$(DESTDIR)$(OCAMLLIB)' '$(out)/lib/ocaml'
|
|
|
|
substituteInPlace v2v/test-harness/Makefile.am --replace '$(DESTDIR)$(OCAMLLIB)' '$(out)/lib/ocaml'
|
|
|
|
substituteInPlace v2v/test-harness/Makefile.in --replace '$(DESTDIR)$(OCAMLLIB)' '$(out)/lib/ocaml'
|
2017-05-19 13:29:29 +02:00
|
|
|
|
|
|
|
# some scripts hardcore /usr/bin/env which is not available in the build env
|
|
|
|
patchShebangs .
|
2017-02-22 07:01:09 +01:00
|
|
|
'';
|
2018-02-22 01:26:49 +01:00
|
|
|
configureFlags = [ "--disable-appliance" "--disable-daemon" "--with-distro=NixOS" ]
|
2018-01-09 14:36:37 +01:00
|
|
|
++ stdenv.lib.optionals (!javaSupport) [ "--disable-java" "--without-java" ];
|
2014-11-06 11:32:59 +01:00
|
|
|
patches = [ ./libguestfs-syms.patch ];
|
2015-10-05 13:23:01 +02:00
|
|
|
NIX_CFLAGS_COMPILE="-I${libxml2.dev}/include/libxml2/";
|
2017-02-22 07:01:09 +01:00
|
|
|
installFlags = "REALLY_INSTALL=yes";
|
2017-05-19 13:29:29 +02:00
|
|
|
enableParallelBuilding = true;
|
2014-11-06 11:32:59 +01:00
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
for bin in $out/bin/*; do
|
|
|
|
wrapProgram "$bin" \
|
2018-03-21 14:05:34 +01:00
|
|
|
--prefix PATH : "$out/bin:${hivex}/bin:${qemu}/bin" \
|
2018-12-15 04:50:31 +01:00
|
|
|
--prefix PERL5LIB : "$out/${perlPackages.perl.libPrefix}"
|
2014-11-06 11:32:59 +01:00
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
2018-03-21 14:05:34 +01:00
|
|
|
postFixup = stdenv.lib.optionalString (appliance != null) ''
|
|
|
|
mkdir -p $out/{lib,lib64}
|
|
|
|
ln -s ${appliance} $out/lib64/guestfs
|
|
|
|
ln -s ${appliance} $out/lib/guestfs
|
|
|
|
'';
|
|
|
|
|
2018-03-22 08:19:12 +01:00
|
|
|
doInstallCheck = appliance != null;
|
2018-03-21 14:05:34 +01:00
|
|
|
installCheckPhase = ''
|
|
|
|
export HOME=$(mktemp -d) # avoid access to /homeless-shelter/.guestfish
|
|
|
|
|
|
|
|
${qemu}/bin/qemu-img create -f qcow2 disk1.img 10G
|
|
|
|
|
|
|
|
$out/bin/guestfish <<'EOF'
|
|
|
|
add-drive disk1.img
|
|
|
|
run
|
|
|
|
list-filesystems
|
|
|
|
part-disk /dev/sda mbr
|
|
|
|
mkfs ext2 /dev/sda1
|
|
|
|
list-filesystems
|
|
|
|
EOF
|
2014-11-06 11:32:59 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
description = "Tools for accessing and modifying virtual machine disk images";
|
|
|
|
license = licenses.gpl2;
|
|
|
|
homepage = http://libguestfs.org/;
|
|
|
|
maintainers = with maintainers; [offline];
|
2015-11-17 21:29:29 +01:00
|
|
|
platforms = platforms.linux;
|
2014-11-06 11:32:59 +01:00
|
|
|
};
|
|
|
|
}
|