# Maintainer: Developer <dev@tuxcore.org>


[[ "${CARCH}" == 'x86_64' ]] && _EFI_ARCH='x86_64'
[[ "${CARCH}" == 'i686' ]] && _EFI_ARCH='i386'

[[ "${CARCH}" == 'x86_64' ]] && _EMU_ARCH='x86_64'
[[ "${CARCH}" == 'i686' ]] && _EMU_ARCH='i386'

pkgname='grub'
pkgver=%version%
pkgrel=%release%
epoch=2
pkgdesc='GNU GRand Unified Bootloader (2)'
url='https://www.gnu.org/software/grub/'
arch=('x86_64')
license=('GPL-3.0-or-later')
backup=('etc/default/grub'
        'etc/grub.d/40_custom')
install="${pkgname}.install"
options=('!makeflags')

conflicts=('grub-common' 'grub-bios' 'grub-emu' "grub-efi-${_EFI_ARCH}" 'grub-legacy')
replaces=('grub-common' 'grub-bios' 'grub-emu' "grub-efi-${_EFI_ARCH}")
provides=('grub-common' 'grub-bios' 'grub-emu' "grub-efi-${_EFI_ARCH}")

depends=('sh' 'xz' 'gettext' 'device-mapper')
optdepends=('freetype2: For grub-mkfont usage'
            'fuse3: For grub-mount usage'
            'dosfstools: For grub-mkrescue FAT FS and EFI support'
            'lzop: For grub-mkrescue LZO support'
            'efibootmgr: For grub-install EFI support'
            'libisoburn: Provides xorriso for generating grub rescue iso using grub-mkrescue'
            'os-prober: To detect other OSes when generating grub.cfg in BIOS systems'
            'mtools: For grub-mkrescue FAT FS support')

source=("$pkgname-$pkgver-$pkgrel.tar.gz"::"https://geo.mirror.pkgbuild.com/pool/packages/$pkgname-$epoch:$pkgver-$pkgrel-x86_64.pkg.tar.zst"
        "grub.default"
        "sbat.csv")

sha256sums=('SKIP'
            'SKIP'
            'SKIP')

package() {

  cp -f $srcdir/grub.default $srcdir/etc/default/grub
  cp -f $srcdir/sbat.csv $srcdir/usr/share/grub/sbat.csv

  mkdir -p "$pkgdir"/usr
  mkdir -p "$pkgdir"/etc
    # Install
  cp -R $srcdir/*/ "$pkgdir"/
}
