#!/usr/bin/bash
# JOBoRun		: Jwm OpenBox Obarun RUNit
# Maintainer	: Joe Bo Run <joborun@disroot.org>
# PkgSource		: url="https://gittea.disroot.org/joborun-pkg/jobcore/$pkgname"
# Website		: https://pozol.eu
#-----------------------------------------| DESCRIPTION |---------------------------------------

pkgname=mkinitcpio
pkgver=36
pkgrel=01
pkgdesc="Modular initramfs image creation utility"
#url='https://github.com/archlinux/mkinitcpio'
#url='https://gitlab.archlinux.org/archlinux/mkinitcpio/mkinitcpio'
url="https://sources.archlinux.org/other"
makedepends=('binutils' 'asciidoc' 'sed')
install=mkinitcpio.install
depends=('awk' 'mkinitcpio-busybox>=1.35.0' 'kmod' 'util-linux>=2.23' 'libarchive' 'coreutils'
         'bash' 'binutils' 'diffutils' 'findutils' 'grep' 'filesystem' 'gzip')
checkdepends=('bash-bats' 'bash-bats-assert' 'lzop')
optdepends=('zstd: Use zstd compression for the initramfs image'
            'bzip2: Use bzip2 compression for the initramfs image'
            'lzop: Use lzo compression for the initramfs image'
            'lz4: Use lz4 compression for the initramfs image'
            'mkinitcpio-nfs-utils: Support for root filesystem on NFS')
provides=("mkinitcpio=$pkgver-$pkgrel"
	'initramfs')
#backup=('etc/mkinitcpio.conf')
source=("$url/$pkgname/$pkgname-$pkgver.tar.gz"{,.sig}
	nosystemd.patch
	mkinitcpio.conf)
#        "fix-strip.patch::https://github.com/archlinux/mkinitcpio/commit/dece596d569ca90af902bf2403227b478b629c03.patch"
#        0001-functions-fix-overwriting-of-symlinks-with-regular-f.patch)

prepare() {
#	patch -Np1 -d "$pkgname-$pkgver" < '0001-functions-fix-overwriting-of-symlinks-with-regular-f.patch'
	cd "${pkgname}-${pkgver}"
#	patch -Np1 < "$srcdir/fix-strip.patch"
	patch -Np1 -i ../nosystemd.patch

}

check() {
	make -C $pkgname-$pkgver check
}

package() {
	make -C $pkgname-$pkgver DESTDIR="$pkgdir" install
	rm -f "${pkgdir}"/usr/lib/initcpio/install/sd-*
	rm -f "${pkgdir}/etc/mkinitcpio.conf"
	install -Dm644 "${srcdir}/mkinitcpio.conf" "${pkgdir}/etc/mkinitcpio.conf"
}

#---- arch license gpg-key & sha256sums ----

arch=(x86_64)

license=(GPL)

validpgpkeys=('ECCAC84C1BA08A6CC8E63FBBF22FB1D78A77AEAB'    # Giancarlo Razzolini
              'C100346676634E80C940FB9E9C02FF419FECBE16')   # Morten Linderud

sha256sums=(7b3b1cdf546922f47845a3ac4353ca97899a4bb68cfff29098c45135e5fb8b5e  # mkinitcpio-36.tar.gz
	165f43e438035f7b58ac71be07661c773a7616f69018cee5ab8e7e31f0b76aa7  # mkinitcpio-36.tar.gz.sig
	c4afeb6b3300c4d50c3f01233705b542f59d6e95a7670f7efde097ea209ef5bd  # nosystemd.patch
	c8ec2debd54233927dd97bd25ef4ac00e1ac850f9b34a3d414e1a66608c36040) # mkinitcpio.conf

##  a164e6a08a5f412fd8e2fa7cb9d5db49cef7f7118566529d13d48435215680c4  mkinitcpio-36-01-x86_64.pkg.tar.lz

