# LFS-Ryco setup environment variables
# Adjust as necessary
# Last updated 3/15/2026

export LFS_ARCH=$(/usr/bin/rpm --eval=%{_arch})

if [ -z "${LFS_ARCH}" ]; then
    echo "Failed to determine arch" >&2
    exit 1
fi

if [ "${LFS_ARCH}" = "x86_64" ]; then
    DMI=$(dmidecode -s system-manufacturer 2>/dev/null)
    if [ -n "${DMI}" ]; then
        echo $DMI
    fi
    if [ "${DMI}" = "VMware, Inc." ]; then
        export LFS_VIRT="open-vm-tools libfuse3 glib2"
    fi
fi

if [ "${LFS_ARCH}" = "armv7hnl" ]; then
    export LFS_UEFI=no
else
    export LFS_UEFI=yes
fi

# IMG_FILE should be empty if using a physical device
export IMG_FILE=${HOME}/lfs-ryco-${LFS_ARCH}.img
export IMG_SIZE=2000
# TARGET_DEVICE can be a physical device
export TARGET_DEVICE=/dev/mapper/loop0

case ${TARGET_DEVICE} in
   /dev/nvme*)
      P=p
      ;;
   /dev/mmcblk*)
      P=p
      ;;
   /dev/mapper/loop*)
      P=p
      ;;
   *)
      P=
      ;;
esac

export BOOT_PARTITION=${TARGET_DEVICE}${P}1
export ROOT_PARTITION=${TARGET_DEVICE}${P}2
export LFS_ROOTFS=/mnt/rootfs
export LFS_REPO=current
export LFS_UPDATES="lfs-updates php-ryco-lib php-lfsryco-autoloader"
export LFS_BASE="base standard systemd-standard-pkg lfs-updates-pkg"
export LFS_LINUXIMAGE="linux-${LFS_ARCH}-image dracut"
export LFS_OPENSSH="openssh openssh-server libmd"
if [ "$LFS_UEFI" = "yes" ]; then
    export LFS_SECUREBOOT="secureboot-pkg"
    export LFS_BOOTLOADER="bootloader-pkg"
    export LFS_TPM2="systemd-tpm2-pkg"
fi
export LFS_PACKAGES="${LFS_BASE} ${LFS_LINUXIMAGE} ${LFS_OPENSSH} ${LFS_SECUREBOOT} ${LFS_TPM2} ${LFS_BOOTLOADER} ${LFS_VIRT}"
export SWAP_FILE=/var/swapfile
export SWAP_SIZE=4000
export BOOT_SIZE=500
