# Fedora Grub Config


set this_isopath="${isodev}${isopath}/fedora"

# abuse for to check for existence
for isofile in ${this_isopath}/Fedora-*.iso; do
  if [ ! -e "$isofile" ]; then break; fi

	echo "Found Fedoras in ${this_isopath}"

submenu "Fedora >" "${this_isopath}" --class fedora {
this_isopath=$2

for isofile in ${this_isopath}/Fedora-*.iso; do
  if [ ! -e "$isofile" ]; then break; fi

  regexp \
    --set 1:isoname \
    --set 2:variant \
    --set 3:arch \
    --set 4:version \
    "^.*/(Fedora-([^-]+)-Live-([^-]+)-([^-]+)-[^-]+\.iso)\$" "${isofile}"

  menuentry "Fedora ${version} ${arch} ${variant}" "${isofile}" "${isoname}" --class fedora {
    set isofile=$2
    set isoname=$3

    regexp \
        --set 1:isodev \
        --set 2:isofile \
        "^(\(.*\))?(.*)\$" "${isofile}"

    echo "Using ${isoname}..."
    loopback loop "${isodev}${isofile}"
    probe --set isolabel --label (loop)
    linux (loop)/images/pxeboot/vmlinuz root=live:CDLABEL=${isolabel} rd.live.image iso-scan/filename=${isofile} rhgb ro
    initrd (loop)/images/pxeboot/initrd.img
  }
done
}

# kill for loop
break
done
