# based on the PKGBUILD from core mkinitcpio by
# Maintainer: Dave Reisner <dreisner@archlinux.org>
# Maintainer: Thomas Bächler <thomas@archlinux.org>
# this pkg attempts to replace mkinitcpio with a version
# that doesn't depend on systemd

_pkgname=mkinitcpio

pkgname=mkinitcpio-nosystemd
pkgver=23
pkgrel=2
pkgdesc="Modular initramfs image creation utility"
arch=('any')
url="https://projects.archlinux.org/mkinitcpio.git/"
license=('GPL')
groups=('base-nosystemd')
depends=('awk' 'mkinitcpio-busybox>=1.19.4-2' 'kmod' 'util-linux>=2.23' 'libarchive'
         'coreutils' 'bash' 'findutils' 'grep' 'filesystem>=2011.10-1' 'gzip')
makedepends=('asciidoc')
optdepends=('xz: Use lzma or xz 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}")
conflicts=('mkinitcpio')
backup=('etc/mkinitcpio.conf')
source=("https://sources.archlinux.org/other/${_pkgname}/${_pkgname}-$pkgver.tar.gz"
        'nosystemd.patch')
install=mkinitcpio.install
sha256sums=('80f12a07f0dceef81dfe87200f099bd2149e0990391dda6defebaa5697f8a35a'
            'e561464646274d995a02776d3fee03199e3b3c5bdc80f31fdf53391744bb6b64')

prepare() {
    #start removing systemd related stuff
    local d=${srcdir}/${_pkgname}-${pkgver}
    [ ! -h "$d" ] && ln -s ${_pkgname}-${pkgver} "$d"
    [ ! -d "$d" ] && echo "!!!!! cannot locate dir '$d'" && exit 666
    rm -rf ${d}/install/sd-vconsole ${d}/install/sd-shutdown
    cd $_pkgname-$pkgver
    patch -Np1 -i $srcdir/nosystemd.patch
    #end removing systemd related stuff
}
package() {
    make -C "$_pkgname-$pkgver" DESTDIR="$pkgdir" install
}
