@@ -0,0 +1,75 @@
1+{ stdenv, fetchurl, bzip2, lzo, zlib, xz, bash, python, gnutar, gnused, gnugrep, which }:
3+stdenv.mkDerivation (rec {
4+ name = "xe-guest-utilities";
7+ description = "Citrix XenServer Tools";
8+ homepage = http://citrix.com/English/ps2/products/product.asp?contentID=683148&ntref=hp_nav_US;
9+ maintainers = with stdenv.lib.maintainers; [ benwbooth ];
10+ platforms = stdenv.lib.platforms.linux;
11+ license = [ stdenv.lib.licenses.gpl2 stdenv.lib.licenses.lgpl21 ];
14+ url = "https://sources.archlinux.org/other/community/xe-guest-utilities/xe-guest-utilities_${version}-1120.tar.gz";
15+ sha256 = "f9593cd9588188f80253e736f48d8dd94c5b517abb18316085f86acffab48794";
17+ buildInputs = [ bzip2 gnutar gnused python lzo zlib xz stdenv gnugrep which ];
18+ patches = [ ./ip-address.patch ];
20+ tar xf "$NIX_BUILD_TOP/$name-$version/xenstore-sources.tar.bz2"
25+ export CFLAGS='-Wall -Wstrict-prototypes -Wno-unused-local-typedefs -Wno-sizeof-pointer-memaccess'
26+ export PYTHON=python2
27+ cd "$NIX_BUILD_TOP/$name-$version/uclibc-sources"
28+ for file in Config.mk tools/libxc/Makefile tools/misc/Makefile tools/misc/lomount/Makefile tools/xenstore/Makefile; do
29+ substituteInPlace "$file" --replace -Werror ""
31+ make -C tools/include
33+ make -C tools/xenstore
37+ export CFLAGS+='-Wall -Wstrict-prototypes -Wno-unused-local-typedefs -Wno-sizeof-pointer-memaccess'
38+ if [[ $CARCH == x86_64 ]]; then
39+ export LIBLEAFDIR_x86_64=lib
41+ for f in include libxc xenstore; do
42+ [[ ! -d $NIX_BUILD_TOP/$name-$version/uclibc-sources/tools/$f ]] && continue
43+ make -C "$NIX_BUILD_TOP/$name-$version/uclibc-sources/tools/$f" DESTDIR="$out" BINDIR=/bin SBINDIR=/bin INCLUDEDIR=/include LIBDIR=/lib install
47+ cd "$NIX_BUILD_TOP/$name-$version"
48+ install -Dm755 xe-update-guest-attrs "$out/bin/xe-update-guest-attrs"
49+ install -Dm755 xe-daemon "$out/bin/xe-daemon"
50+ install -Dm644 xen-vcpu-hotplug.rules "$out/lib/udev/rules.d/10-xen-vcpu-hotplug.rules"
51+ substituteInPlace "$out/bin/xe-daemon" --replace sbin bin
52+ substituteInPlace "$out/bin/xe-daemon" --replace /usr/ "$out/"
53+ substituteInPlace "$out/bin/xe-update-guest-attrs" --replace /usr/ "$out/"
54+ substituteInPlace "$out/bin/xe-update-guest-attrs" --replace 'export PATH=' 'export PATH=$PATH:'
55+ substituteInPlace "$out/lib/udev/rules.d/10-xen-vcpu-hotplug.rules" --replace /bin/sh '${bash}/bin/sh'
57+ cat <<'EOS' >"$out/bin/xe-linux-distribution"
58+ #!${bash}/bin/bash -eu
60+ if [[ $# -gt 0 ]]; then
61+ mkdir -p "$(dirname "$1")"
66+ os_majorver="''${VERSION_ID%%.*}"
67+ os_minorver="''${VERSION_ID#*.}"
68+ os_uname="$(uname -r)"
69+ os_name="$PRETTY_NAME"
72+ chmod 0755 "$out/bin/xe-linux-distribution"