# We patch on-the-fly. This way, we don't need to publish our own archiso32 source and keep that in-sync.

if declare -f build; then
  >&2 echo 'Ooops, upstream added a build() function: more elaborate patching will be required.'
  exit 1
fi

build() {
  cd "${pkgbase}/configs/releng"
  mv packages.x86_64 packages.i686
  sed -i '
    /^edk2-shell$/d
  ' packages.i686
  sed -i '
    s@archlinux@archlinux32@g
    s@ARCH_@ARCH32_@g
    s@\bx86_64\b@i686@g
    /^bootmodes=/ s@\(\s\+'"'"'uefi-x64\.systemd-boot\.\S\+'"'"'\)\+@@
  ' profiledef.sh
  find airootfs efiboot syslinux -type f -exec \
    sed -i '
      s@\bx86_64\b@i686@g
      s@Arch Linux@\0 32@g
      s@pacman-key --populate archlinux@\032@g
    ' {} +
}