# Calculate path=/tmp exec=/bin/bash os_install_root_type!=livecd&&os_install_scratch==off&&pkg(sys-boot/grub)>=2.00_p5000

echo "Configuring the grub"
# mount some need directories from the current system to the installing system

#?ac_install_disk==on#
mount -t proc none #-cl_chroot_path-#/proc
mount -t sysfs none #-cl_chroot_path-#/sys
mount -o bind /dev #-cl_chroot_path-#/dev
#ac_install_disk#

#?ac_install_disk==on&&os_arch_machine==i686&&os_install_arch_machine!=i686#
for mdir in /bin /sbin /lib /usr/sbin /usr/bin /usr/lib /usr/libexec;do
	mount -o bind $mdir #-cl_chroot_path-#/$mdir
done
#ac_install_disk#
# bind mount current system root to install system for correct work os-prober
#?os_root_type==hdd&&ac_install_disk==on#
mount -o bind / #-cl_chroot_path-#/mnt
#os_root_type#

# temporary disable cache for blkid for correct work
[[ -f #-cl_chroot_path-#/etc/blkid.conf ]] && mv #-cl_chroot_path-#/etc/blkid.conf #-cl_chroot_path-#/etc/blkid.conf.bak
echo "CACHE_FILE=/dev/null" >#-cl_chroot_path-#/etc/blkid.conf

#?ac_install_disk==on#
/bin/chroot #-cl_chroot_path-# grub-mkconfig -o /boot/grub/grub.cfg &>/dev/null
#ac_install_disk#
#?ac_install_disk==off#
/usr/sbin/grub-mkconfig -o /boot/grub/grub.cfg &>/dev/null
#ac_install_disk#
res=$?

[[ -f #-cl_chroot_path-#/etc/blkid.conf.bak ]] && mv #-cl_chroot_path-#/etc/blkid.conf.bak #-cl_chroot_path-#/etc/blkid.conf || rm -f #-cl_chroot_path-#/etc/blkid.conf

#?ac_install_disk==on&&os_arch_machine==i686&&os_install_arch_machine!=i686#
for mdir in /bin /sbin /lib /usr/sbin /usr/bin /usr/lib /usr/libexec;do
	umount #-cl_chroot_path-#/$mdir
done
#ac_install_disk#

#?ac_install_disk==on#
umount #-cl_chroot_path-#/proc #-cl_chroot_path-#/sys #-cl_chroot_path-#/dev
#ac_install_disk#

#?os_root_type==hdd&&ac_install_disk==on#
umount #-cl_chroot_path-#/mnt
#os_root_type#

#?exists(#-cl_chroot_path-#/boot/grub/unicode.pf2)!=&&exists(#-cl_chroot_path-#/usr/share/grub/unicode.pf2)!=#
cp #-cl_chroot_path-#/usr/share/grub/unicode.pf2 #-cl_chroot_path-#/boot/grub/unicode.pf2 &>/dev/null
#exists#

exit $res
