summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: d4024eb118934300b1ffe6f2a10204d9e946be57 (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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
## For build instructions, see https://libguestfs.org/guestfs-building.1.html
# Libguestfs: Installer: Arch
# Maintainer:  dreieck
# Contributor: Csaba Henk <csaba+arch@lowlife.hu>
# Contributor: Nikos Skalkotos <skalkoto (at) Gmail.com>
# Contributor: Xiao-Long Chen <chenxiaolong@cxl.epac.to>
# Contributor: Evaggelos Balaskas <eblaskas _AT_ ebalaskas _DOT_ gr>
# Contributor: Peter Wu <peter@lekensteyn.nl>

_pkgname=libguestfs
pkgname="${_pkgname}-git"
epoch=0
pkgver=1.51.7+4.r11933.20231030.0e37e5fee
pkgrel=2
pkgdesc="Access and modify virtual machine disk image"
arch=(
  "i686"
  "x86_64"
)
url="https://libguestfs.org"
license=("GPL2" "LGPL2.1")
backup=(
  "etc/libguestfs-tools.conf"
  "etc/php.d/guestfs_php.ini"
  "etc/xdg/virt-builder/repos.d/libguestfs.conf"
  "etc/xdg/virt-builder/repos.d/libguestfs.gpg"
)
install="appliance.install"
depends=(
  'augeas>=1.2.0'
  'bash'
  'cdrtools' # or 'libisoburn' or 'xorriso'
  'cpio'
  'file' # For libmagic.so
  'gcc-libs'
  'glibc'
  'hivex>=1.2.7'
  'jansson>=2.7'
  'libvirt>=0.10.2'
  'libxml2'
  'linux>=2.6.34'
  'ncurses'
  'psmisc'
  'supermin>=5.1.18'
  'qemu-common>=1.3.0'
  'qemu-img>=1.3.0'
  'xz'
  'zstd'

  #"qemu-headless"
  #"augeas"
  #"hivex>=1.3.2"
  #"libconfig"
  #"fuse"
  #"file"
  #"cpio"
  #"wget"
  #"jansson"
  #"supermin>=5.1"
)
makedepends=(
  'bison'
  'coreutils'
  'flex'
  # 'ei' # To build the Erlang bindings. Note that Erlang ≤ 22 will not work unless you use libguestfs ≤ 1.42.
  'erlang>=23' # To build the Erlang bindings. Note that Erlang ≤ 22 will not work unless you use libguestfs ≤ 1.42.
  'git'
  'gjs' # To build and test the GObject bindings.
  'glib2' # To build and test the GObject bindings.
  # 'gobject-introspection' # To build and test the GObject bindings. Introspection currently deactivated, see comment in `build()`.
  'gperf'
  'autoconf'
  'automake'
  'gcc'
  'gettext'
  # 'ghc' # To build Haskell bindings. Currently deactivated due to errors finding packages. See comment in `build()`.
  'go>=1.1.1' # To build the Go bindings.
  'java-runtime-headless>=1.6'
  'libtool'
  # 'libtirpc'
  'lua' # To build the LUA bindings.
  'ocaml>=4.07'
  'ocaml-augeas'
  'ocaml-findlib'
  'pcre2'
  'perl'
  'perl-pod-parser'
  'php' # To build PHP bindings
  # 'phpize' # To build PHP bindings
  'po4a'
  'python>=3.6'
  'rpcsvc-proto' # For rpcgen
  'ruby'
  'ruby-minitest'
  'ruby-rake'
  'ruby-rdoc'
  'rust' # To build rust bindings.
  # 'vala' # To build the Vala bindings.
  'valgrind' # For testing memory problems.
  'wget'
)
# # 2023-10-14: `check()` disabled, as takes very long, as it creates and tests several virtual machines.
# checkdepends=(
#   "libvirt-python" # For testing Python libvirt/libguestfs interactions.
#   "libxml2" # For xmllint
#   "ntfs-3g" # For testing windows image
#   "ocaml-ounit>=2.0.0" # For testing the common OCaml modules.
#   "perl"
#   "perl-module-build>=0.19"
#   # "perl-test-more"
#   # "perl-test-simple"
#   "python>=3.6"
#   # 'qemu-nbd'
# )
optdepends=(
  "acl: Library and programs for handling POSIX ACLs."
  "bash-completion: For tab-completion of commands in bash."
  "curl: Used by virt-builder for downloads."
  "fuse: fusermount(1), libfuse and kernel module are all needed if you want guestmount(1) and/or mount-local support."
  "gdisk: GPT disk support."
  "gnupg: Used by virt-builder for checking digital signatures."
  "java-runtime>=1.6: For Java bindings."
  "icoutils: Render icons from Windows guests."
  "libcap: Library and programs for handling Linux capabilities."
  "libconfig: To parse libguestfs's own config files."
  "libldm: Library and ldmtool(1) for handling Windows Dynamic Disks."
  "libselinux: Used by the libvirt backend to securely confine the appliance (sVirt)."
  "libsystemd-journal: For accessing systemd journals."
  "libtsk: For filesystem forensics analysis."
  'lua: For LUA bindings.'
  "nbdkit>=1.12"
  "netpbm: Render icons from guests."
  "ocaml: For OCaml bindings."
  "ocaml-augeas: For OCaml augeas binding."
  "ocaml-gettext: For localizing OCaml virt tools."
  "perl: Perl Bindings; Perl module used to test virt-rescue(1)."
  "perl-sys-virt: Sys-Virt tools."
  "php: For PHP bindings."
  "python>=3.6: Python bindings"
  "python-evtx: Used by virt-log(1) to parse Windows Event Log files."
  "readline: For nicer command line editing in guestfish(1)."
  "rpm: To parse the list of applications from RPM-based guests."
  "ruby: For ruby bindings."
  "wget: For '/usr/bin/update-libguestfs-appliance'."
  "yara>=4.0.0: Tool for categorizing files based on their content."
)
provides=(
  "${_pkgname}=${pkgver}"

  #"cargo-guestfs=${pkgver}"
  "erlang-guestfs=${pkgver}"
  #"golang-guestfs=${pkgver}"
  #"haskell-guestfs=${pkgver}"
  "java-guestfs=${pkgver}"
  "lua-guestfs=${pkgver}"
  "ocaml-guestfs=${pkgver}"
  "perl-guestfs=${pkgver}"
  "php-guestfs=${pkgver}"
  "python-guestfs=${pkgver}"
  "ruby-guestfs=${pkgver}"

  "guestfs-bash-completion=${pkgver}"
  "guestfsd=${pkgver}"
  "guestfish=${pkgver}"
  "virt-rescue=${pkgver}"
  "libguestfs.so"
  "libguestfs-gobject-1.0.so"
)
conflicts=(
  "${_pkgname}"
  "guestfsd"
  "guestfish"
  "virt-rescue"
)
source=(
  "${_pkgname}::git+https://github.com/libguestfs/libguestfs.git"
  "gnulib::git+https://git.savannah.gnu.org/git/gnulib.git"
  "libguestfs-common::git+https://github.com/libguestfs/libguestfs-common.git"
  "libguestfs-1.48.1-disable_php_tests.patch::https://gitlab.archlinux.org/archlinux/packaging/packages/libguestfs/-/raw/main/libguestfs-1.48.1-disable_php_tests.patch" # disable php tests, as missing arginfo definition makes them fail: https://github.com/libguestfs/libguestfs/issues/78
  # "libguestfs-1.48.6-ocaml5.patch::https://gitlab.archlinux.org/archlinux/packaging/packages/libguestfs/-/raw/main/libguestfs-1.48.6-ocaml5.patch" # fixes for OCaml >= 5. 2023-10-11: Seems to be present in the git checkout.
  "update-libguestfs-appliance"
  "${install}"
)
sha256sums=(
  'SKIP'
  'SKIP'
  'SKIP'
  '151d7ab43e7150c7d645eb0bad9681ce5ecc59cae44f254f08ef617ce3d9932f'
  # 'eb019796aede102254f22b25e10db5751891fbff8c4b7cf2d5786fd58f2b005a'
  '96809e9df6e349b7f5679cd62e42917b42c6f6d5b5b1d6063841d081a83beb27'
  '46ee0c9b3532cbbc38ddce7136b37e30ef71ad7aa004fa2fa552c9f165ee63d5'
)
# LTO breaks linking into OCaml library, e.g. with building the package `virt-v2v`.
options+=('!lto')

prepare() {
  cd "${srcdir}/${_pkgname}"

  git submodule init
  git config submodule.gnulib.url $srcdir/gnulib
  git config submodule.oommon.url $srcdir/libguestfs-common
  git submodule update

  for _patch in "${srcdir}/libguestfs-1.48.1-disable_php_tests.patch"; do
    msg2 "Applying patch '$(basename ${_patch}) ...'"
    patch -N -p1 --follow-symlinks -i "${_patch}"
  done

  autoreconf -fiv
}

pkgver() {
  cd "${srcdir}/${_pkgname}"

  _ver="$(git describe --tags | sed -E -e 's|^[vV]||' -e 's|\-g[0-9a-f]*$||' | tr '-' '+')"
  _rev="$(git rev-list --count HEAD)"
  _date="$(git log -1 --date=format:"%Y%m%d" --format="%ad")"
  _hash="$(git rev-parse --short HEAD)"

  if [ -z "${_ver}" ]; then
    error "Could not determine version."
    return 1
  else
    printf '%s' "${_ver}.r${_rev}.${_date}.${_hash}"
  fi
}

_fix_pod_files() {
  # work around podfile generation isssue
  rm -f po-docs/podfiles
  make -C po-docs update-po
}

build() {
  cd "${srcdir}/${_pkgname}"

# 2023-10-10: Currently, Haskell bindings are disabled. To enable, change `--disable-haskell` to `--enable-haskell` and add `ghc` to `makedepends`.  
# 2023-10-10: Enabling haskell bindings results in build error:  
# ```
# make[2]: Entering directory '/tmp/makepkg/build/libguestfs-git/src/libguestfs/haskell'
# ghc  -I../lib -L../lib/.libs -i. --make -main-is Guestfs010Load -odir .Guestfs010Load -o Guestfs010Load Guestfs010Load.hs ./Guestfs.hs -lguestfs
# [1 of 2] Compiling Guestfs          ( Guestfs.hs, .Guestfs010Load/Guestfs.o )
# 
# Guestfs.hs:539:1: error:
#     Could not find module ‘Prelude’
#     There are files missing in the ‘base-4.15.1.0’ package,
#     try running 'ghc-pkg check'.
#     Use -v (or `:set -v` in ghci) to see a list of the files searched for.
#     |
# 539 | import Prelude hiding (head, tail, truncate)
#     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# 
# Guestfs.hs:541:1: error:
#     Could not find module ‘Foreign’
#     There are files missing in the ‘base-4.15.1.0’ package,
#     try running 'ghc-pkg check'.
#     Use -v (or `:set -v` in ghci) to see a list of the files searched for.
#     |
# 541 | import Foreign
#     | ^^^^^^^^^^^^^^
# 
# Guestfs.hs:542:1: error:
#     Could not find module ‘Foreign.C’
#     There are files missing in the ‘base-4.15.1.0’ package,
#     try running 'ghc-pkg check'.
#     Use -v (or `:set -v` in ghci) to see a list of the files searched for.
#     |
# 542 | import Foreign.C
#     | ^^^^^^^^^^^^^^^^
# 
# Guestfs.hs:543:1: error:
#     Could not find module ‘Foreign.C.Types’
#     There are files missing in the ‘base-4.15.1.0’ package,
#     try running 'ghc-pkg check'.
#     Use -v (or `:set -v` in ghci) to see a list of the files searched for.
#     |
# 543 | import Foreign.C.Types
#     | ^^^^^^^^^^^^^^^^^^^^^^
# 
# Guestfs.hs:544:1: error:
#     Could not find module ‘System.IO’
#     There are files missing in the ‘base-4.15.1.0’ package,
#     try running 'ghc-pkg check'.
#     Use -v (or `:set -v` in ghci) to see a list of the files searched for.
#     |
# 544 | import System.IO
#     | ^^^^^^^^^^^^^^^^
# 
# Guestfs.hs:545:1: error:
#     Could not find module ‘Control.Exception’
#     There are files missing in the ‘base-4.15.1.0’ package,
#     try running 'ghc-pkg check'.
#     Use -v (or `:set -v` in ghci) to see a list of the files searched for.
#     |
# 545 | import Control.Exception
#     | ^^^^^^^^^^^^^^^^^^^^^^^^
# 
# Guestfs.hs:546:1: error:
#     Could not find module ‘Data.Typeable’
#     There are files missing in the ‘base-4.15.1.0’ package,
#     try running 'ghc-pkg check'.
#     Use -v (or `:set -v` in ghci) to see a list of the files searched for.
#     |
# 546 | import Data.Typeable
#     | ^^^^^^^^^^^^^^^^^^^^
# make[2]: *** [Makefile:1285: Guestfs010Load] Error 1
# make[2]: Leaving directory '/tmp/makepkg/build/libguestfs-git/src/libguestfs/haskell'
# make[1]: *** [Makefile:1089: all-recursive] Error 1
# ```

# 2023-10-10: `--enable-introspection=yes` results in build error:  
# ```
# Command '['/tmp/makepkg/build/libguestfs-git/src/libguestfs/gobject/tmp-introspectqgkewund/Guestfs-1.0', '--introspect-dump=/tmp/makepkg/build/libguestfs-git/src/libguestfs/gobject/tmp-introspectqgkewund/functions.txt,/tmp/makepkg/build/libguestfs-git/src/libguestfs/gobject/tmp-introspectqgkewund/dump.xml']' died with <Signals.SIGSEGV: 11>.
# ```  
# If re-enabling, add `gobject-introspection` to `makedepends`.
# Vala is disabled as a consequence: `configure: error: Vala bindings require GObject Introspection`. If enabling, also add `vala` to `makedepends`.

# 2023-10-10: `make` fails with `make: *** No rule to make target 'update-po'.  Stop.`.

  export CARGO_HOME="${srcdir}/.cargo"
  export GOPATH="${srcdir}/.go"
  export GOBIN="${GOPATH}/bin"

  ./configure \
    --prefix=/usr \
    --bindir=/usr/bin \
    --sbindir=/usr/bin \
    --libexecdir=/usr/libexec \
    --sysconfdir=/etc \
    --sharedstatedir=/var \
    --localstatedir=/var \
    --runstatedir=/run \
    --libdir=/usr/lib \
    --includedir=/usr/include \
    --oldincludedir=/usr/include \
    --datarootdir=/usr/share \
    --datadir=/usr/share/guestfs \
    --infodir=/usr/share/info \
    --localedir=/usr/share/locale \
    --mandir=/usr/share/man \
    --docdir=/usr/share/doc/"${_pkgname}" \
    --htmldir=/usr/share/doc/"${_pkgname}"/html \
    --dvidir=/usr/share/doc/"${_pkgname}"/dvi \
    --pdfdir=/usr/share/doc/"${_pkgname}"/pdf \
    --psdir=/usr/share/doc/"${_pkgname}"/ps \
    --enable-shared \
    --disable-static \
    --disable-werror \
    --enable-largefile \
    --enable-nls \
    --enable-rpath \
    --enable-packet-dump \
    --enable-fuse \
    --enable-daemon \
    --enable-install-daemon \
    --enable-appliance \
    --enable-appliance-format-auto \
    --enable-ocaml \
    --enable-perl \
    --enable-probes \
    --enable-python \
    --enable-ruby \
    --disable-haskell \
    --enable-php \
    --enable-erlang \
    --enable-lua \
    --enable-golang \
    --enable-gobject \
    --enable-introspection=no \
    --enable-rust \
    --enable-vala=no \
    --with-default-backend=direct \
    --with-extra-packages="openssh" \
    --with-guestfs-path=/usr/lib/guestfs \
    --with-libvirt \
    --with-qemu="qemu-system-x86_64 qemu-system-i386 qemu" \
    --with-readline \
    --with-java

  make
  #if ! make; then
  #  _fix_pod_files
  #  make
  #fi

  # for some reason ruby is not properly made (albeit enabled)
  make -C ruby
}

# # 2023-10-14: `check()` disabled, as takes very long, as it creates and tests several virtual machines.
# check() {
#   cd "${srcdir}/${_pkgname}"
# 
#   export CARGO_HOME="${srcdir}/.cargo"
#   export GOPATH="${srcdir}/.go"
#   export GOBIN="${GOPATH}/bin"
# 
#   # # To sanity check that the build worked, do (warning, this takes very long, as it creates and tests several virtual machines):
#   # make quickcheck
# 
#   # # To run the basic tests, do (warning, this takes very long, as it creates and tests several virtual machines):
#   # make check
# 
#   ## There are many more tests you can run. See guestfs-hacking(1) for details.
# }

package() {
  cd "${srcdir}/${_pkgname}"

  export CARGO_HOME="${srcdir}/.cargo"
  export GOPATH="${srcdir}/.go"
  export GOBIN="${GOPATH}/bin"

  make INSTALLDIRS=vendor DESTDIR="${pkgdir}" install
  #if ! make DESTDIR="${pkgdir}" install; then
  #  _fix_pod_files
  #  make DESTDIR="${pkgdir}" install
  #fi

  # Clean up messed-up installation directories
  mv -v "${pkgdir}/lib"/* "${pkgdir}/usr/lib"/
  rmdir "${pkgdir}/lib"

  install -dvm755 "${pkgdir}/usr/lib/guestfs"
  install -dvm755 "${pkgdir}/var/cache/guestfs"
  install -Dvm755 "${srcdir}/update-libguestfs-appliance" "${pkgdir}/usr/bin/update-libguestfs-appliance"

  for _docfile in AUTHORS HACKING README TODO; do
    install -Dvm644 "${_docfile}" "${pkgdir}/usr/share/doc/${_pkgname}/${_docfile}"
  done
  for _licensefile in COPYING COPYING.LIB; do
    install -Dvm644 "${_licensefile}" "${pkgdir}/usr/share/licenses/${pkgname}/${_licensefile}"
    ln -svr "${pkgdir}/usr/share/licenses/${pkgname}/${_licensefile}" "${pkgdir}/usr/share/doc/${_pkgname}/${_licensefile}"
  done
}