File PKGBUILD of Package mkosi

# Maintainer: Christian Rebischke <chris.rebischke@archlinux.org>
# Maintainer: David Runge <dvzrv@archlinux.org>
# Contributor: Lucas Werkmeister <mail@lucaswerkmeister.de>
# Contributor: Dave Reisner <dreisner@archlinux.org>

pkgname=mkosi
pkgver=21
pkgrel=1
pkgdesc="Build Legacy-Free OS Images"
arch=(any)
url="https://github.com/systemd/mkosi"
license=(LGPL-2.1-or-later)
depends=(
  bubblewrap
  python
  python-argcomplete
  sh
  systemd
)
makedepends=(
  pandoc-cli
  python-build
  python-installer
  python-setuptools
  python-setuptools-scm
  python-wheel
)
checkdepends=(
  python-pytest
)
optdepends=(
  'acl: for removing directories created by mkosi'
  'apt: for creating Debian and Ubuntu images'
  'btrfs-progs: raw_btrfs and subvolume output formats'
  'cpio: for cpio output format'
  'debian-archive-keyring: build Debian images'
  'dnf: for creating CentOS, Fedora, OpenMandriva, Mageia and OpenSUSE images'
  'edk2-ovmf: for running bootable images using QEMU'
  'erofs-utils: for EROFS support'
  'gnupg: for signing image checksums'
  'kmod: for images using Linux kernels'
  'mtools: for FAT support'
  'openssl: for UEFI SecureBoot'
  'python-pefile: for bootable images'
  'qemu: for running bootable images using QEMU'
  'sbsigntools: for UEFI SecureBoot'
  'swtpm: for adding software TPM when running bootable images using QEMU'
  'systemd-ukify: for Unified Kernel Image (UKI) support'
  'tar: for tar output format and Debian or Ubuntu images'
  'ubuntu-keyring: for building Ubuntu images'
  'xz: for compressing images with xz'
  'zstd: for compressing images with zstd'
  # 'zypper: for creating OpenSUSE images'  # TODO: package zypper
)
source=(
  $pkgname-$pkgver.tar.gz::$url/archive/v$pkgver.tar.gz
)
sha256sums=('SKIP')

build() {
  cd $pkgname-$pkgver
  python -m build --wheel --no-isolation
  pandoc -t man -s -o $pkgname/resources/$pkgname.1 $pkgname/resources/$pkgname.md
}

check() {
  cd $pkgname-$pkgver
  pytest -vv
}

package() {
  cd $pkgname-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl

  # add kernel-install integration
  install -vDm 755 kernel-install/50-$pkgname.install -t "$pkgdir/usr/lib/kernel/install.d/"

  # NOTE: mkosi automatically uses the mkosi-initrd integration from Python's site-packages
  # distribution overrides can be added below /usr/lib/mkosi-initrd
  # user overrides can be added below /etc/mkosi-initrd
  install -vdm 755 "$pkgdir/etc/mkosi-initrd"

  install -vDm 644 $pkgname/resources/$pkgname.1 -t "$pkgdir/usr/share/man/man1/"
  install -vDm 644 docs/*.md {NEWS,README}.md -t "$pkgdir/usr/share/doc/$pkgname/"
}
openSUSE Build Service is sponsored by