summaryrefslogtreecommitdiff
blob: ed65ee9489f69b806314c12d43ee8886733fd9f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

inherit flag-o-matic linux-info perl-functions strip-linguas toolchain-funcs

MY_PV_1="$(ver_cut 1-2)"
MY_PV_2="$(ver_cut 2)"
[[ $(( ${MY_PV_2} % 2 )) -eq 0 ]] && SD="stable" || SD="development"

DESCRIPTION="Tools for accessing, inspecting, and modifying virtual machine (VM) disk images"
HOMEPAGE="https://libguestfs.org/"
SRC_URI="https://download.libguestfs.org/${PN}/${MY_PV_1}-${SD}/${P}.tar.gz"

LICENSE="GPL-2 LGPL-2"
SLOT="0/${MY_PV_1}"
KEYWORDS="~amd64"
IUSE="doc +ocaml +perl test"
RESTRICT="!test? ( test )"

# Failures - doc
COMMON_DEPEND="
	!<app-emulation/libguestfs-1.46.0-r1
	app-arch/cpio
	app-arch/lzma
	app-arch/unzip[natspec]
	app-arch/xz-utils
	app-crypt/gnupg
	>=app-emulation/libguestfs-${MY_PV_1}:=[ocaml?,perl?]
	app-emulation/libvirt:=
	>=app-emulation/qemu-2.0[qemu_softmmu_targets_x86_64,filecaps]
	dev-lang/perl:=
	dev-libs/libpcre2:=
	dev-libs/libxml2:2
	dev-libs/jansson:=
	>=sys-apps/fakechroot-2.8
	sys-fs/squashfs-tools:*
	sys-libs/libxcrypt:=
	virtual/libcrypt:=
	ocaml? ( >=dev-lang/ocaml-4.03:=[ocamlopt] )
	perl? (
		virtual/perl-Data-Dumper
		virtual/perl-Getopt-Long
		dev-perl/Module-Build
		dev-perl/libintl-perl
		virtual/perl-ExtUtils-MakeMaker
		>=dev-perl/Sys-Virt-0.2.4
		dev-perl/String-ShellQuote
		test? ( virtual/perl-Test-Simple )
	)
"
# Some OCaml is always required
# bug #729674
DEPEND="${COMMON_DEPEND}
	>=dev-lang/ocaml-4.03:=[ocamlopt]
	dev-ml/findlib[ocamlopt]
	doc? ( app-text/po4a )
	ocaml? (
		dev-ml/ounit2[ocamlopt]
		|| (
			<dev-ml/ocaml-gettext-0.4.2
			dev-ml/ocaml-gettext-stub[ocamlopt]
		)
	)
"
BDEPEND="virtual/pkgconfig"
RDEPEND="${COMMON_DEPEND}
	app-emulation/libguestfs-appliance
"

DOCS=( AUTHORS BUGS ChangeLog HACKING README TODO )

#PATCHES=(
#	"${FILESDIR}"/${MY_PV_1}/
#)

pkg_setup() {
	CONFIG_CHECK="~KVM ~VIRTIO"
	[[ -n "${CONFIG_CHECK}" ]] && check_extra_config
}

src_configure() {
	# bug #794877
	tc-export AR

	if use test ; then
		# Skip Bash test
		# (See 13-test-suite.log in linked bug)
		# bug #794874
		export SKIP_TEST_COMPLETE_IN_SCRIPT_SH=1

		# This test requires libvirt support in libguestfs and it makes
		# no difference at runtime. Just gracefully skip it to make life
		# easier for e.g. arch testing.
		if ! has_version 'app-emulation/libguestfs[libvirt]' ; then
			export SKIP_TEST_VIRT_ALIGNMENT_SCAN_GUESTS_SH=1
		fi

		# Needed for the inspector tests. Provided by libguestfs-appliance.
		#export LIBGUESTFS_PATH="${BROOT}"/usr/share/guestfs/appliance/
		# But the inspector tests seem fragile anyway...
		export SKIP_TEST_VIRT_INSPECTOR_LUKS_SH=1
		export SKIP_TEST_VIRT_INSPECTOR_SH=1
	fi

	# Disable feature test for kvm for more reason
	# i.e: not loaded module in __build__ time,
	# build server not supported kvm, etc. ...
	#
	# In fact, this feature is virtio support and requires
	# configured kernel.
	export vmchannel_test=no

	# Give a nudge to help find libxcrypt[-system]
	# We have a := dep on virtual/libcrypt to ensure this
	# doesn't become stale.
	# bug #703118, bug #789354
	if ! has_version 'sys-libs/libxcrypt[system]' ; then
		append-ldflags "-L${ESYSROOT}/usr/$(get_libdir)/xcrypt"
		append-ldflags "-Wl,-R${ESYSROOT}/usr/$(get_libdir)/xcrypt"
	fi

	econf \
		$(usex doc '' PO4A=no) \
		$(use_enable ocaml) \
		$(use_enable perl)
}

src_install() {
	strip-linguas -i po

	emake DESTDIR="${D}" install "LINGUAS=""${LINGUAS}"""

	find "${ED}" -name '*.la' -delete || die

	if use perl ; then
		perl_delete_localpod
	fi
}

pkg_postinst() {
	if ! use ocaml ; then
		einfo "OCaml based tools and bindings (virt-resize, virt-sparsify, virt-sysprep, ...) NOT installed"
	fi

	if ! use perl ; then
		einfo "Perl based tools NOT built"
	fi
}