summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 8c93c7594b9011e22cf79193de5c84f354c9b647 (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
# Maintainer: Matheus Afonso Martins Moreira <matheus@matheusmoreira.com>
pkgname=virtdev-git
pkgver=r307.0b213b5
pkgrel=1
pkgdesc='Isolated virtual development machines on KVM/QEMU'
arch=('x86_64')
url='https://github.com/matheusmoreira/virtdev'
license=('AGPL-3.0-or-later')
depends=(
  'bash>=5.2'
  'qemu-img'
  'qemu-system-x86'
  'edk2-ovmf'
  'openssh'
  'socat'
)
optdepends=(
  'archiso: required for building the installation ISO (virtdev-iso)'
  'rsync: required for backup, restore, transfer, and recreate'
)
makedepends=('git')
provides=("${pkgname%-git}")
conflicts=("${pkgname%-git}")
source=("${pkgname}::git+${url}.git")
sha256sums=('SKIP')

pkgver() {
  cd "${pkgname}"

  if git describe --long --tags 2>/dev/null | grep -q .; then
    git describe --long --tags | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
  else
    printf 'r%s.%s' "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
  fi
}

build() {
  make -C "${pkgname}"
}

package() {
  cd "${pkgname}"

  # Install commands (exclude C source)
  local _cmd
  while IFS= read -rd '' _cmd; do
    install -Dm755 "${_cmd}" "${pkgdir}/usr/bin/${_cmd##*/}"
  done < <(find bin/ -maxdepth 1 -type f ! -name '*.c' -print0)

  # Install shared bash libraries (sourced via the bin/ scripts'
  # bootstrap; not executable).
  install -Dm644 -t "${pkgdir}/usr/lib/${pkgname%-git}/" lib/virtdev/*

  # Install ISO profile
  local _profiledir="${pkgdir}/usr/share/${pkgname%-git}/profile"

  local _file
  while IFS= read -rd '' _file; do
    install -Dm644 "${_file}" "${_profiledir}/${_file#iso/}"
  done < <(find iso/ -type f -print0)
  unset _file

  chmod 755 "${_profiledir}/airootfs/root/virtdev/install.sh"

  install -dm755 "${_profiledir}/airootfs/etc/systemd/system/multi-user.target.wants"
  ln -s ../virtdev-install.service "${_profiledir}/airootfs/etc/systemd/system/multi-user.target.wants/virtdev-install.service"

  # Install documentation
  install -Dm644 README.md  "${pkgdir}/usr/share/doc/${pkgname%-git}/README.md"
  install -Dm644 DESIGN.md  "${pkgdir}/usr/share/doc/${pkgname%-git}/DESIGN.md"
  install -Dm644 LICENSE.AGPLv3 "${pkgdir}/usr/share/licenses/${pkgname%-git}/LICENSE"
}